|
|
|
|
|
|
|
|
it('throws away the morpher if it wasnt initialized yet and returns false', () => { |
|
|
it('throws away the morpher if it wasnt initialized yet and returns false', () => { |
|
|
const rect = new Rect().move(0, 0) |
|
|
const rect = new Rect().move(0, 0) |
|
|
const runner = rect.animate().move(10, 10) |
|
|
const runner = rect.animate().move(10, 10) |
|
|
// In that case tryRetarget is not successfull |
|
|
|
|
|
|
|
|
// In that case tryRetarget is not successful |
|
|
expect(runner._tryRetarget('x', 20)).toBe(false) |
|
|
expect(runner._tryRetarget('x', 20)).toBe(false) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rect = new Rect().move(0, 0) |
|
|
const rect = new Rect().move(0, 0) |
|
|
const runner = rect.animate().move(10, 10) |
|
|
const runner = rect.animate().move(10, 10) |
|
|
jasmine.RequestAnimationFrame.tick(16) |
|
|
jasmine.RequestAnimationFrame.tick(16) |
|
|
// In that case tryRetarget is not successfull |
|
|
|
|
|
|
|
|
// In that case tryRetarget is not successful |
|
|
expect(runner._tryRetarget('foo', 20)).toBe(false) |
|
|
expect(runner._tryRetarget('foo', 20)).toBe(false) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rect = new Rect() |
|
|
const rect = new Rect() |
|
|
const runner = rect.animate(new Controller(() => 0)).transform({ translate: [ 10, 10 ] }) |
|
|
const runner = rect.animate(new Controller(() => 0)).transform({ translate: [ 10, 10 ] }) |
|
|
jasmine.RequestAnimationFrame.tick(16) |
|
|
jasmine.RequestAnimationFrame.tick(16) |
|
|
// In that case tryRetarget is not successfull |
|
|
|
|
|
|
|
|
// In that case tryRetarget is not successful |
|
|
expect(runner._tryRetarget('transform', { translate: [ 20, 20 ] })).toBe(true) |
|
|
expect(runner._tryRetarget('transform', { translate: [ 20, 20 ] })).toBe(true) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
it('starts the timeline if retarget was successfull', () => { |
|
|
|
|
|
|
|
|
it('starts the timeline if retarget was successful', () => { |
|
|
const timeline = new Timeline() |
|
|
const timeline = new Timeline() |
|
|
const rect = new Rect().move(0, 0).timeline(timeline) |
|
|
const rect = new Rect().move(0, 0).timeline(timeline) |
|
|
const runner = rect.animate().move(10, 10) |
|
|
const runner = rect.animate().move(10, 10) |
|
|
|
|
|
|
|
|
runner.transform({ translate: [ 10, 20 ], scale: 2, rotate: 90 }) |
|
|
runner.transform({ translate: [ 10, 20 ], scale: 2, rotate: 90 }) |
|
|
runner.step(50) |
|
|
runner.step(50) |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// when every runner had the chance to add its bit of tranforms |
|
|
|
|
|
|
|
|
// when every runner had the chance to add its bit of transforms |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
expect(element.matrix().decompose()).toEqual(objectContaining({ |
|
|
expect(element.matrix().decompose()).toEqual(objectContaining({ |
|
|
translateX: 5, |
|
|
translateX: 5, |
|
|
|
|
|
|
|
|
runner.translate(10, 20).scale(2).rotate(45) |
|
|
runner.translate(10, 20).scale(2).rotate(45) |
|
|
runner.step(50) |
|
|
runner.step(50) |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// when every runner had the chance to add its bit of tranforms |
|
|
|
|
|
|
|
|
// when every runner had the chance to add its bit of transforms |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
|
|
|
|
|
|
// The origin is transformed with every |
|
|
// The origin is transformed with every |
|
|
|
|
|
|
|
|
runner2.step(50) |
|
|
runner2.step(50) |
|
|
runner3.step(50) |
|
|
runner3.step(50) |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// when every runner had the chance to add its bit of tranforms |
|
|
|
|
|
|
|
|
// when every runner had the chance to add its bit of transforms |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
|
|
|
|
|
|
// The origin is transformed with every |
|
|
// The origin is transformed with every |
|
|
|
|
|
|
|
|
runner2.step(50) |
|
|
runner2.step(50) |
|
|
runner3.step(50) |
|
|
runner3.step(50) |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// when every runner had the chance to add its bit of tranforms |
|
|
|
|
|
|
|
|
// when every runner had the chance to add its bit of transforms |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
|
|
|
|
|
|
expect(runner1._queue.length).toBe(0) |
|
|
expect(runner1._queue.length).toBe(0) |
|
|
|
|
|
|
|
|
runner.transform(new Matrix({ rotate: 90 })) |
|
|
runner.transform(new Matrix({ rotate: 90 })) |
|
|
runner.step(50) |
|
|
runner.step(50) |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// when every runner had the chance to add its bit of tranforms |
|
|
|
|
|
|
|
|
// when every runner had the chance to add its bit of transforms |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
|
|
|
|
|
|
// The origin is transformed with every |
|
|
// The origin is transformed with every |
|
|
|
|
|
|
|
|
runner.transform(Object.assign({ affine: true }, new Matrix({ rotate: 90 }))) |
|
|
runner.transform(Object.assign({ affine: true }, new Matrix({ rotate: 90 }))) |
|
|
runner.step(50) |
|
|
runner.step(50) |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// when every runner had the chance to add its bit of tranforms |
|
|
|
|
|
|
|
|
// when every runner had the chance to add its bit of transforms |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
|
|
|
|
|
|
// The origin is transformed with every |
|
|
// The origin is transformed with every |
|
|
|
|
|
|
|
|
runner.transform(new Matrix({ rotate: 90 }), true, true) |
|
|
runner.transform(new Matrix({ rotate: 90 }), true, true) |
|
|
runner.step(50) |
|
|
runner.step(50) |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// transform sets an immediate callback to apply all merged transforms |
|
|
// when every runner had the chance to add its bit of tranforms |
|
|
|
|
|
|
|
|
// when every runner had the chance to add its bit of transforms |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
jasmine.RequestAnimationFrame.tick(1) |
|
|
|
|
|
|
|
|
// The origin is transformed with every |
|
|
// The origin is transformed with every |