Skip to content

Commit 5e30492

Browse files
committed
feat(sticky): styleConfig
1 parent 7defc3e commit 5e30492

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

packages/mpx-cube-ui/lib/components/sticky/index.mpx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
2-
<view wx:ref class="cube-sticky" wx:style="{{containerStyle}}">
2+
<view wx:ref class="cube-sticky" wx:style="{{styleConfig.sticky}}">
33
<slot></slot>
4-
<view class="cube-sticky-fixed" wx:style="{{fixedEleStyle}}" wx:ref="fixedEle">
4+
<view class="cube-sticky-fixed" wx:style="{{[fixedEleStyle, styleConfig.fixedEle]}}" wx:ref="fixedEle">
55
</view>
66
</view>
77
</template>

packages/mpx-cube-ui/lib/components/sticky/sticky-ele/sticky-ele.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ createComponent({
3737
// 重置高度为 auto,然后重新计算并设置固定高度
3838
this.eleHeight = 'auto';
3939
const query = this.createSelectorQuery();
40-
// eslint-disable-next-line
41-
// @ts-ignore
40+
// eslint-disable-next-line @typescript-eslint/no-this-alias
4241
const that = this;
4342
query.select('.cube-sticky-ele').boundingClientRect((rect) => {
4443
if (rect && rect.height > 0) {

packages/mpx-cube-ui/lib/components/sticky/sticky.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ createComponent({
2020
offset: {
2121
type: Number,
2222
value: 0
23+
},
24+
styleConfig: {
25+
type: Object,
26+
value: {}
2327
}
2428
},
2529
data: {
@@ -33,9 +37,6 @@ createComponent({
3337
eles: []
3438
},
3539
computed: {
36-
containerStyle() {
37-
return {};
38-
},
3940
fixedEleStyle() {
4041
return {
4142
top: `${this.offset}px`

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
2-
<view wx:ref class="cube-sticky" wx:style="{{containerStyle}}">
2+
<view wx:ref class="cube-sticky" wx:style="{{styleConfig.sticky}}">
33
<slot></slot>
4-
<view class="cube-sticky-fixed" wx:style="{{fixedEleStyle}}" wx:ref="fixedEle">
4+
<view class="cube-sticky-fixed" wx:style="{{[fixedEleStyle, styleConfig.fixedEle]}}" wx:ref="fixedEle">
55
</view>
66
</view>
77
</template>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ createComponent({
3838
// 重置高度为 auto,然后重新计算并设置固定高度
3939
this.eleHeight = 'auto'
4040
const query = this.createSelectorQuery()
41-
// eslint-disable-next-line
42-
// @ts-ignore
41+
// eslint-disable-next-line @typescript-eslint/no-this-alias
4342
const that = this
4443
query.select('.cube-sticky-ele').boundingClientRect((rect: any) => {
4544
if (rect && rect.height > 0) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ createComponent({
3131
offset: {
3232
type: Number,
3333
value: 0
34+
},
35+
styleConfig: {
36+
type: Object,
37+
value: {}
3438
}
3539
},
3640
data: {
@@ -44,9 +48,6 @@ createComponent({
4448
eles: [] as StickyEleInstance[]
4549
},
4650
computed: {
47-
containerStyle() {
48-
return {}
49-
},
5051
fixedEleStyle() {
5152
return {
5253
top: `${this.offset}px`

0 commit comments

Comments
 (0)