UNPKG

@opensig/opendesign

Version:

29 lines (28 loc) 726 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); function useScrollState(opts = {}) { const { resetDelay = 150 } = opts; const isScrolling = vue.ref(false); let endTimer; const markScrolling = () => { isScrolling.value = true; if (endTimer) { clearTimeout(endTimer); } endTimer = setTimeout(() => { isScrolling.value = false; endTimer = void 0; }, resetDelay); }; const cleanup = () => { if (endTimer) { clearTimeout(endTimer); } }; if (vue.getCurrentInstance()) { vue.onUnmounted(cleanup); } return { isScrolling, markScrolling, cleanup }; } exports.useScrollState = useScrollState;