Skip to content

Commit

Permalink
Fix: Allows events like lottieAnimationStart to fire when used in a C…
Browse files Browse the repository at this point in the history
…apacitor project (#438)

Co-authored-by: Tim Brust <github@timbrust.de>
  • Loading branch information
dtarnawsky and timbru31 committed Jun 26, 2022
1 parent 4545d35 commit b537de0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/android/LottieSplashScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.os.Looper
import android.util.Log
import android.view.animation.AlphaAnimation
import android.view.animation.Animation
import android.webkit.WebView
import android.widget.ImageView
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieComposition
Expand Down Expand Up @@ -272,11 +273,11 @@ class LottieSplashScreen : CordovaPlugin() {
animationView.addAnimatorListener(
object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationStart'))") { }
(webView.getView() as WebView).evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationStart'))") { }
}

override fun onAnimationEnd(animation: Animator) {
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationEnd'))") { }
(webView.getView() as WebView).evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationEnd'))") { }
val hideAfterAnimationDone = preferences.getBoolean(
"LottieHideAfterAnimationEnd",
false
Expand All @@ -288,11 +289,11 @@ class LottieSplashScreen : CordovaPlugin() {
}

override fun onAnimationCancel(animation: Animator) {
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationCancel'))") { }
(webView.getView() as WebView).evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationCancel'))") { }
}

override fun onAnimationRepeat(animation: Animator) {
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationRepeat'))") { }
(webView.getView() as WebView).evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationRepeat'))") { }
}
}
)
Expand Down

0 comments on commit b537de0

Please sign in to comment.