Skip to content

Commit

Permalink
update scroll reader
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Oct 24, 2024
1 parent 5f7b0ec commit 471cccb
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 471cccb

Please sign in to comment.