浏览代码

fix: rotation

martabal 1 年之前
父节点
当前提交
9fdc982ca6
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 2 2
      server/src/domain/asset/dto/asset.dto.ts
  2. 7 2
      web/src/lib/components/asset-viewer/photo-viewer.svelte

+ 2 - 2
server/src/domain/asset/dto/asset.dto.ts

@@ -205,9 +205,9 @@ export class AssetBulkUpdateDto extends BulkIdsDto {
   longitude?: number;
   longitude?: number;
 
 
   @Optional()
   @Optional()
+  @IsInt()
   @Min(1)
   @Min(1)
   @Max(8)
   @Max(8)
-  @IsInt()
   @Type(() => Number)
   @Type(() => Number)
   orientation?: number;
   orientation?: number;
 }
 }
@@ -240,9 +240,9 @@ export class UpdateAssetDto {
   longitude?: number;
   longitude?: number;
 
 
   @Optional()
   @Optional()
+  @IsInt()
   @Min(1)
   @Min(1)
   @Max(8)
   @Max(8)
-  @IsInt()
   @Type(() => Number)
   @Type(() => Number)
   orientation?: number;
   orientation?: number;
 }
 }

+ 7 - 2
web/src/lib/components/asset-viewer/photo-viewer.svelte

@@ -30,14 +30,19 @@
   //   }
   //   }
   // };
   // };
 
 
+  const getRotationModulo = (rotation: number): number => {
+    return ((rotation % 360) + 360) % 360;
+  };
+
   $: {
   $: {
-    $zoomImageWheelState.currentRotation === 0 || $zoomImageWheelState.currentRotation === 180
+    getRotationModulo($zoomImageWheelState.currentRotation) === 0 ||
+    getRotationModulo($zoomImageWheelState.currentRotation) === 180
       ? ([imgHeight, imgWidth] = [clientHeight, clientWidth])
       ? ([imgHeight, imgWidth] = [clientHeight, clientWidth])
       : ([imgWidth, imgHeight] = [clientHeight, clientWidth]);
       : ([imgWidth, imgHeight] = [clientHeight, clientWidth]);
   }
   }
 
 
   const rotationToOrientation = (rotation: number): number => {
   const rotationToOrientation = (rotation: number): number => {
-    switch (((rotation % 360) + 360) % 360) {
+    switch (getRotationModulo(rotation)) {
       case 0:
       case 0:
         return 1;
         return 1;
       case 90:
       case 90: