phetsims / twixt

Animation library for interactive HTML5 graphics
MIT License
1 stars 3 forks source link

Is this length computation correct? #12

Open samreid opened 6 years ago

samreid commented 6 years ago

During #11 I noticed this code in Animation.js

        // Compute the start/end for each target, and determine the length of our animation
        this.length = this.duration;
        for ( var i = 0; i < this.targets.length; i++ ) {
          var target = this.targets[ i ];
          target.computeStartEnd();

          // If we don't have a computed length yet, check all of our targets
          if ( this.length === null ) {
            this.length = target.getPreferredDuration();
          }
        }

That is, it uses the Animation.length, if specified, otherwise it uses the preferred duration of the first child that has one. Is this correct? Should it use the max of all the children with preferred durations? What if a child has a preferred duration longer than Animation.length?

samreid commented 6 years ago

It seems that only one child can supply a preferred duration, so this should be a non-issue. @jonathanolson if that's correct, let me know and I'll add a comment to that effect.