Skip to content

Commit

Permalink
Don't render if trying to rotate to the same spot
Browse files Browse the repository at this point in the history
  • Loading branch information
simonlc committed Dec 14, 2023
1 parent 9c3e413 commit 61a993d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@reach/dialog": "^0.18.0",
"@types/autosuggest-highlight": "^3.2.3",
"@types/d3": "^7.4.3",
"@types/lodash": "^4.14.202",
"@types/topojson-client": "^3.1.4",
"@uidotdev/usehooks": "^2.4.1",
"autosuggest-highlight": "^3.3.4",
Expand Down
6 changes: 4 additions & 2 deletions src/Globe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
transition,
} from 'd3';
import { land, land110m } from './App';
import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';
import { useEffect, useMemo, useRef } from 'react';
import { rotateProjectionTo } from './transformations';
import * as solar from 'solar-calculator';
import { debounce } from '@mui/material';
Expand Down Expand Up @@ -261,7 +261,7 @@ export function Globe({ size, country, initialRotation, rotation }) {
const draw = debounce(() => {
drawCanvas();
return true;
}, 50);
}, 20);

useEffect(() => {
if (!data.features.length) return;
Expand Down Expand Up @@ -363,6 +363,8 @@ export function Globe({ size, country, initialRotation, rotation }) {
} else {
const duration = 1000;
const currentRotate = projection.rotate();
if (currentRotate[0] === rotation[0] && currentRotate[1] === rotation[1])
return;

path.projection(projection);
const r = interpolate(currentRotate, rotation);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==

"@types/lodash@^4.14.202":
version "4.14.202"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.202.tgz#f09dbd2fb082d507178b2f2a5c7e74bd72ff98f8"
integrity sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==

"@types/parse-json@^4.0.0":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239"
Expand Down

0 comments on commit 61a993d

Please sign in to comment.