chore: Minor refactoring for consistency (#2425)

This commit is contained in:
Lipis 2020-11-29 18:32:51 +02:00 committed by GitHub
parent 204c8370a0
commit b21fd49412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 76 additions and 82 deletions

View File

@ -24,6 +24,8 @@
"no-unused-expressions": "warn", "no-unused-expressions": "warn",
"no-unused-vars": "warn", "no-unused-vars": "warn",
"no-useless-return": "warn", "no-useless-return": "warn",
"no-var": "warn",
"object-shorthand": "warn",
"one-var": ["warn", "never"], "one-var": ["warn", "never"],
"prefer-arrow-callback": "warn", "prefer-arrow-callback": "warn",
"prefer-const": [ "prefer-const": [

View File

@ -9,9 +9,9 @@
// node build/static/js/build-node.js // node build/static/js/build-node.js
// open test.png // open test.png
var rewire = require("rewire"); const rewire = require("rewire");
var defaults = rewire("react-scripts/scripts/build.js"); const defaults = rewire("react-scripts/scripts/build.js");
var config = defaults.__get__("config"); const config = defaults.__get__("config");
// Disable multiple chunks // Disable multiple chunks
config.optimization.runtimeChunk = false; config.optimization.runtimeChunk = false;

View File

@ -98,7 +98,7 @@ export const actionDeleteSelected = register({
LinearElementEditor.movePoint(element, activePointIndex, "delete"); LinearElementEditor.movePoint(element, activePointIndex, "delete");
return { return {
elements: elements, elements,
appState: { appState: {
...appState, ...appState,
editingLinearElement: { editingLinearElement: {

View File

@ -156,7 +156,7 @@ export const actionLoadScene = register({
onClick={() => { onClick={() => {
loadFromJSON(appState) loadFromJSON(appState)
.then(({ elements, appState }) => { .then(({ elements, appState }) => {
updateData({ elements: elements, appState: appState }); updateData({ elements, appState });
}) })
.catch(muteFSAbortError) .catch(muteFSAbortError)
.catch((error) => { .catch((error) => {

View File

@ -159,7 +159,7 @@ export const renderSpreadsheet = (
const range = max - min; const range = max - min;
const minYLabel = newTextElement({ const minYLabel = newTextElement({
x: x, x,
y: y + BAR_HEIGHT, y: y + BAR_HEIGHT,
strokeColor: appState.currentItemStrokeColor, strokeColor: appState.currentItemStrokeColor,
backgroundColor: appState.currentItemBackgroundColor, backgroundColor: appState.currentItemBackgroundColor,
@ -177,8 +177,8 @@ export const renderSpreadsheet = (
}); });
const maxYLabel = newTextElement({ const maxYLabel = newTextElement({
x: x, x,
y: y, y,
strokeColor: appState.currentItemStrokeColor, strokeColor: appState.currentItemStrokeColor,
backgroundColor: appState.currentItemBackgroundColor, backgroundColor: appState.currentItemBackgroundColor,
fillStyle: appState.currentItemFillStyle, fillStyle: appState.currentItemFillStyle,
@ -194,11 +194,11 @@ export const renderSpreadsheet = (
verticalAlign: DEFAULT_VERTICAL_ALIGN, verticalAlign: DEFAULT_VERTICAL_ALIGN,
}); });
const bars = spreadsheet.values.map((value, i) => { const bars = spreadsheet.values.map((value, index) => {
const valueBarHeight = value - min; const valueBarHeight = value - min;
const percentBarHeight = valueBarHeight / range; const percentBarHeight = valueBarHeight / range;
const barHeight = percentBarHeight * BAR_HEIGHT; const barHeight = percentBarHeight * BAR_HEIGHT;
const barX = i * (BAR_WIDTH + BAR_SPACING) + LABEL_SPACING; const barX = index * (BAR_WIDTH + BAR_SPACING) + LABEL_SPACING;
const barY = BAR_HEIGHT - barHeight; const barY = BAR_HEIGHT - barHeight;
return newElement({ return newElement({
type: "rectangle", type: "rectangle",
@ -218,9 +218,9 @@ export const renderSpreadsheet = (
}); });
const xLabels = const xLabels =
spreadsheet.labels?.map((label, i) => { spreadsheet.labels?.map((label, index) => {
const labelX = const labelX =
i * (BAR_WIDTH + BAR_SPACING) + LABEL_SPACING + BAR_SPACING; index * (BAR_WIDTH + BAR_SPACING) + LABEL_SPACING + BAR_SPACING;
const labelY = BAR_HEIGHT + BAR_SPACING; const labelY = BAR_HEIGHT + BAR_SPACING;
return newTextElement({ return newTextElement({
text: label.length > 8 ? `${label.slice(0, 5)}...` : label, text: label.length > 8 ? `${label.slice(0, 5)}...` : label,

View File

@ -47,7 +47,6 @@ import {
loadScene, loadScene,
loadFromBlob, loadFromBlob,
SOCKET_SERVER, SOCKET_SERVER,
SocketUpdateDataSource,
exportCanvas, exportCanvas,
} from "../data"; } from "../data";
import Portal from "./Portal"; import Portal from "./Portal";
@ -505,7 +504,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
return false; return false;
} }
const roomID = roomMatch[1]; const roomId = roomMatch[1];
let collabForceLoadFlag; let collabForceLoadFlag;
try { try {
@ -524,7 +523,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
); );
// if loading same room as the one previously unloaded within 15sec // if loading same room as the one previously unloaded within 15sec
// force reload without prompting // force reload without prompting
if (previousRoom === roomID && Date.now() - timestamp < 15000) { if (previousRoom === roomId && Date.now() - timestamp < 15000) {
return true; return true;
} }
} catch {} } catch {}
@ -828,13 +827,13 @@ class App extends React.Component<ExcalidrawProps, AppState> {
} }
private beforeUnload = withBatchedUpdates((event: BeforeUnloadEvent) => { private beforeUnload = withBatchedUpdates((event: BeforeUnloadEvent) => {
if (this.state.isCollaborating && this.portal.roomID) { if (this.state.isCollaborating && this.portal.roomId) {
try { try {
localStorage?.setItem( localStorage?.setItem(
LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG, LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG,
JSON.stringify({ JSON.stringify({
timestamp: Date.now(), timestamp: Date.now(),
room: this.portal.roomID, room: this.portal.roomId,
}), }),
); );
} catch {} } catch {}
@ -962,7 +961,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
zoom: this.state.zoom, zoom: this.state.zoom,
remotePointerViewportCoords: pointerViewportCoords, remotePointerViewportCoords: pointerViewportCoords,
remotePointerButton: cursorButton, remotePointerButton: cursorButton,
remoteSelectedElementIds: remoteSelectedElementIds, remoteSelectedElementIds,
remotePointerUsernames: pointerUsernames, remotePointerUsernames: pointerUsernames,
shouldCacheIgnoreZoom: this.state.shouldCacheIgnoreZoom, shouldCacheIgnoreZoom: this.state.shouldCacheIgnoreZoom,
}, },
@ -979,7 +978,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
? false ? false
: !atLeastOneVisibleElement && elements.length > 0; : !atLeastOneVisibleElement && elements.length > 0;
if (this.state.scrolledOutside !== scrolledOutside) { if (this.state.scrolledOutside !== scrolledOutside) {
this.setState({ scrolledOutside: scrolledOutside }); this.setState({ scrolledOutside });
} }
if ( if (
@ -1205,8 +1204,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
); );
const element = newTextElement({ const element = newTextElement({
x: x, x,
y: y, y,
strokeColor: this.state.currentItemStrokeColor, strokeColor: this.state.currentItemStrokeColor,
backgroundColor: this.state.currentItemBackgroundColor, backgroundColor: this.state.currentItemBackgroundColor,
fillStyle: this.state.currentItemFillStyle, fillStyle: this.state.currentItemFillStyle,
@ -1215,7 +1214,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
roughness: this.state.currentItemRoughness, roughness: this.state.currentItemRoughness,
opacity: this.state.currentItemOpacity, opacity: this.state.currentItemOpacity,
strokeSharpness: this.state.currentItemStrokeSharpness, strokeSharpness: this.state.currentItemStrokeSharpness,
text: text, text,
fontSize: this.state.currentItemFontSize, fontSize: this.state.currentItemFontSize,
fontFamily: this.state.currentItemFontFamily, fontFamily: this.state.currentItemFontFamily,
textAlign: this.state.currentItemTextAlign, textAlign: this.state.currentItemTextAlign,
@ -1376,7 +1375,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
const roomMatch = getCollaborationLinkData(window.location.href); const roomMatch = getCollaborationLinkData(window.location.href);
if (roomMatch) { if (roomMatch) {
const roomID = roomMatch[1]; const roomId = roomMatch[1];
const roomKey = roomMatch[2]; const roomKey = roomMatch[2];
// fallback in case you're not alone in the room but still don't receive // fallback in case you're not alone in the room but still don't receive
@ -1386,11 +1385,9 @@ class App extends React.Component<ExcalidrawProps, AppState> {
INITIAL_SCENE_UPDATE_TIMEOUT, INITIAL_SCENE_UPDATE_TIMEOUT,
); );
const { default: socketIOClient }: any = await import( const { default: socketIOClient }: any = await import("socket.io-client");
/* webpackChunkName: "socketIoClient" */ "socket.io-client"
);
this.portal.open(socketIOClient(SOCKET_SERVER), roomID, roomKey); this.portal.open(socketIOClient(SOCKET_SERVER), roomId, roomKey);
// All socket listeners are moving to Portal // All socket listeners are moving to Portal
this.portal.socket!.on( this.portal.socket!.on(
@ -1420,17 +1417,12 @@ class App extends React.Component<ExcalidrawProps, AppState> {
break; break;
case "MOUSE_LOCATION": { case "MOUSE_LOCATION": {
const { const {
socketId,
pointer, pointer,
button, button,
username, username,
selectedElementIds, selectedElementIds,
} = decryptedData.payload; } = decryptedData.payload;
const socketId: SocketUpdateDataSource["MOUSE_LOCATION"]["payload"]["socketId"] =
decryptedData.payload.socketId ||
// @ts-ignore legacy, see #2094 (#2097)
decryptedData.payload.socketID;
// NOTE purposefully mutating collaborators map in case of // NOTE purposefully mutating collaborators map in case of
// pointer updates so as not to trigger LayerUI rerender // pointer updates so as not to trigger LayerUI rerender
this.setState((state) => { this.setState((state) => {
@ -1463,7 +1455,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
}); });
try { try {
const elements = await loadFromFirebase(roomID, roomKey); const elements = await loadFromFirebase(roomId, roomKey);
if (elements) { if (elements) {
this.handleRemoteSceneUpdate(elements, { initFromSnapshot: true }); this.handleRemoteSceneUpdate(elements, { initFromSnapshot: true });
} }

View File

@ -49,7 +49,7 @@ export const Popover = ({
}, [onCloseRequest]); }, [onCloseRequest]);
return ( return (
<div className="popover" style={{ top: top, left: left }} ref={popoverRef}> <div className="popover" style={{ top, left }} ref={popoverRef}>
{children} {children}
</div> </div>
); );

View File

@ -14,7 +14,7 @@ class Portal {
app: App; app: App;
socket: SocketIOClient.Socket | null = null; socket: SocketIOClient.Socket | null = null;
socketInitialized: boolean = false; // we don't want the socket to emit any updates until it is fully initialized socketInitialized: boolean = false; // we don't want the socket to emit any updates until it is fully initialized
roomID: string | null = null; roomId: string | null = null;
roomKey: string | null = null; roomKey: string | null = null;
broadcastedElementVersions: Map<string, number> = new Map(); broadcastedElementVersions: Map<string, number> = new Map();
@ -24,13 +24,13 @@ class Portal {
open(socket: SocketIOClient.Socket, id: string, key: string) { open(socket: SocketIOClient.Socket, id: string, key: string) {
this.socket = socket; this.socket = socket;
this.roomID = id; this.roomId = id;
this.roomKey = key; this.roomKey = key;
// Initialize socket listeners (moving from App) // Initialize socket listeners (moving from App)
this.socket.on("init-room", () => { this.socket.on("init-room", () => {
if (this.socket) { if (this.socket) {
this.socket.emit("join-room", this.roomID); this.socket.emit("join-room", this.roomId);
} }
}); });
this.socket.on("new-user", async (_socketId: string) => { this.socket.on("new-user", async (_socketId: string) => {
@ -47,7 +47,7 @@ class Portal {
} }
this.socket.close(); this.socket.close();
this.socket = null; this.socket = null;
this.roomID = null; this.roomId = null;
this.roomKey = null; this.roomKey = null;
this.socketInitialized = false; this.socketInitialized = false;
this.broadcastedElementVersions = new Map(); this.broadcastedElementVersions = new Map();
@ -57,7 +57,7 @@ class Portal {
return !!( return !!(
this.socketInitialized && this.socketInitialized &&
this.socket && this.socket &&
this.roomID && this.roomId &&
this.roomKey this.roomKey
); );
} }
@ -72,7 +72,7 @@ class Portal {
const encrypted = await encryptAESGEM(encoded, this.roomKey!); const encrypted = await encryptAESGEM(encoded, this.roomKey!);
this.socket!.emit( this.socket!.emit(
volatile ? BROADCAST.SERVER_VOLATILE : BROADCAST.SERVER, volatile ? BROADCAST.SERVER_VOLATILE : BROADCAST.SERVER,
this.roomID, this.roomId,
encrypted.data, encrypted.data,
encrypted.iv, encrypted.iv,
); );

View File

@ -83,7 +83,7 @@ export const isSavedToFirebase = (
portal: Portal, portal: Portal,
elements: readonly ExcalidrawElement[], elements: readonly ExcalidrawElement[],
): boolean => { ): boolean => {
if (portal.socket && portal.roomID && portal.roomKey) { if (portal.socket && portal.roomId && portal.roomKey) {
const sceneVersion = getSceneVersion(elements); const sceneVersion = getSceneVersion(elements);
return firebaseSceneVersionCache.get(portal.socket) === sceneVersion; return firebaseSceneVersionCache.get(portal.socket) === sceneVersion;
} }
@ -96,11 +96,11 @@ export const saveToFirebase = async (
portal: Portal, portal: Portal,
elements: readonly ExcalidrawElement[], elements: readonly ExcalidrawElement[],
) => { ) => {
const { roomID, roomKey, socket } = portal; const { roomId, roomKey, socket } = portal;
if ( if (
// if no room exists, consider the room saved because there's nothing we can // if no room exists, consider the room saved because there's nothing we can
// do at this point // do at this point
!roomID || !roomId ||
!roomKey || !roomKey ||
!socket || !socket ||
isSavedToFirebase(portal, elements) isSavedToFirebase(portal, elements)
@ -121,7 +121,7 @@ export const saveToFirebase = async (
} as FirebaseStoredScene; } as FirebaseStoredScene;
const db = firebase.firestore(); const db = firebase.firestore();
const docRef = db.collection("scenes").doc(roomID); const docRef = db.collection("scenes").doc(roomId);
const didUpdate = await db.runTransaction(async (transaction) => { const didUpdate = await db.runTransaction(async (transaction) => {
const doc = await transaction.get(docRef); const doc = await transaction.get(docRef);
if (!doc.exists) { if (!doc.exists) {
@ -146,13 +146,13 @@ export const saveToFirebase = async (
}; };
export const loadFromFirebase = async ( export const loadFromFirebase = async (
roomID: string, roomId: string,
roomKey: string, roomKey: string,
): Promise<readonly ExcalidrawElement[] | null> => { ): Promise<readonly ExcalidrawElement[] | null> => {
const firebase = await getFirebase(); const firebase = await getFirebase();
const db = firebase.firestore(); const db = firebase.firestore();
const docRef = db.collection("scenes").doc(roomID); const docRef = db.collection("scenes").doc(roomId);
const doc = await docRef.get(); const doc = await docRef.get();
if (!doc.exists) { if (!doc.exists) {
return null; return null;

View File

@ -153,7 +153,7 @@ export const decryptAESGEM = async (
const decrypted = await window.crypto.subtle.decrypt( const decrypted = await window.crypto.subtle.decrypt(
{ {
name: "AES-GCM", name: "AES-GCM",
iv: iv, iv,
}, },
importedKey, importedKey,
data, data,
@ -195,7 +195,7 @@ export const exportToBackend = async (
const encrypted = await window.crypto.subtle.encrypt( const encrypted = await window.crypto.subtle.encrypt(
{ {
name: "AES-GCM", name: "AES-GCM",
iv: iv, iv,
}, },
key, key,
encoded, encoded,
@ -248,7 +248,7 @@ const importFromBackend = async (
const decrypted = await window.crypto.subtle.decrypt( const decrypted = await window.crypto.subtle.decrypt(
{ {
name: "AES-GCM", name: "AES-GCM",
iv: iv, iv,
}, },
key, key,
buffer, buffer,

View File

@ -44,24 +44,24 @@ export const distributeElements = (
// rather than from gaps. Buckle up, this is a weird one. // rather than from gaps. Buckle up, this is a weird one.
// Get indices of boxes that define start and end of our bounding box // Get indices of boxes that define start and end of our bounding box
const i0 = groups.findIndex((g) => g[1][start] === bounds[start]); const index0 = groups.findIndex((g) => g[1][start] === bounds[start]);
const i1 = groups.findIndex((g) => g[1][end] === bounds[end]); const index1 = groups.findIndex((g) => g[1][end] === bounds[end]);
// Get our step, based on the distance between the center points of our // Get our step, based on the distance between the center points of our
// start and end boxes // start and end boxes
const step = const step =
(groups[i1][1][mid] - groups[i0][1][mid]) / (groups.length - 1); (groups[index1][1][mid] - groups[index0][1][mid]) / (groups.length - 1);
let pos = groups[i0][1][mid]; let pos = groups[index0][1][mid];
return groups.flatMap(([group, box], i) => { return groups.flatMap(([group, box], index) => {
const translation = { const translation = {
x: 0, x: 0,
y: 0, y: 0,
}; };
// Don't move our start and end boxes // Don't move our start and end boxes
if (i !== i0 && i !== i1) { if (index !== index0 && index !== index1) {
pos += step; pos += step;
translation[distribution.axis] = pos - box[mid]; translation[distribution.axis] = pos - box[mid];
} }

View File

@ -91,8 +91,8 @@ export const dragNewElement = (
mutateElement(draggingElement, { mutateElement(draggingElement, {
x: newX, x: newX,
y: newY, y: newY,
width: width, width,
height: height, height,
}); });
} }
}; };

View File

@ -44,10 +44,10 @@ export const mutateElement = <TElement extends Mutable<ExcalidrawElement>>(
const nextPoints = value; const nextPoints = value;
if (prevPoints.length === nextPoints.length) { if (prevPoints.length === nextPoints.length) {
let didChangePoints = false; let didChangePoints = false;
let i = prevPoints.length; let index = prevPoints.length;
while (--i) { while (--index) {
const prevPoint: Point = prevPoints[i]; const prevPoint: Point = prevPoints[index];
const nextPoint: Point = nextPoints[i]; const nextPoint: Point = nextPoints[index];
if ( if (
prevPoint[0] !== nextPoint[0] || prevPoint[0] !== nextPoint[0] ||
prevPoint[1] !== nextPoint[1] prevPoint[1] !== nextPoint[1]

View File

@ -74,7 +74,7 @@ export const textWysiwyg = ({
angle, angle,
appState, appState,
), ),
textAlign: textAlign, textAlign,
color: updatedElement.strokeColor, color: updatedElement.strokeColor,
opacity: updatedElement.opacity / 100, opacity: updatedElement.opacity / 100,
filter: "var(--appearance-filter)", filter: "var(--appearance-filter)",

View File

@ -127,8 +127,8 @@ export const getNewGroupIdsForDuplication = (
: -1; : -1;
const endIndex = const endIndex =
positionOfEditingGroupId > -1 ? positionOfEditingGroupId : groupIds.length; positionOfEditingGroupId > -1 ? positionOfEditingGroupId : groupIds.length;
for (let i = 0; i < endIndex; i++) { for (let index = 0; index < endIndex; index++) {
copy[i] = mapper(copy[i]); copy[index] = mapper(copy[index]);
} }
return copy; return copy;

View File

@ -89,8 +89,8 @@ export const setLanguageFirstTime = async () => {
export const getLanguage = () => currentLanguage; export const getLanguage = () => currentLanguage;
const findPartsForData = (data: any, parts: string[]) => { const findPartsForData = (data: any, parts: string[]) => {
for (var i = 0; i < parts.length; ++i) { for (let index = 0; index < parts.length; ++index) {
const part = parts[i]; const part = parts[index];
if (data[part] === undefined) { if (data[part] === undefined) {
return undefined; return undefined;
} }
@ -112,7 +112,7 @@ export const t = (path: string, replacement?: { [key: string]: string }) => {
} }
if (replacement) { if (replacement) {
for (var key in replacement) { for (const key in replacement) {
translation = translation.replace(`{{${key}}}`, replacement[key]); translation = translation.replace(`{{${key}}}`, replacement[key]);
} }
} }

View File

@ -147,11 +147,11 @@ const drawElementOnCanvas = (
: element.textAlign === "right" : element.textAlign === "right"
? element.width ? element.width
: 0; : 0;
for (let i = 0; i < lines.length; i++) { for (let index = 0; index < lines.length; index++) {
context.fillText( context.fillText(
lines[i], lines[index],
horizontalOffset, horizontalOffset,
(i + 1) * lineHeight - verticalOffset, (index + 1) * lineHeight - verticalOffset,
); );
} }
context.fillStyle = fillStyle; context.fillStyle = fillStyle;

View File

@ -620,13 +620,13 @@ const renderSelectionBorder = (
context.translate(sceneState.scrollX, sceneState.scrollY); context.translate(sceneState.scrollX, sceneState.scrollY);
const count = selectionColors.length; const count = selectionColors.length;
for (var i = 0; i < count; ++i) { for (let index = 0; index < count; ++index) {
context.strokeStyle = selectionColors[i]; context.strokeStyle = selectionColors[index];
context.setLineDash([ context.setLineDash([
dashWidth, dashWidth,
spaceWidth + (dashWidth + spaceWidth) * (count - 1), spaceWidth + (dashWidth + spaceWidth) * (count - 1),
]); ]);
context.lineDashOffset = (dashWidth + spaceWidth) * i; context.lineDashOffset = (dashWidth + spaceWidth) * index;
strokeRectWithRotation( strokeRectWithRotation(
context, context,
elementX1 - dashedLinePadding, elementX1 - dashedLinePadding,

View File

@ -36,8 +36,8 @@ export const getElementAtPosition = (
// We need to to hit testing from front (end of the array) to back (beginning of the array) // We need to to hit testing from front (end of the array) to back (beginning of the array)
// because array is ordered from lower z-index to highest and we want element z-index // because array is ordered from lower z-index to highest and we want element z-index
// with higher z-index // with higher z-index
for (let i = elements.length - 1; i >= 0; --i) { for (let index = elements.length - 1; index >= 0; --index) {
const element = elements[i]; const element = elements[index];
if (element.isDeleted) { if (element.isDeleted) {
continue; continue;
} }
@ -68,13 +68,13 @@ export const getElementContainingPosition = (
) => { ) => {
let hitElement = null; let hitElement = null;
// We need to to hit testing from front (end of the array) to back (beginning of the array) // We need to to hit testing from front (end of the array) to back (beginning of the array)
for (let i = elements.length - 1; i >= 0; --i) { for (let index = elements.length - 1; index >= 0; --index) {
if (elements[i].isDeleted) { if (elements[index].isDeleted) {
continue; continue;
} }
const [x1, y1, x2, y2] = getElementAbsoluteCoords(elements[i]); const [x1, y1, x2, y2] = getElementAbsoluteCoords(elements[index]);
if (x1 < x && x < x2 && y1 < y && y < y2) { if (x1 < x && x < x2 && y1 < y && y < y2) {
hitElement = elements[i]; hitElement = elements[index];
break; break;
} }
} }

View File

@ -16,4 +16,4 @@ export {
hasText, hasText,
getElementsAtPosition, getElementsAtPosition,
} from "./comparisons"; } from "./comparisons";
export { normalizeZoomValue as getNormalizedZoom, getNewZoom } from "./zoom"; export { getNormalizedZoom, getNewZoom } from "./zoom";

View File

@ -20,7 +20,7 @@ export const getNewZoom = (
}; };
}; };
export const normalizeZoomValue = (zoom: number): NormalizedZoomValue => { export const getNormalizedZoom = (zoom: number): NormalizedZoomValue => {
const normalizedZoom = parseFloat(zoom.toFixed(2)); const normalizedZoom = parseFloat(zoom.toFixed(2));
const clampedZoom = Math.max(0.1, Math.min(normalizedZoom, 2)); const clampedZoom = Math.max(0.1, Math.min(normalizedZoom, 2));
return clampedZoom as NormalizedZoomValue; return clampedZoom as NormalizedZoomValue;