-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rework set video percentage to run racked scroll and play video…
… frames in parallel (#107)
- Loading branch information
1 parent
00af278
commit 9bc3478
Showing
6 changed files
with
132 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export function debounce(func, delay = 0) { | ||
let timeoutId; | ||
|
||
return function (...args) { | ||
const context = this; | ||
|
||
// Clear the previous timeout if it exists | ||
clearTimeout(timeoutId); | ||
|
||
// Set a new timeout to call the function later | ||
timeoutId = setTimeout(() => { | ||
func.apply(context, args); | ||
}, delay); | ||
}; | ||
} | ||
|
||
export const isScrollPositionAtTarget = ( | ||
targetScrollPosition, | ||
threshold = 1, | ||
) => { | ||
// eslint-disable-next-line no-undef | ||
const currentScrollPosition = window.pageYOffset; | ||
const difference = Math.abs(currentScrollPosition - targetScrollPosition); | ||
|
||
return difference < threshold; | ||
}; |