getndazn / kopytko-utils

A collection of modern utility functions for Brightscript applications
MIT License
6 stars 4 forks source link

Promise Error with Animation Utility #19

Closed alexkn1 closed 1 year ago

alexkn1 commented 1 year ago

When using animation utility, I get:

[Promise] Trying to complete already completed promise

    m.contestCompletedTextBlock.opacity = 1.0
    Animator().fadeOut(m.contestCompletedTextBlock, { duration: 2 }).then(sub (state as String):
        Animator().fadeIn(m.contestCompletedTextBlock, { duration: 2 })
    end sub)

I tried this:

  m.anim = Animator().fadeOut(m.contestCompletedTextBlock, { duration: 2 }).then(sub (state as String):
    m.anim.resolve() 
   ' CHANGES THE STATUS FROM 0 to 1, however the ERROR MSG still appears.        
    Animator().fadeIn(m.contestCompletedTextBlock, { duration: 2 })
    end sub)

I tried finishAll, stopAll, resolve() And it still prints out that Promise msg. However, if I try it on another node, it works fine. It seems like when re-using on the same node it does this.

RadoslawZambrowski commented 1 year ago

Hey @alexkn1

Not a legitimate solution, just a workaround, but you can trigger another animation via setTimeout function from the first animation's callback.

e.g.

m.contestCompletedTextBlock.opacity = 1.0
Animator().fadeOut(m.contestCompletedTextBlock, { duration: 2 }).then(sub (state as String)
    setTimeout(fadeInTextBlock, 0)
end sub)

sub fadeInTextBlock()
    Animator().fadeIn(m.contestCompletedTextBlock, { duration: 2 })
end sub

Anyway, this issue should be addressed and solved properly.

alexkn1 commented 1 year ago

RadoslawZambrowski

@RadoslawZambrowski

This worked! However, I am looking for a smoother transition between the two. There is about a half a second delay when going from one to another.

Thanks!