Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
sharknoon committed Nov 29, 2024
1 parent 94935ea commit 2493634
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions stores/favorite-tiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const useFavoriteTilesStore = defineStore(
const cloudFavoriteTiles = await getCloudFavoriteTiles();
if (cloudFavoriteTiles === undefined) return;
const mergedFavoriteTiles = Array.from(
new Set([...cloudFavoriteTiles, ...favoriteTiles.value])
new Set([...cloudFavoriteTiles, ...favoriteTiles.value]),
);
favoriteTiles.value = mergedFavoriteTiles;
setCloudFavoriteTiles(mergedFavoriteTiles);
Expand Down Expand Up @@ -119,7 +119,7 @@ export const useFavoriteTilesStore = defineStore(
const newFavoriteTiles: string = JSON.parse(vuex).favoriteTiles;
localStorage.setItem(
"favorite-tiles",
JSON.stringify({ favoriteTiles: newFavoriteTiles })
JSON.stringify({ favoriteTiles: newFavoriteTiles }),
);
localStorage.removeItem("vuex");
} catch (e) {
Expand All @@ -128,5 +128,5 @@ export const useFavoriteTilesStore = defineStore(
}
},
},
}
},
);
24 changes: 12 additions & 12 deletions utils/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class Zoom {
maxZoom: 15,
zoomFactor: 1.2,
restrictInsideParents: true,
}
},
) {
this.el = el;
this.options = options;
Expand Down Expand Up @@ -98,12 +98,12 @@ export default class Zoom {
newTranslationX = Zoom.restrictTranslationInsideParent(
elementScaled.width,
this.el.parentElement?.clientWidth || 0,
newTranslationX
newTranslationX,
);
newTranslationY = Zoom.restrictTranslationInsideParent(
elementScaled.height,
this.el.parentElement?.clientHeight || 0,
newTranslationY
newTranslationY,
);
}
this.el.style.transform = new DOMMatrix([
Expand Down Expand Up @@ -139,7 +139,7 @@ export default class Zoom {
} else if (newScale > this.options.maxZoom) {
newScale = this.options.maxZoom;
}
let scaleDelata = newScale / this.scale;
const scaleDelata = newScale / this.scale;

// From the pointers coordinate (relative to document / page), subtract the offset of the element its parent (distance to the page borders because of padding, margin, border, navigation-bars, etc...)
// and subtract half of the element size to get the pointer position relative to the center of the element
Expand All @@ -161,12 +161,12 @@ export default class Zoom {
newTranslationX = Zoom.restrictTranslationInsideParent(
elementScaled.width,
this.el.parentElement?.clientWidth ?? 0,
newTranslationX
newTranslationX,
);
newTranslationY = Zoom.restrictTranslationInsideParent(
elementScaled.height,
this.el.parentElement?.clientHeight ?? 0,
newTranslationY
newTranslationY,
);
}

Expand All @@ -192,7 +192,7 @@ export default class Zoom {
this.initialTouchY = center.y;
this.initialPinchDistance = Zoom.getTouchDistance(
event.touches[0],
event.touches[1]
event.touches[1],
);
};

Expand All @@ -203,7 +203,7 @@ export default class Zoom {
// Calculate the new scale
const newPinchDistance = Zoom.getTouchDistance(
event.touches[0],
event.touches[1]
event.touches[1],
);
let newScale =
(newPinchDistance / this.initialPinchDistance) * this.scale;
Expand All @@ -216,7 +216,7 @@ export default class Zoom {
// Calculate the new translation
const newCenter = Zoom.getTouchCenter(
event.touches[0],
event.touches[1]
event.touches[1],
);
const deltaX = newCenter.x - this.initialTouchX;
const deltaY = newCenter.y - this.initialTouchY;
Expand Down Expand Up @@ -307,12 +307,12 @@ export default class Zoom {
currentTranslationX = Zoom.restrictTranslationInsideParent(
elementScaled.width * scaleDelta,
this.el.parentElement?.clientWidth || 0,
currentTranslationX
currentTranslationX,
);
currentTranslationY = Zoom.restrictTranslationInsideParent(
elementScaled.height * scaleDelta,
this.el.parentElement?.clientHeight || 0,
currentTranslationY
currentTranslationY,
);
}

Expand All @@ -332,7 +332,7 @@ export default class Zoom {
static restrictTranslationInsideParent(
elementLength: number,
parentElementLength: number,
translate: number
translate: number,
): number {
// "overflow" left / right or top / bottom of element relative to its parent
// Divide by 2 to get one bar out of the two
Expand Down

0 comments on commit 2493634

Please sign in to comment.