getndazn / kopytko-utils

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

fix: Fixed clearing context in Animator #24

Closed RadoslawZambrowski closed 11 months ago

RadoslawZambrowski commented 11 months ago

What did you implement:

It turned out that the root cause for not working animations triggered from the other animation's callback is clearing the context after the new animation is set up. Ie. calling m["$$animatorContexts"][contextName].promise.resolve("stopped") triggers the callback, which calls Animator.animate, which sets fields in the m["$$animatorContexts"][contextName]. After the execution of the callback is finished m["$$animatorContexts"].delete(contextName) is called which removes fields that were just set.

How did you implement it:

The previous fix is not needed anymore, hence I reverted it. Instead of it, I changed the order of resolving the promise and deleting context from the $$animatorContexts object

How can we verify it:

Given there is a component with an id container the following code:

    m.container.opacity = 1.0

    ' Immediate calls
    Animator().fadeOut(m.container, { duration: 2 }).finally(sub (state as String)
      ?"Faded Out - ";state
    end sub)
    Animator().fadeIn(m.container, { duration: 2 }).finally(sub (state as String)
      ?"Faded In - ";state
    end sub)
    Animator().fadeOut(m.container, { duration: 2 }).finally(sub (state as String, m as Object)
      ?"Again Faded Out - ";state
      ' Callback calls
      Animator().fadeIn(m.container, { duration: 2 }).finally(sub (state as String, m as Object)
        ?"Again Faded In - ";state
        Animator().fadeOut(m.container, { duration: 2 }).finally(sub (state as String, m as Object)
          ?"And Again Faded Out - ";state
          Animator().fadeIn(m.container, { duration: 2 }).finally(sub (state as String)
            ?"And Again Faded In - ";state
          end sub)
        end sub, m)
      end sub, m)
    end sub, m)

Todos:

Is this ready for review?: YES Is it a breaking change?: NO

github-actions[bot] commented 11 months ago

:tada: This PR is included in version 2.4.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: