1 |
- {"version":3,"sources":["../../src/directives/scroll.ts"],"names":[],"mappings":";;;;;AASA,SAAS,QAAT,CAAmB,EAAnB,EAAoC,OAApC,EAAiE;AAC/D,QAAM,WAAW,QAAQ,KAAzB;AACA,QAAM,UAAU,QAAQ,OAAR,IAAmB,EAAE,SAAS,IAAX,EAAnC;AACA,QAAM,SAAS,QAAQ,GAAR,GAAc,SAAS,aAAT,CAAuB,QAAQ,GAA/B,CAAd,GAAoD,MAAnE;AACA,QAAI,CAAC,MAAL,EAAa;AAEb,WAAO,gBAAP,CAAwB,QAAxB,EAAkC,QAAlC,EAA4C,OAA5C;AAEA,OAAG,SAAH,GAAe;AACb,0BADa;AAEb,wBAFa;AAGb;AAHa,KAAf;AAKD;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAgC;AAC9B,QAAI,CAAC,GAAG,SAAR,EAAmB;AADW,wBAGQ,GAAG,SAHX;AAAA,QAGtB,QAHsB,iBAGtB,QAHsB;AAAA,QAGZ,OAHY,iBAGZ,OAHY;AAAA,QAGH,MAHG,iBAGH,MAHG;;AAK9B,WAAO,mBAAP,CAA2B,QAA3B,EAAqC,QAArC,EAA+C,OAA/C;AACA,WAAO,GAAG,SAAV;AACD;kBAEc;AACb,sBADa;AAEb;AAFa,C","sourcesContent":["import { VNodeDirective } from 'vue/types/vnode'\nimport { DirectiveOptions } from 'vue'\n\ninterface ScrollVNodeDirective extends VNodeDirective {\n arg: string\n value: EventListenerOrEventListenerObject\n options?: boolean | AddEventListenerOptions\n}\n\nfunction inserted (el: HTMLElement, binding: ScrollVNodeDirective) {\n const callback = binding.value\n const options = binding.options || { passive: true }\n const target = binding.arg ? document.querySelector(binding.arg) : window\n if (!target) return\n\n target.addEventListener('scroll', callback, options)\n\n el._onScroll = {\n callback,\n options,\n target\n }\n}\n\nfunction unbind (el: HTMLElement) {\n if (!el._onScroll) return\n\n const { callback, options, target } = el._onScroll\n\n target.removeEventListener('scroll', callback, options)\n delete el._onScroll\n}\n\nexport default {\n inserted,\n unbind\n} as DirectiveOptions\n"],"sourceRoot":""}
|