CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
step-all.mjs121 linesDownload Raw Back to animation
1import step from './step.mjs';2import startAnimation from './start.mjs';3 4function stepAll( now, cy ){5  let eles = cy._private.aniEles;6  let doneEles = [];7 8  function stepOne( ele, isCore ){9    let _p = ele._private;10    let current = _p.animation.current;11    let queue = _p.animation.queue;12    let ranAnis = false;13 14    // if nothing currently animating, get something from the queue15    if( current.length === 0 ){16      let next = queue.shift();17 18      if( next ){19        current.push( next );20      }21    }22 23    let callbacks = function( callbacks ){24      for( let j = callbacks.length - 1; j >= 0; j-- ){25        let cb = callbacks[ j ];26 27        cb();28      }29 30      callbacks.splice( 0, callbacks.length );31    };32 33    // step and remove if done34    for( let i = current.length - 1; i >= 0; i-- ){35      let ani = current[ i ];36      let ani_p = ani._private;37 38      if( ani_p.stopped ){39        current.splice( i, 1 );40 41        ani_p.hooked = false;42        ani_p.playing = false;43        ani_p.started = false;44 45        callbacks( ani_p.frames );46 47        continue;48      }49 50      if( !ani_p.playing && !ani_p.applying ){ continue; }51 52      // an apply() while playing shouldn't do anything53      if( ani_p.playing && ani_p.applying ){54        ani_p.applying = false;55      }56 57      if( !ani_p.started ){58        startAnimation( ele, ani, now, isCore );59      }60 61      step( ele, ani, now, isCore );62 63      if( ani_p.applying ){64        ani_p.applying = false;65      }66 67      callbacks( ani_p.frames );68 69      if( ani_p.step != null ){70        ani_p.step(now);71      }72 73      if( ani.completed() ){74        current.splice( i, 1 );75 76        ani_p.hooked = false;77        ani_p.playing = false;78        ani_p.started = false;79 80        callbacks( ani_p.completes );81      }82 83      ranAnis = true;84    }85 86    if( !isCore && current.length === 0 && queue.length === 0 ){87      doneEles.push( ele );88    }89 90    return ranAnis;91  } // stepElement92 93  // handle all eles94  let ranEleAni = false;95  for( let e = 0; e < eles.length; e++ ){96    let ele = eles[ e ];97    let handledThisEle = stepOne( ele );98 99    ranEleAni = ranEleAni || handledThisEle;100  } // each element101 102  let ranCoreAni = stepOne( cy, true );103 104  // notify renderer105  if( ranEleAni || ranCoreAni ){106    if( eles.length > 0 ){107      cy.notify('draw', eles);108    } else {109      cy.notify('draw');110    }111  }112 113  // remove elements from list of currently animating if its queues are empty114  eles.unmerge( doneEles );115 116  cy.emit('step');117 118} // stepAll119 120export default stepAll;121 
basant307/AI_Governance_Project · CoolFace