Skip to content

Commit

Permalink
update scroll reader
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane authored and sashankaryal committed Oct 30, 2024
1 parent a9f95e5 commit 1f27c30
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/packages/spotlight/src/createScrollReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ export default function createScrollReader(
let timeout: ReturnType<typeof setTimeout>;
let zooming = false;

element.addEventListener("scroll", () => {
const scroll = () => {
scrolling = true;
});
};
element.addEventListener("scroll", scroll);

element.addEventListener("scrollend", () => {
const scrollEnd = () => {
scrolling = false;
requestAnimationFrame(() => render(zooming, true));
});
};

element.addEventListener("scrollend", scrollEnd);

const updateScrollStatus = () => {
const threshold = getScrollSpeedThreshold();
Expand Down Expand Up @@ -68,7 +71,9 @@ export default function createScrollReader(
return {
destroy: () => {
destroyed = true;
element.removeEventListener("scroll", scroll);
element.removeEventListener("scrollend", scrollEnd)
},
zooming: () => zooming
zooming: () => zooming,
};
}

0 comments on commit 1f27c30

Please sign in to comment.