(stacked notes) smooth scroll to focused note

This commit is contained in:
Julien Calixte
2021-03-14 21:11:06 +01:00
parent 4df7b95d26
commit 23a310f986
5 changed files with 78 additions and 15 deletions

View File

@@ -1,15 +1,14 @@
import { onMounted, ref } from 'vue'
import { ref } from 'vue'
import { useEventListener } from '@vueuse/core'
export const useOverlay = () => {
export const useOverlay = (listen = true) => {
const x = ref(0)
const body = document.querySelector('body')
onMounted(() => {
const element = document.querySelector('body')
if (listen) {
useEventListener(
element,
body,
'scroll',
(e) => {
const target = e.target as HTMLElement
@@ -20,8 +19,16 @@ export const useOverlay = () => {
capture: false
}
)
})
}
const scrollTo = (to: number) => {
body?.scroll({
left: to
})
}
return {
x
x,
scrollTo
}
}