MCPcopy Create free account
hub / github.com/coderwhy/LearnMiniProgram / onPageScroll

Function onPageScroll

pages/home/home.js:98–119  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

96 },
97
98 onPageScroll(options) {
99 // 1.取出scrollTop
100 const scrollTop = options.scrollTop;
101 // console.log(scrollTop)
102
103 // 2.修改showBackTop属性
104 // 官方: 不要再滚动的函数回调中频繁的调用this.setData
105 const flag1 = scrollTop >= TOP_DISTANCE;
106 if (flag1 != this.data.showBackTop) {
107 this.setData({
108 showBackTop: flag1
109 })
110 }
111
112 // 3.修改isTabFixed属性
113 const flag2 = scrollTop >= this.data.tabScrollTop;
114 if (flag2 != this.data.isTabFixed) {
115 this.setData({
116 isTabFixed: flag2
117 })
118 }
119 }
120})

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected