Vulture/VApp/node_modules/vuetify/lib/composables/goto.mjs.map

1 line
12 KiB
Plaintext
Raw Normal View History

{"version":3,"file":"goto.mjs","names":["inject","mergeDeep","refElement","GoToSymbol","Symbol","for","genDefaults","container","undefined","duration","layout","offset","easing","patterns","linear","t","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","getContainer","el","getTarget","document","scrollingElement","body","querySelector","getOffset","target","horizontal","rtl","totalOffset","offsetLeft","offsetTop","offsetParent","createGoTo","options","locale","isRtl","scrollTo","_target","_options","goTo","value","HTMLElement","parentElement","ease","TypeError","targetLocation","styles","window","getComputedStyle","layoutOffset","getPropertyValue","parseInt","startLocation","scrollLeft","scrollTop","Promise","resolve","startTime","performance","now","requestAnimationFrame","step","currentTime","timeElapsed","progress","Math","abs","min","location","floor","clientSize","reachEnd","documentElement","clientHeight","scrollHeight","clientWidth","scrollWidth","useGoTo","arguments","length","Error","go"],"sources":["../../src/composables/goto.ts"],"sourcesContent":["// Utilities\nimport { inject } from 'vue'\nimport { mergeDeep, refElement } from '@/util'\n\n// Types\nimport type { ComponentPublicInstance, InjectionKey, Ref } from 'vue'\nimport type { LocaleInstance, RtlInstance } from './locale'\n\nexport interface GoToInstance {\n rtl: Ref<boolean>\n options: GoToOptions\n}\n\nexport interface GoToOptions {\n container: ComponentPublicInstance | HTMLElement | string\n duration: number\n layout: boolean\n offset: number\n easing: string | ((t: number) => number)\n patterns: Record<string, (t: number) => number>\n}\n\nexport const GoToSymbol: InjectionKey<GoToInstance> = Symbol.for('vuetify:goto')\n\nfunction genDefaults () {\n return {\n container: undefined,\n duration: 300,\n layout: false,\n offset: 0,\n easing: 'easeInOutCubic',\n patterns: {\n linear: (t: number) => t,\n easeInQuad: (t: number) => t ** 2,\n easeOutQuad: (t: number) => t * (2 - t),\n easeInOutQuad: (t: number) => (t < 0.5 ? 2 * t ** 2 : -1 + (4 - 2 * t) * t),\n easeInCubic: (t: number) => t ** 3,\n easeOutCubic: (t: number) => --t ** 3 + 1,\n easeInOutCubic: (t: number) => t < 0.5 ? 4 * t ** 3 : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1,\n easeInQuart: (t: number) => t ** 4,\n easeOutQuart: (t: number) => 1 - --t ** 4,\n easeInOutQuart: (t: number) => (t < 0.5 ? 8 * t ** 4 : 1 - 8 * --t ** 4),\n easeInQuint: (t: number) => t ** 5,\n easeOutQuint: (t: number) => 1 + --t ** 5,\n easeInOutQuint: (t: number) => t < 0.5 ? 16 * t ** 5 : 1 + 16 * --t ** 5,\n },\n }\n}\n\nfunction getContainer (el?: ComponentPublicInstance | HTMLElement | string) {\n return getTarget(el) ?? (document.scrollingElement || document.body) as HTMLElement\n}\n\nfunction getTarget (el: ComponentPublicInstance | HTMLElement | string | undefined) {\n return (typeof el === 'string') ? document.querySelector<HTMLElement>(el) : refElement(el)\n}\n\nfunction getOffset (target: any, horizontal?: boolean, rtl?: boolean): number {\n if (typeof target === 'number') return horizontal && rtl ? -target : target\n\n let el = getTarget(target)\n let totalOffset = 0\n while (el) {\n totalOffset += horizontal ? el.offsetLeft : el.offsetTop\n el = el.offsetParent as HTMLElement\n }\n\n return totalOffset\n}\n\nexport function createGoTo (options: Partial<GoToOptions> | undefined, locale: LocaleInstance & RtlInstance) {\n return {\n rtl: locale.isRtl,\n options: mergeDeep(genDefaults(), options),\n }\n}\n\nasync function scrollTo (\n _target: ComponentPublicInstance | HTMLElement | number | string,\n _options: Partial<GoToOptions>,\n horizontal?: boolean,\n goTo?: GoToInstance,\n) {\n const options = mergeDeep(goTo?.options, _options)\n const rtl = goTo?.rtl.value\n const target = (typeof _target === 'number' ? _target : getTarget(_target)) ?? 0\n const co