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

修复image组件图片懒加载失效 #3036

Merged
merged 5 commits into from
Aug 5, 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
9 changes: 3 additions & 6 deletions src/image-viewer/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ exports[`image-viewer :base 1`] = `
<wx-image
ariaHidden="{{true}}"
ariaLabel=""
class="class t-class t-image t-image--shape-square"
hidden="{{true}}"
class="class t-class t-image t-image--shape-square t-image--lazy"
id="image"
lazyLoad="{{true}}"
mode="aspectFit"
Expand Down Expand Up @@ -115,8 +114,7 @@ exports[`image-viewer :base 2`] = `
<wx-image
ariaHidden="{{true}}"
ariaLabel=""
class="class t-class t-image t-image--shape-square"
hidden="{{true}}"
class="class t-class t-image t-image--shape-square t-image--lazy"
id="image"
lazyLoad="{{true}}"
mode="aspectFit"
Expand Down Expand Up @@ -180,8 +178,7 @@ exports[`image-viewer :base 3`] = `
<wx-image
ariaHidden="{{true}}"
ariaLabel=""
class="class t-class t-image t-image--shape-square"
hidden="{{true}}"
class="class t-class t-image t-image--shape-square t-image--lazy"
id="image"
lazyLoad="{{true}}"
mode="aspectFit"
Expand Down
6 changes: 2 additions & 4 deletions src/image/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ exports[`image :base 1`] = `
<wx-image
ariaHidden="{{true}}"
ariaLabel=""
class="class t-class t-image t-image--shape-square"
hidden="{{true}}"
class="class t-class t-image t-image--shape-square t-image--lazy"
id="image"
lazyLoad="{{false}}"
mode="scaleToFill"
Expand All @@ -71,8 +70,7 @@ exports[`image :success 1`] = `
<wx-image
ariaHidden="{{false}}"
ariaLabel=""
class="class t-class t-image t-image--shape-square"
hidden="{{false}}"
class="class t-class t-image t-image--shape-square "
id="image"
lazyLoad="{{false}}"
mode="heightFix"
Expand Down
10 changes: 10 additions & 0 deletions src/image/image.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
@image-loading-color: var(--td-image-loading-color, @text-color-placeholder);
@image-round-radius: var(--td-image-round-radius, @radius-default);

:host {
position: relative;
}

.@{prefix}-image {
color: @image-color;
vertical-align: top;
Expand All @@ -27,6 +31,12 @@
height: 100%;
}

&--lazy {
position: absolute;
top: 0;
z-index: -1;
}

&--shape {
&-circle {
border-radius: 50%;
Expand Down
4 changes: 2 additions & 2 deletions src/image/image.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<!-- 图片 -->
<image
id="{{tId||'image'}}"
hidden="{{isLoading || isFailed}}"
class="class {{prefix}}-class {{classPrefix}} {{classPrefix}}--shape-{{shape}}"
wx:if="{{ !isFailed }}"
class="class {{prefix}}-class {{classPrefix}} {{classPrefix}}--shape-{{shape}} {{isLoading ? classPrefix + '--lazy' : ''}}"
src="{{src}}"
style="{{_._style([innerStyle, style, customStyle])}}"
mode="{{mode}}"
Expand Down
Loading