src/service/vsync-impl.js
/**
   * Runs the series of mutates until the mutator returns a false value.
   * @param {!Node} contextNode
   * @param {function(time, time, !VsyncStateDef):boolean} mutator The
   *   mutator callback. Only expected to do DOM writes, not reads. If the
   *   returned value is true, the vsync task will be repeated, otherwise it
   *   will be completed. The arguments are: timeSinceStart:time,
   *   timeSincePrev:time and state:VsyncStateDef.
   * @param {number=} opt_timeout Optional timeout that will force the series
   *   to complete and reject the promise.
   * @return {!Promise} Returns the promise that will either resolve on when
   *   the vsync series are completed or reject in case of failure, such as
   *   timeout.
   */
Runs the series of mutates until the mutator returns a false value.
@param {!Node} contextNode
@param {function(time, time, !VsyncStateDef):boolean} mutator The
mutator callback. Only expected to do DOM writes, not reads. If the
returned value is true, the vsync task will be repeated, otherwise it
will be completed.
Runs the series of mutates until the mutator returns a false value . @param { !Node } contextNode @param { function ( time time !VsyncStateDef ) : boolean } mutator The mutator callback . Only expected to do DOM writes not reads . If the returned value is true the vsync task will be repeated otherwise it will be completed .
runAnimMutateSeries(contextNode, mutator, opt_timeout) {
    if (!this.canAnimate_(contextNode)) {
      return Promise.reject(cancellation());
    }
    return new Promise((resolve, reject) => {
      const startTime = Date.now();
      let prevTime = 0;
      const task = this.createAnimTask(contextNode, {
        mutate: state => {
          const timeSinceStart = Date.now() - startTime;
          const res = mutator(timeSinceStart, timeSinceStart - prevTime, state);
          if (!res) {
            resolve();
          } else if (opt_timeout && timeSinceStart > opt_timeout) {
            reject(new Error('timeout'));
          } else {
            prevTime = timeSinceStart;
            task(state);
          }
        },
      });
      task({});
    });
  }
runAnimMutateSeries ( contextNode , mutator , opt_timeout ) { if ( ! this . canAnimate_ ( contextNode ) ) { return Promise . reject ( cancellation ( ) ) ; } return new Promise ( ( resolve , reject ) => { const startTime = Date . now ( ) ; let prevTime = 0 ; const task = this . createAnimTask ( contextNode , { mutate : state => { const timeSinceStart = Date . now ( ) - startTime ; const res = mutator ( timeSinceStart , timeSinceStart - prevTime , state ) ; if ( ! res ) { resolve ( ) ; } else if ( opt_timeout && timeSinceStart > opt_timeout ) { reject ( new Error ( 'timeout' ) ) ; } else { prevTime = timeSinceStart ; task ( state ) ; } } , } ) ; task ( { } ) ; } ) ; }
Runs the series of mutates until the mutator returns a false value.
Runs the series of mutates until the mutator returns a false value .