Skip to content

Commit ee6899f

Browse files
committed
fix(Sticky): 修复吸顶容器动态插入计算错误的问题
close #1554
1 parent 52c6ba9 commit ee6899f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/sticky-item/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import nodeUtil from '../core/utils/node-util';
2+
import pixelUtil from '../core/utils/pixel-util';
3+
24
Component({
35
externalClasses: ['l-class', 'l-header-wrapper-class', 'l-header-class', 'l-header-sticky-class', 'l-body-class'],
46
options: {
@@ -71,7 +73,8 @@ Component({
7173
updateStickyItemPosition(scrollTop) {
7274
const parent = this.getParentComponent();
7375
const {index, stickyItemTop, stickyItemHeight, top} = this.data;
74-
const isFixedTop = scrollTop > stickyItemTop - top && scrollTop < stickyItemHeight + stickyItemTop - top;
76+
const topPx = pixelUtil.rpx2px(top);
77+
const isFixedTop = scrollTop > stickyItemTop - topPx && scrollTop < stickyItemHeight + stickyItemTop - topPx;
7578

7679
// 避免频繁setData
7780
if (this.data.isFixedTop === isFixedTop) {

0 commit comments

Comments
 (0)