From 71d58ed034ed35080ad266ccb38a809b549d3bad Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Mon, 20 Jan 2025 12:41:43 +0530 Subject: [PATCH] Remove scrollToCoordinates. --- .../src/protectedAudience/components/box.js | 8 +--- .../components/progressLine.js | 1 - .../src/protectedAudience/modules/bubbles.js | 2 - .../src/protectedAudience/utils/index.js | 1 - .../utils/scrollToCoordinates.js | 45 ------------------- 5 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 packages/explorable-explanations/src/protectedAudience/utils/scrollToCoordinates.js diff --git a/packages/explorable-explanations/src/protectedAudience/components/box.js b/packages/explorable-explanations/src/protectedAudience/components/box.js index 8b9b49ac3..e475ad352 100644 --- a/packages/explorable-explanations/src/protectedAudience/components/box.js +++ b/packages/explorable-explanations/src/protectedAudience/components/box.js @@ -18,11 +18,7 @@ */ import app from '../app'; import config from '../config'; -import { - addCanvasEventListener, - isInsideBox, - scrollToCoordinates, -} from '../utils'; +import { addCanvasEventListener, isInsideBox } from '../utils'; const INFO_ICON_SIZE = 16; const INFO_ICON_SPACING = 3; @@ -47,8 +43,6 @@ const Box = ({ }, }; - scrollToCoordinates(x, y); - const p = app.p; p.push(); diff --git a/packages/explorable-explanations/src/protectedAudience/components/progressLine.js b/packages/explorable-explanations/src/protectedAudience/components/progressLine.js index dc0880080..b570368f7 100644 --- a/packages/explorable-explanations/src/protectedAudience/components/progressLine.js +++ b/packages/explorable-explanations/src/protectedAudience/components/progressLine.js @@ -198,7 +198,6 @@ const ProgressLine = ({ break; case 'up': - utils.scrollToCoordinates(x1, currentY); currentY -= incrementBy; if (y1 - currentY > height) { diff --git a/packages/explorable-explanations/src/protectedAudience/modules/bubbles.js b/packages/explorable-explanations/src/protectedAudience/modules/bubbles.js index fd5c06f0d..dcba4d6f4 100644 --- a/packages/explorable-explanations/src/protectedAudience/modules/bubbles.js +++ b/packages/explorable-explanations/src/protectedAudience/modules/bubbles.js @@ -151,7 +151,6 @@ bubbles.barrageAnimation = async (index) => { return; } - utils.scrollToCoordinates(0, 0, true); utils.wipeAndRecreateInterestCanvas(); for (let i = 0; i < positionsOfCircles.length; i++) { @@ -279,7 +278,6 @@ bubbles.reverseBarrageAnimation = async (index) => { } document.getElementById('interest-canvas').style.zIndex = 4; - utils.scrollToCoordinates(0, 0, true); await new Promise((resolve) => { const animate = () => { diff --git a/packages/explorable-explanations/src/protectedAudience/utils/index.js b/packages/explorable-explanations/src/protectedAudience/utils/index.js index 1f78b90d5..60a5e96f4 100644 --- a/packages/explorable-explanations/src/protectedAudience/utils/index.js +++ b/packages/explorable-explanations/src/protectedAudience/utils/index.js @@ -24,4 +24,3 @@ export * from './markVisitedValue'; export * from './requestInterval'; export * from './isOverControls'; export * from './isInsideBox'; -export * from './scrollToCoordinates'; diff --git a/packages/explorable-explanations/src/protectedAudience/utils/scrollToCoordinates.js b/packages/explorable-explanations/src/protectedAudience/utils/scrollToCoordinates.js deleted file mode 100644 index d66bc4e03..000000000 --- a/packages/explorable-explanations/src/protectedAudience/utils/scrollToCoordinates.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export const scrollToCoordinates = (x, y, override = false) => { - if (override) { - document.querySelector('#ps-canvas').parentElement.scrollTo({ - left: 0, - top: 0, - behavior: 'smooth', - }); - return; - } - - const rect = document - .querySelector('#ps-canvas') - .parentElement.getBoundingClientRect(); - - let finalX = x - rect.left, - finalY = y - rect.top; - if (finalX < 0) { - finalX = rect.left - x; - } - - if (finalY < 0) { - finalY = rect.top - y; - } - - document.querySelector('#ps-canvas').parentElement.scrollTo({ - left: finalX, - top: finalY, - behavior: 'smooth', - }); -};