Skip to content

Commit

Permalink
fix: 修复自定义图层的非法值透明度问题
Browse files Browse the repository at this point in the history
  • Loading branch information
StarJacky committed Dec 4, 2023
1 parent a7dae4e commit 1c18df5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/taro-components/src/components/map/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,9 @@ export class Map implements ComponentInterface {
// 创建 img 元素并设置样式
const img = document.createElement('img')
img.src = this._imageUrl
img.style.opacity = this._opacity
// 确保opacity值在0到1之间
const validOpacity = (this._opacity < 0 ) ? '1' : this._opacity
img.style.opacity = validOpacity
div.appendChild(img)
this._div = div
}
Expand Down Expand Up @@ -995,7 +997,8 @@ export class Map implements ComponentInterface {
this._div.style.width = imageWidth + 'px'
this._div.style.height = imageHeight + 'px'
this._div.style.display = this._visible ? 'block' : 'none'
this._div.getElementsByTagName('img')[0].style.opacity = this._opacity
const validOpacity = (this._opacity < 0 ) ? '1' : this._opacity
this._div.getElementsByTagName('img')[0].style.opacity = validOpacity
}

// 创建 GroundOverlay 实例
Expand Down Expand Up @@ -1031,7 +1034,8 @@ export class Map implements ComponentInterface {
const imgElement = element.querySelector('img')
if (imgElement) {
// 找到了对应的元素
element.style.opacity = opacity
const validOpacity = (opacity < 0 ) ? '1' : opacity
element.style.opacity = validOpacity
imgElement.style.display = visible ? 'block' : 'none'
element.style.zIndex = zIndex

Expand Down

0 comments on commit 1c18df5

Please sign in to comment.