Example #1
0
 it('list distinct events', function () {
   let anim = Animation.compile(null, $xml(`<group>
     <animation />
     <animation />
     <animation on="exit" />
     <animation on="exit" />
   </group>`))
   expect(anim._events).to.deep.equal(['', 'exit'])
 })
Example #2
0
 it('should return the function for given prop', function () {
   let anim = Animation.compile(null, $xml(`<group>
     <animation>
       <keyframe t="0" x="10" />
       <keyframe t="1" x="20" />
     </animation>
   </group>`))
   assert(anim.prop('x')({ t: 0.4 }) === 14)
 })
Example #3
0
 it('should return a set of properties', function () {
   let anim = Animation.compile(null, $xml(`<group>
     <animation>
       <keyframe t="0" x="10" />
       <keyframe t="1" x="20" />
     </animation>
     <animation>
       <keyframe t="0" y="10" />
       <keyframe t="1" y="20" />
     </animation>
   </group>`))
   expect(Array.from(anim._properties)).to.deep.equal(['x', 'y'])
 })
Example #4
0
 it('should choose animation that occurs last', function () {
   let anim = Animation.compile(null, $xml(`<group>
     <animation on="event1">
       <keyframe t="0" x="10" />
       <keyframe t="1" x="20" />
     </animation>
     <animation on="event2">
       <keyframe t="0" x="100" />
       <keyframe t="1" x="200" />
     </animation>
   </group>`))
   assert(anim.prop('x')({ event1: 0.2, event2: 0, t: 0.4 }) === 12)
   assert(anim.prop('x')({ event1: 0, event2: 0.2, t: 0.4 }) === 120)
 })