Showing
1 changed file
with
18 additions
and
0 deletions
| @@ -158,6 +158,22 @@ export struct ImageItemView { | @@ -158,6 +158,22 @@ export struct ImageItemView { | ||
| 158 | 158 | ||
| 159 | build() { | 159 | build() { |
| 160 | Stack() { | 160 | Stack() { |
| 161 | + if(this.imageUri != null && (this.imageUri.includes('.gif') || this.imageUri.includes('.GIF'))){ | ||
| 162 | + Image(this.imageUri)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性 | ||
| 163 | + .width(this.fitWH === "width" ? "100%" : undefined) | ||
| 164 | + .height(this.fitWH === "height" ? "100%" : undefined) | ||
| 165 | + .aspectRatio(this.imageWHRatio) | ||
| 166 | + .objectFit(ImageFit.Cover)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能 | ||
| 167 | + .autoResize(false) | ||
| 168 | + .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放 | ||
| 169 | + .defaultFocus(true) | ||
| 170 | + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) | ||
| 171 | + .offset({ | ||
| 172 | + // TODO:知识点:通过offset控制图片的偏移 | ||
| 173 | + x: this.imageOffsetInfo.currentX, | ||
| 174 | + y: this.imageOffsetInfo.currentY | ||
| 175 | + }) | ||
| 176 | + }else{ | ||
| 161 | Image(this.imagePixelMap)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性 | 177 | Image(this.imagePixelMap)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性 |
| 162 | .width(this.fitWH === "width" ? "100%" : undefined) | 178 | .width(this.fitWH === "width" ? "100%" : undefined) |
| 163 | .height(this.fitWH === "height" ? "100%" : undefined) | 179 | .height(this.fitWH === "height" ? "100%" : undefined) |
| @@ -173,6 +189,8 @@ export struct ImageItemView { | @@ -173,6 +189,8 @@ export struct ImageItemView { | ||
| 173 | y: this.imageOffsetInfo.currentY | 189 | y: this.imageOffsetInfo.currentY |
| 174 | }) | 190 | }) |
| 175 | } | 191 | } |
| 192 | + | ||
| 193 | + } | ||
| 176 | .onBlur(() => { | 194 | .onBlur(() => { |
| 177 | this.resetCurrentImageInfo(); | 195 | this.resetCurrentImageInfo(); |
| 178 | }) | 196 | }) |
-
Please register or login to post a comment