Skip to content

Commit

Permalink
fix(sticky): abnormal height calculation problem
Browse files Browse the repository at this point in the history
  • Loading branch information
betavs committed Nov 23, 2024
1 parent a53836f commit 1cde5fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/sticky/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Sticky Props', () => {
const $sticky = comp.querySelector('.demo >>> #base-sticky');

simulate.scroll($demo, 500, 4);
await simulate.sleep(20);
await simulate.sleep(320);
expect($sticky.instance.data.contentStyle).toBe('position:fixed;top:0px;left:0;right:0;');
});

Expand Down
4 changes: 3 additions & 1 deletion src/sticky/sticky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default class Sticky extends SuperComponent {
};

ready() {
this.onScroll();
setTimeout(() => {
this.onScroll();
}, 300);
}

methods = {
Expand Down
7 changes: 5 additions & 2 deletions src/sticky/sticky.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

<view
class="{{classPrefix}} class {{prefix}}-class"
style="{{_._style(['z-index:' + zIndex, containerStyle, style, customStyle])}};"
style="{{_._style(['z-index:' + zIndex, containerStyle, style, customStyle])}}"
>
<view class="{{classPrefix}}__content {{prefix}}-class-content" style="z-index:{{ zIndex }};{{ contentStyle }};">
<view
class="{{classPrefix}}__content {{prefix}}-class-content"
style="{{_._style(['z-index:' + zIndex, contentStyle]) }}"
>
<slot />
</view>
</view>

0 comments on commit 1cde5fc

Please sign in to comment.