Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Skeleton): support delay props #2698

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/skeleton/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('skeleton', () => {
describe('Props', () => {
it(`: style && customStyle`, async () => {
const id = simulate.load({
template: `<t-skeleton class="skeleton" style="{{style}}" customStyle="{{customStyle}}"></t-skeleton>`,
template: `<t-skeleton class="skeleton" style="{{style}}" customStyle="{{customStyle}}" loading="{{true}}"></t-skeleton>`,
usingComponents: {
't-skeleton': skeleton,
},
Expand Down
13 changes: 13 additions & 0 deletions src/skeleton/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ export default class Skeleton extends SuperComponent {
rowCol() {
this.init();
},
'loading,delay'(loading: boolean, delay: number) {
if (!loading || delay === 0) {
this.setData({
isShow: loading,
});
return;
}
setTimeout(() => {
this.setData({
isShow: loading,
});
}, delay);
},
};

lifetimes = {
Expand Down
2 changes: 1 addition & 1 deletion src/skeleton/skeleton.wxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<wxs src="../common/utils.wxs" module="_" />

<view wx:if="{{ loading }}" style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class ">
<view wx:if="{{ isShow }}" style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class ">
<view wx:if="{{ parsedRowcols.length }}" class="{{classPrefix}}__content">
<view
wx:for="{{parsedRowcols}}"
Expand Down
Loading