Skip to content

Commit

Permalink
JS animation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Jul 12, 2024
1 parent 5f41b5d commit aab9280
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ actual inline var ImageView.source: ImageSource?
}
}
fun ImageView.setSrc(url: String) {
val animating = animationsEnabled
if(!animationsEnabled) {
native.innerHTML = ""
}
Expand Down Expand Up @@ -100,13 +101,13 @@ fun ImageView.setSrc(url: String) {
val children = (0..<native.children.length).mapNotNull { native.children[it] }
val myIndex = children.indexOf(newElement)
if(myIndex == -1) return@label Unit
if((clockMillis() - now) < 32) {
if((clockMillis() - now) < 32 && !animating) {
// disable animations and get it done; no reason to show the user an animation
newElement.withoutAnimation {
newElement.style.opacity = "0.8"
newElement.style.opacity = "1"
}
} else {
newElement.style.opacity = "0.99"
newElement.style.opacity = "1"
}
for(index in 0..<myIndex) {
val it = children[index] as? HTMLElement ?: continue
Expand Down

0 comments on commit aab9280

Please sign in to comment.