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AAe,WAAf,EAAkC;AACpF,gBAAM,cAAc,cAAc,SAAlC;AACA,gBAAM,WAAW,KAAK,GAAL,CAAS,SAAS,QAAT,GAAoB,KAAK,GAAL,CAAS,cAAc,SAAS,QAAhC,EAA0C,CAA1C,CAApB,GAAmE,CAA5E,CAAjB;AAEA,sBAAU,SAAV,GAAsB,KAAK,KAAL,CAAW,gBAAgB,CAAC,iBAAiB,aAAlB,IAAmC,KAAK,QAAL,CAA9D,CAAtB;AAEA,gBAAI,aAAa,CAAb,IAAkB,UAAU,YAAV,GAAyB,UAAU,SAAnC,KAAiD,UAAU,YAAjF,EAA+F;AAC7F,uBAAO,QAAQ,cAAR,CAAP;AACD;AAED,kCAAsB,IAAtB;AACD,SAX6B,CAAX;AAAA,KAAZ,CAAP;AAYD","sourcesContent":["import * as easingPatterns from './easing-patterns'\nimport {\n getContainer,\n getOffset\n} from './util'\nimport Vue from 'vue'\n\ntype GoToTarget = number | string | HTMLElement | Vue\ninterface GoToSettings {\n container: string | HTMLElement | Vue\n duration: number\n offset: number\n easing: string | easingPatterns.EasingFunction\n appOffset: boolean\n}\n\nexport default function goTo (_target: GoToTarget, _settings: Partial<GoToSettings> = {}): Promise<number> {\n const settings: GoToSettings = {\n container: (document.scrollingElement as HTMLElement | null) || document.body || document.documentElement,\n duration: 500,\n offset: 0,\n easing: 'easeInOutCubic',\n appOffset: true,\n ..._settings\n }\n const container = getContainer(settings.container)\n\n if (settings.appOffset) {\n const isDrawer = container.classList.contains('v-navigation-drawer')\n const isClipped = container.classList.contains('v-navigation-drawer--clipped')\n\n settings.offset += Vue.prototype.$vuetify.application.bar\n if (!isDrawer || isClipped) settings.offset += Vue.prototype.$vuetify.application.top\n }\n\n const startTime = performance.now()\n const targetLocation = getOffset(_target) - settings.offset\n const startLocation = container.scrollTop\n if (targetLocation === startLocation) return Promise.resolve(targetLocation)\n\n const ease = typeof settings.easing === 'function'\n ? settings.easing\n : (easingPatterns as Dictionary<easingPatterns.EasingFunction>)[settings.easing]\n if (!ease) throw new TypeError(`Easing function \"${settings.easing}\" not found.`)\n\n // tslint:disable-next-line:promise-must-complete\n return new Promise(resolve => requestAnimationFrame(function step (currentTime: number) {\n const timeElapsed = currentTime - startTime\n const progress = Math.abs(settings.duration ? Math.min(timeElapsed / settings.duration, 1) : 1)\n\n container.scrollTop = Math.floor(startLocation + (targetLocation - startLocation) * ease(progress))\n\n if (progress === 1 || container.clientHeight + container.scrollTop === container.scrollHeight) {\n return resolve(targetLocation)\n }\n\n requestAnimationFrame(step)\n }))\n}\n"],"sourceRoot":""}
|