Skip to content

Commit 1f9a6a4

Browse files
committed
fix: sticky
1 parent 2a7cfaf commit 1f9a6a4

4 files changed

Lines changed: 121 additions & 197 deletions

File tree

example/pages/sticky/sticky-basic.mpx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
<scroll-view
66
scroll-y="{{ true }}"
77
bindscroll="onScroll"
8-
style="height: 400px;position:relative"
8+
style="height: 100vh;position:relative"
99
>
10-
<cube-sticky-ele eleKey="1">
11-
<view class="sticky-header">吸顶标题 1</view>
12-
</cube-sticky-ele>
1310
<view class="sticky-content">
1411
<view wx:for="{{[1,2,3,4,5]}}" wx:key="*this" class="content-item">内容项 {{item}}</view>
1512
</view>
@@ -33,20 +30,20 @@
3330
</template>
3431

3532
<script>
36-
import { createPage } from '@mpxjs/core'
33+
import { createComponent } from '@mpxjs/core'
3734

38-
createPage({
35+
createComponent({
3936
options: {
40-
styleIsolation: 'shared'
37+
styleIsolation: 'shared',
4138
},
4239
data: {
43-
pos: 0
40+
pos: 0,
4441
},
4542
methods: {
4643
onScroll(e) {
4744
this.pos = e.detail.scrollTop
48-
}
49-
}
45+
},
46+
},
5047
})
5148
</script>
5249

@@ -65,7 +62,7 @@ createPage({
6562
background-color: #f5f5f5
6663

6764
.content-item
68-
height: 40px
65+
height: 120px
6966
line-height: 40px
7067
margin-bottom: 10px
7168
padding: 0 15px
@@ -82,4 +79,4 @@ createPage({
8279
"cube-sticky-ele": "@mpxjs/mpx-cube-ui/src/components/sticky/sticky-ele/index"
8380
}
8481
}
85-
</script>
82+
</script>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"init:dev": "pnpm install --frozen-lockfile && cd example && npm ci --legacy-peer-deps && cd ReactNativeProject && npm ci --legacy-peer-deps && npx install-expo-modules"
3131
},
3232
"devDependencies": {
33+
"react-native-gesture-handler": "^2.23.0",
3334
"@babel/runtime-corejs3": "^7.10.4",
3435
"@babel/core": "^7.10.4",
3536
"@babel/preset-env": "^7.10.4",

packages/mpx-cube-ui/src/components/sticky/sticky.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ createComponent({
102102
} else {
103103
oldEle?.refresh()
104104
oldEle?.setContentStyle({})
105-
newEle.setContentStyle({
105+
newEle?.setContentStyle({
106106
position: 'fixed',
107107
top: this.rootRect.top + this.offset + 'px',
108108
left: this.rootRect.left + 'px',

0 commit comments

Comments
 (0)