aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-05-25 12:05:53 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-05-25 12:05:53 +0200
commit69869d25c4b8fb4cd0f428ead4112ebb14dd2fb4 (patch)
tree77c86a52a174a68b2fbba9d78f7c645185dda95c
parent4d39baa3e4191c70d3eb7c9b67704b29f79a812d (diff)
downloadsvg.js-69869d25c4b8fb4cd0f428ead4112ebb14dd2fb4.tar.gz
svg.js-69869d25c4b8fb4cd0f428ead4112ebb14dd2fb4.zip
simple fix for morpharray
-rw-r--r--dirty.html33
-rw-r--r--src/controller.js1
-rw-r--r--src/runner.js5
3 files changed, 31 insertions, 8 deletions
diff --git a/dirty.html b/dirty.html
index 6647826..6893e42 100644
--- a/dirty.html
+++ b/dirty.html
@@ -75,12 +75,37 @@ function getColor(t) {
// }
// }
+var randPoint = (x = 50, y = 50) => [
+ Math.random() * 100 - 50 + x,
+ Math.random() * 100 - 50 + y
+]
+
+var poly = SVG('<polygon>').plot([
+ randPoint(),
+ randPoint(),
+ randPoint(),
+ randPoint(),
+ randPoint()
+]).attr({fill: 'none', stroke: 'black'}).addTo('svg')
+var polyAni = poly.animate(SVG.PID(null, 0))
+
+SVG.on(document, 'click', function (e) {
+ polyAni.plot([
+ randPoint(e.pageX-50, e.pageY-50),
+ randPoint(e.pageX+50, e.pageY-50),
+ randPoint(e.pageX+50, e.pageY),
+ randPoint(e.pageX+50, e.pageY+50),
+ randPoint(e.pageX-50, e.pageY+50)
+ ])
+})
+/*
var mover = SVG('rect').clone().show()
-mover.animate(SVG.PID()).move(500, 500)
+var anim = mover.animate(SVG.PID()).move(500, 500)
-// SVG.on(document, 'click', function (e) {
-// console.log(mover.animate(SVG.Spring(300, 30)).move(e.pageX, e.pageY))
-// })
+SVG.on(document, 'mousemove', function (e) {
+ //mover.animate(SVG.PID()).move(e.pageX, e.pageY)
+ anim.move(e.pageX, e.pageY)
+})*/
</script>
diff --git a/src/controller.js b/src/controller.js
index f6fab93..064c4f2 100644
--- a/src/controller.js
+++ b/src/controller.js
@@ -91,6 +91,7 @@ SVG.Controller = SVG.invent ({
},
isComplete: function (dt, c) {
+ return false
var result = false
for(var i = c.length; i--;) {
result = result || (Math.abs(c[i].error) < 0.01)
diff --git a/src/runner.js b/src/runner.js
index 718c5c8..ebdd93e 100644
--- a/src/runner.js
+++ b/src/runner.js
@@ -283,7 +283,6 @@ SVG.Runner = SVG.invent({
// Run each initialise function in the runner if required
_initialise: function (all) {
for (var i = 0, len = this._functions.length; i < len ; ++i) {
-
// Get the current initialiser
var current = this._functions[i]
@@ -511,10 +510,8 @@ SVG.extend(SVG.Runner, {
// Make a morpher and queue the animation
var morpher = new SVG.Morphable(this._stepper).to(to)
this.queue(function () {
- console.log('init')
morpher.from(this[method]())
}, function (pos) {
- console.log('run', pos)
this[method](morpher.at(pos))
return morpher.isComplete()
}, this._isDeclarative)
@@ -587,7 +584,7 @@ SVG.extend(SVG.Runner, {
return this.plot([a, b, c, d])
}
- return this._queueObject('plot', new this._element.morphArray(a))
+ return this._queueObject('plot', new this._element.MorphArray(a))
/*var morpher = this._element.morphArray().to(a)