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,CAAC,aAAT,CAAuB,KAAK,YAA5B,CAAd;;AAEA,UAAI,CAAC,KAAK,MAAV,EAAkB;AAChB,QAAA,WAAW,CAAC,4CAA4C,KAAK,YAAY,EAA9D,EAAkE,IAAlE,CAAX;AACD;AACF;AACF,GAzDuB;;AA2DxB,EAAA,OAAO,EAAE;AACP,IAAA,QAAQ,GAAA;AACN,UAAI,CAAC,KAAK,SAAV,EAAqB;AAErB,WAAK,cAAL,GAAsB,KAAK,aAA3B;AACA,WAAK,aAAL,GAAqB,KAAK,MAAL,GACjB,KAAK,MAAL,CAAY,SADK,GAEjB,MAAM,CAAC,WAFX;AAIA,WAAK,aAAL,GAAqB,KAAK,aAAL,GAAqB,KAAK,cAA/C;AACA,WAAK,gBAAL,GAAwB,IAAI,CAAC,GAAL,CAAS,KAAK,aAAL,GAAqB,KAAK,uBAAnC,CAAxB;AAEA,WAAK,SAAL,CAAe,MAAK;AAClB,YACE,IAAI,CAAC,GAAL,CAAS,KAAK,aAAL,GAAqB,KAAK,WAAnC,IACA,KAAK,uBAFP,EAGE,KAAK,YAAL;AACH,OALD;AAMD,KAlBM;;AAmBP;;;;;AAKA,IAAA,YAAY,GAAA,CAAkB;;AAxBvB;AA3De,CAAX,CAAf","sourcesContent":["// Directives\nimport { Scroll } from '../../directives'\n\n// Utilities\nimport { consoleWarn } from '../../util/console'\n\n// Types\nimport Vue from 'vue'\n\n/**\n * Scrollable\n *\n * Used for monitoring scrolling and\n * invoking functions based upon\n * scrolling thresholds being\n * met.\n */\n/* @vue/component */\nexport default Vue.extend({\n name: 'scrollable',\n\n directives: { Scroll },\n\n props: {\n scrollTarget: String,\n scrollThreshold: [String, Number],\n },\n\n data: () => ({\n currentScroll: 0,\n currentThreshold: 0,\n isActive: false,\n isScrollingUp: false,\n previousScroll: 0,\n savedScroll: 0,\n target: null as Element | null,\n }),\n\n computed: {\n /**\n * A computed property that returns\n * whether scrolling features are\n * enabled or disabled\n */\n canScroll (): boolean {\n return typeof window !== 'undefined'\n },\n /**\n * The threshold that must be met before\n * thresholdMet function is invoked\n */\n computedScrollThreshold (): number {\n return this.scrollThreshold\n ? Number(this.scrollThreshold)\n : 300\n },\n },\n\n watch: {\n isScrollingUp () {\n this.savedScroll = this.savedScroll || this.currentScroll\n },\n isActive () {\n this.savedScroll = 0\n },\n },\n\n mounted () {\n if (this.scrollTarget) {\n this.target = document.querySelector(this.scrollTarget)\n\n if (!this.target) {\n consoleWarn(`Unable to locate element with identifier ${this.scrollTarget}`, this)\n }\n }\n },\n\n methods: {\n onScroll () {\n if (!this.canScroll) return\n\n this.previousScroll = this.currentScroll\n this.currentScroll = this.target\n ? this.target.scrollTop\n : window.pageYOffset\n\n this.isScrollingUp = this.currentScroll < this.previousScroll\n this.currentThreshold = Math.abs(this.currentScroll - this.computedScrollThreshold)\n\n this.$nextTick(() => {\n if (\n Math.abs(this.currentScroll - this.savedScroll) >\n this.computedScrollThreshold\n ) this.thresholdMet()\n })\n },\n /**\n * The method invoked when\n * scrolling in any direction\n * has exceeded the threshold\n */\n thresholdMet () { /* noop */ },\n },\n})\n"],"sourc
|