Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Parallel animation added #25

Merged
merged 4 commits into from Nov 8, 2023

Conversation

tomek-r
Copy link
Contributor

@tomek-r tomek-r commented Oct 31, 2023

What did you implement:

ParallelAnimation

How did you implement it:

Added new Parallel Animation wrapper.

How can we verify it:

Todos:

  • Write documentation (if required)
  • Fix linting errors
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

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

@tomek-r tomek-r requested a review from a team as a code owner October 31, 2023 15:16
@tomek-r tomek-r requested review from bchelkowski and adamczopek and removed request for a team October 31, 2023 15:16
' @param {Object} [options={}]
' @param {Float} options.delay
' @param {Boolean} options.repeat
' @param {AnimatorFactory~Options} options.animations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AA of {AnimatorFactory~Options}?

According to this, it could be something like:

@param {Object.<string, AnimatorFactory~Options>}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnimatorFactory~Options is already defined in AnimatoFactory.brs so it's ok, isn't it?
Anyway, in my opinion, instead of unclear AA (as Radek mentioned, docs are incorrect now, because AnimatorFactory~Options is a type of value of AA) I'd switch to an array of objects like { elementId, animatorOptions }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnimatorFactory~Options is already defined in AnimatoFactory.brs so it's ok, isn't it?

true, missed that when updating comment 😅 will update my previous comment then

Copy link
Contributor

@pawelhertman pawelhertman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done; left some remarks

' @param {AnimatorFactory~Options} options.animations
' @param {Node} element
' @returns {Object} - ParallelAnimation component
prototype.createAnimation = function(name as String, options = {} as Object, element = invalid as Object) as Object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

element is unused

Comment on lines +26 to +28
for each animationOption in options.animations.items()
parallelAnimationNode.appendChild(factory.createAnimation(animationOption.key, animationOption.value))
end for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnimatorFactory.createAnimation has such an interface: function (name as String, options = {} as Object, element = Invalid as Object)
So if you implement my suggestion (https://github.com/getndazn/kopytko-utils/pull/25/files#r1378563587) you could iterate through options.animations objects and code would look clearer:

Suggested change
for each animationOption in options.animations.items()
parallelAnimationNode.appendChild(factory.createAnimation(animationOption.key, animationOption.value))
end for
for each animation in options.animations
parallelAnimationNode.appendChild(factory.createAnimation(animation.elementId, animation.animatorOptions))
end for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the definition point of view clearer is:

{
  someAnimationConfig: {
     animations: {
       gradient: {
          duration:0.2
          easeFunction: "linear"
          fields: [...]
       }
     }
  }
}

vs

{
   someAnimationConfig: {
     animations: [
      {
        name: "gradient",
        options: {
          duration: 0.2,
          easeFunction: "linear",
          fields: [],
        }
      }
    ]
  }
}

Less code and more compact imho.

' @import /components/KopytkoTestSuite.brs from @dazn/kopytko-unit-testing-framework
' @import /components/rokuComponents/Animation.brs
' @mock /components/animator/AnimatorFactory.brs
function TestSuite__ParallelAnimationFactory() as Object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A unit test testing multiple elements is missing

Comment on lines +23 to +29
delay: Csng(0.2),
duration: Csng(20),
easeFunction: "linear",
easeInPercent: 0.1,
easeOutPercent: 0.2,
optional: false,
repeat: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, aren't fields necessary? Otherwise, it makes no sense to me

Co-authored-by: Błażej Chełkowski <bchelkow@gmail.com>
@bchelkowski bchelkowski merged commit dc9d32f into getndazn:master Nov 8, 2023
github-actions bot pushed a commit that referenced this pull request Nov 8, 2023
# [2.5.0](v2.4.2...v2.5.0) (2023-11-08)

### Features

* Parallel animation added ([#25](#25)) ([dc9d32f](dc9d32f))
Copy link

github-actions bot commented Nov 8, 2023

🎉 This PR is included in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants