MCPcopy
hub / github.com/youzan/vant-weapp / attached

Function attached

packages/mixins/page-scroll.ts:25–46  ·  view source on GitHub ↗
(this: WechatMiniprogram.Component.TrivialInstance)

Source from the content-addressed store, hash-verified

23export function pageScrollMixin(scroller: Scroller) {
24 return Behavior({
25 attached(this: WechatMiniprogram.Component.TrivialInstance) {
26 const page = getCurrentPage<{ vanPageScroller: Scroller[] }>();
27
28 if (!isDef(page)) {
29 return;
30 }
31
32 const _scroller = scroller.bind(this);
33
34 const { vanPageScroller = [] } = page;
35
36 if (isFunction(page.onPageScroll) && page.onPageScroll !== onPageScroll) {
37 vanPageScroller.push(page.onPageScroll.bind(page));
38 }
39
40 vanPageScroller.push(_scroller);
41
42 page.vanPageScroller = vanPageScroller;
43 page.onPageScroll = onPageScroll;
44
45 this._scroller = _scroller;
46 },
47
48 detached(this: WechatMiniprogram.Component.TrivialInstance) {
49 const page = getCurrentPage<{ vanPageScroller: Scroller[] }>();

Callers

nothing calls this directly

Calls 3

getCurrentPageFunction · 0.90
isFunctionFunction · 0.90
isDefFunction · 0.50

Tested by

no test coverage detected