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CAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAI,EAAE,CAAC;IACnF,CAAC;CACF,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,OAAY,EAAE,QAAgB;IAC7D,OAAO,IAAI,OAAO,CAAqD,CAAC,OAAO,EAAE,EAAE;QACjF,EAAE,CAAC,mBAAmB,EAAE;aACrB,EAAE,CAAC,OAAO,CAAC;aACX,MAAM,CAAC,QAAQ,CAAC;aAChB,kBAAkB,EAAE;aACpB,IAAI,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","file":"utils.js","sourcesContent":["const getCurrentPage = function <T>() {\n const pages = getCurrentPages();\n return pages[pages.length - 1] as T & WechatMiniprogram.Page.TrivialInstance;\n};\n\ntype IPageScrollOption = WechatMiniprogram.Page.IPageScrollOption;\ntype Scroller = (\n this: WechatMiniprogram.Component.TrivialInstance,\n event?: IPageScrollOption,\n) => void;\n\nconst onPageScroll = function (event?: IPageScrollOption) {\n const { pageScroller = [] } = getCurrentPage<{\n pageScroller: Scroller[];\n }>();\n\n pageScroller.forEach((scroller: Scroller) => {\n if (typeof scroller === 'function') {\n // @ts-ignore\n scroller(event);\n }\n });\n};\n\nexport const pageScrollMixin = (scroller: Scroller) =>\n Behavior({\n attached() {\n const page = getCurrentPage<{ pageScroller: Scroller[] }>();\n\n if (Array.isArray(page.pageScroller)) {\n page.pageScroller.push(scroller.bind(this));\n } else {\n page.pageScroller =\n typeof page.onPageScroll === 'function'\n ? [page.onPageScroll.bind(page), scroller.bind(this)]\n : [scroller.bind(this)];\n }\n\n page.onPageScroll = onPageScroll;\n },\n\n detached() {\n const page = getCurrentPage<{ pageScroller: Scroller[] }>();\n page.pageScroller = page.pageScroller?.filter((item) => item !== scroller) || [];\n },\n });\n\nexport const getRect = function (context: any, selector: string) {\n return new Promise<WechatMiniprogram.BoundingClientRectCallbackResult>((resolve) => {\n wx.createSelectorQuery()\n .in(context)\n .select(selector)\n .boundingClientRect()\n .exec((rect = []) => resolve(rect[0]));\n });\n};\n"]}