🐛 (overlay) fix scroll flash

This commit is contained in:
2021-03-16 00:02:37 +01:00
parent acf54f7a86
commit 3abadf2477

View File

@@ -1,12 +1,14 @@
import { computed, ref } from 'vue'
import { useEventListener, useWindowSize } from '@vueuse/core'
import { MOBILE_BREAKPOINT } from '@/constants/mobile' import { MOBILE_BREAKPOINT } from '@/constants/mobile'
import { ref } from 'vue'
import { useEventListener } from '@vueuse/core'
export const useOverlay = (listen = true) => { export const useOverlay = (listen = true) => {
const body = document.querySelector('body') as HTMLBodyElement
const x = ref(0) const x = ref(0)
const y = ref(0) const y = ref(0)
const body = document.querySelector('body') as HTMLBodyElement const { width } = useWindowSize()
const isMobile = ref((body?.clientWidth ?? 0) <= MOBILE_BREAKPOINT) const isMobile = computed(() => width.value <= MOBILE_BREAKPOINT)
if (listen) { if (listen) {
useEventListener( useEventListener(
@@ -25,8 +27,6 @@ export const useOverlay = (listen = true) => {
} }
const scrollToNote = (to: number) => { const scrollToNote = (to: number) => {
console.log('scroll to note', to)
if (isMobile.value) { if (isMobile.value) {
body.scroll({ body.scroll({
top: to top: to