<script src="spec/line.js"></script>
<script src="spec/marker.js"></script>
<script src="spec/mask.js"></script>-->
- <script src="spec/matrix.js"></script>
+ <!--<script src="spec/matrix.js"></script>-->
<!--<script src="spec/number.js"></script>
<script src="spec/path.js"></script>
<script src="spec/pattern.js"></script>
<script src="spec/utils.js"></script>
<script src="spec/viewbox.js"></script> -->
- <!-- <script src="spec/morphing.js"></script>
+ <script src="spec/morphing.js"></script>
<script src="spec/animator.js"></script>
- <script src="spec/runner.js"></script> -->
+ <script src="spec/runner.js"></script>
</body>
</html>
it('cancels a timeout which was created with timeout()', function () {
var spy = jasmine.createSpy('tester')
var id = SVG.Animator.timeout(spy, 100)
- SVG.Animator.cancelTimeout(id)
+ SVG.Animator.clearTimeout(id)
expect(spy).not.toHaveBeenCalled()
jasmine.RequestAnimationFrame.tick(100)
})
it(`Creates a morphable out of an SVG.Morphable.TransformBag`, function () {
- var morpher = new SVG.Morphable.TransformBag({}).to({rotate: 50, translateX: 20})
+ var morpher = new SVG.Morphable.TransformBag({rotate: 0, translateX: 0})
+ .to({rotate: 50, translateX: 20})
expect(morpher instanceof SVG.Morphable).toBe(true)
expect(morpher.type()).toBe(SVG.Morphable.TransformBag)
expect(morpher.at(0.5) instanceof SVG.Morphable.TransformBag).toBe(true)
- // TODO: This fails because of roundingerrors and the FIXME above
- expect(morpher.at(0.5).valueOf().decompose()).toBe(jasmine.objectContaining({rotate: 25, translateX: 10}))
+ expect(morpher.at(0.5)).toEqual(jasmine.objectContaining({rotate: 25, translateX: 10}))
})
it(`Creates a morphable out of an SVG.Morphable.ObjectBag`, function () {
runner.queue(initFn, runFn, true)
expect(runner._queue[0]).toEqual(jasmine.objectContaining({
- alwaysInitialise: true,
initialiser: initFn,
initialised: false,
- runner: runFn
+ runner: runFn,
+ finished: false
}))
})
})
expect(runner.step()).toBe(runner)
})
- it('calls initFn once and runFn at every step when alwaysInitialise is false', function() {
+ it('calls initFn once and runFn at every step', function() {
var runner = new SVG.Runner()
runner.queue(initFn, runFn, false)
expect(runFn.calls.count()).toBe(2)
})
- it('calls initFn and runFn at every step when alwaysInitialise is true', function() {
- var runner = new SVG.Runner()
+ it('calls initFn on every step if its declaritive', function() {
+ var runner = new SVG.Runner(new SVG.Controller())
runner.queue(initFn, runFn, true)
runner.step()
var runner = new SVG.Runner(1000)
var timeline = new SVG.Timeline()
- // FIXME: schedulung a runner on a timeline does not set the timeline for the runner!
runner.schedule(timeline)
- var runner2 = runner.animate(1000)
+ var runner2 = runner.animate(500, 1000)
expect(runner2.timeline()).toBe(timeline)
expect(runner2.time()).toBe(-1000)
+
+ expect(timeline.schedule()).toEqual(jasmine.objectContaining([
+ jasmine.objectContaining({start: 0, duration: 1000, end: 1000, runner: runner}),
+ jasmine.objectContaining({start: 1000, duration: 500, end: 1500, runner: runner2})
+ ]))
})
})
return this
},
- to: function (val, modifier) {
+ to: function (val) {
if(val == null)
return this._to
this._to = this._set(val)
- this.modifier = modifier || this.modifier
return this
},
}
})
-SVG.Morphable.TransformBag2 = SVG.invent({
+SVG.Morphable.TransformBag = SVG.invent({
create: function (obj) {
if(Array.isArray(obj)) {
obj = {
}
}
- Object.assign(this, obj)
+ Object.assign(this, SVG.Morphable.TransformBag.defaults, obj)
},
extend: {
}
})
-SVG.Morphable.TransformBag = SVG.invent({
- inherit: SVG.Matrix,
- create: function (obj) {
- if(Array.isArray(obj)) {
- obj = {
- scaleX: obj[0],
- scaleY: obj[1],
- shear: obj[2],
- rotate: obj[3],
- translateX: obj[4],
- translateY: obj[5],
- originX: obj[6],
- originY: obj[7]
- }
- }
-
- var data = {...(obj || {})}
-
- if (typeof data.origin == 'string') {
- delete data.origin
- }
-
- SVG.Matrix.call(this, data)
-
-
- if (data.origin) {
- data.originX = data.origin[0]
- data.originY = data.origin[1]
- }
-
- this.originX = data.originX || 0
- this.originY = data.originY || 0
- },
-
- extend: {
- toArray: function (){
- var v = this.decompose(this.originX, this.originY)
+SVG.Morphable.TransformBag.defaults = {
+ scaleX: 1,
+ scaleY: 1,
+ shear: 0,
+ rotate: 0,
+ translateX: 0,
+ translateY: 0,
+ originX: 0,
+ originY: 0
+}
- return [
- v.scaleX,
- v.scaleY,
- v.shear,
- v.rotate,
- v.translateX,
- v.translateY,
- v.originX,
- v.originY,
- ]
- }
- }
-})
+// SVG.Morphable.TransformBag = SVG.invent({
+// inherit: SVG.Matrix,
+// create: function (obj) {
+// if(Array.isArray(obj)) {
+// obj = {
+// scaleX: obj[0],
+// scaleY: obj[1],
+// shear: obj[2],
+// rotate: obj[3],
+// translateX: obj[4],
+// translateY: obj[5],
+// originX: obj[6],
+// originY: obj[7]
+// }
+// }
+//
+// var data = {...(obj || {})}
+//
+// if (typeof data.origin == 'string') {
+// delete data.origin
+// }
+//
+// SVG.Matrix.call(this, data)
+//
+//
+// if (data.origin) {
+// data.originX = data.origin[0]
+// data.originY = data.origin[1]
+// }
+//
+// this.originX = data.originX || 0
+// this.originY = data.originY || 0
+// },
+//
+// extend: {
+// toArray: function (){
+// var v = this.decompose(this.originX, this.originY)
+//
+// return [
+// v.scaleX,
+// v.scaleY,
+// v.shear,
+// v.rotate,
+// v.translateX,
+// v.translateY,
+// v.originX,
+// v.originY,
+// ]
+// }
+// }
+// })
SVG.Morphable.ObjectBag = SVG.invent({
SVG.PathArray,
SVG.Morphable.NonMorphable,
SVG.Morphable.TransformBag,
- SVG.Morphable.TransformBag2,
SVG.Morphable.ObjectBag,
]
// Create a morepher and set its type
const morpher = new SVG.Morphable()
- .type( affine ? SVG.Morphable.TransformBag2 : SVG.Matrix )
+ .type( affine ? SVG.Morphable.TransformBag : SVG.Matrix )
.stepper(this._stepper)
let origin