use a single call to useContextMenu as recommended in the docs

This commit is contained in:
Athou
2023-06-26 20:04:51 +02:00
parent 95f4cffa7c
commit 3e903fc6bc
5 changed files with 35 additions and 46 deletions

View File

@@ -95,6 +95,7 @@ export const Constants = {
},
dom: {
entryId: (entry: Entry) => `entry-id-${entry.id}`,
entryContextMenuId: (entry: Entry) => entry.id,
},
browserExtensionUrl: "https://github.com/Athou/commafeed-browser-extension",
bitcoinWalletAddress: "1dymfUxqCWpyD7a6rQSqNy4rLVDBsAr5e",

View File

@@ -30,17 +30,16 @@ export const calculatePlaceholderSize = ({ width, height, maxWidth }: { width?:
export const scrollToWithCallback = ({ options, onScrollEnded }: { options: ScrollToOptions; onScrollEnded: () => void }) => {
const offset = (options.top ?? 0).toFixed()
const onScroll = () => {
const onScroll = throttle(100, () => {
if (window.scrollY.toFixed() === offset) {
window.removeEventListener("scroll", throttleListener)
window.removeEventListener("scroll", onScroll)
onScrollEnded()
}
}
const throttleListener = throttle(100, onScroll)
window.addEventListener("scroll", throttleListener)
})
window.addEventListener("scroll", onScroll)
// scrollTo does not trigger if there's nothing to do, trigger it manually
throttleListener()
onScroll()
window.scrollTo(options)
}