"use strict";const r=require("../common/utils.js"),e=new(require("../common/bus.js").Bus),o=function(e){const o=r.getCurrentPage();if(!o)return;const{pageScroller:l}=o;null==l||l.forEach((r=>{"function"==typeof r&&r(e)}))};exports.pageScrollMixin=(l="onScroll",n=!0)=>({mounted(){if(n)return void e.on("page-scroll",this[l]);const t=r.getCurrentPage();t&&(Array.isArray(t.pageScroller)?t.pageScroller.push(this._bindScroller):t.pageScroller="function"==typeof t.onPageScroll?[t.onPageScroll.bind(t),this._bindScroller]:[this._bindScroller],t.onPageScroll=o)},beforeUnMount(){var o;if(n)return void e.off("page-scroll",this[l]);const t=r.getCurrentPage();t&&(t.pageScroller=(null==(o=t.pageScroller)?void 0:o.filter((r=>r!==this._bindScroller)))||[])},methods:{_bindScroller(r){var e;let o;return o=null==(e=this[l])?void 0:e.call(this,r),o}}});
