summaryrefslogtreecommitdiffstats
path: root/dist/svg.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-01-28 15:43:43 +0100
committerwout <wout@impinc.co.uk>2014-01-28 15:43:43 +0100
commite04f8d1b3595c65e245465606e3987025075a4fd (patch)
treeb5b559ec735dee3245de203cb592e93190b79409 /dist/svg.js
parent97f12207121d4e3171c5ef07d8098f06fb509f67 (diff)
downloadsvg.js-e04f8d1b3595c65e245465606e3987025075a4fd.tar.gz
svg.js-e04f8d1b3595c65e245465606e3987025075a4fd.zip
Added loop(), switched to requestAnimFrame, bumped to v0.38
Diffstat (limited to 'dist/svg.js')
-rw-r--r--dist/svg.js44
1 files changed, 36 insertions, 8 deletions
diff --git a/dist/svg.js b/dist/svg.js
index 55a6e96..cf9159b 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -1,4 +1,4 @@
-/* svg.js v0.37 - svg regex default color array pointarray number viewbox bbox rbox element parent container fx event defs group arrange mask clip gradient doc shape use rect ellipse line poly path image text textpath nested hyperlink sugar set memory loader - svgjs.com/license */
+/* svg.js v0.38 - svg regex default color array pointarray number viewbox bbox rbox element parent container fx event defs group arrange mask clip gradient doc shape use rect ellipse line poly path image text textpath nested hyperlink sugar set memory loader - svgjs.com/license */
;(function() {
this.SVG = function(element) {
@@ -1415,9 +1415,9 @@
, duration: d
}
- /* start animation */
- fx.interval = setInterval(function(){
-
+ /* render function */
+ fx.render = function(){
+
if (fx.situation.play === true) {
// This code was borrowed from the emile.js micro framework by Thomas Fuchs, aka MadRobby.
var time = new Date().getTime()
@@ -1431,12 +1431,25 @@
if (fx._plot)
element.plot(new SVG.PointArray(fx._plot.destination).settle())
- clearInterval(fx.interval)
- fx._after ? fx._after.apply(element, [fx]) : fx.stop()
+ if (fx._loop === true || (typeof fx._loop == 'number' && fx._loop > 1)) {
+ if (typeof fx._loop == 'number')
+ --fx._loop
+ fx.animate(d, ease, delay)
+ } else {
+ fx._after ? fx._after.apply(element, [fx]) : fx.stop()
+ }
+
+ } else {
+ requestAnimFrame(fx.render)
}
+ } else {
+ requestAnimFrame(fx.render)
}
- }, d > fx.situation.interval ? fx.situation.interval : d)
+ }
+
+ /* start animation */
+ fx.render()
}, delay || 0)
}
@@ -1585,6 +1598,12 @@
return this
}
+ // Make loopable
+ , loop: function(times) {
+ this._loop = times || true
+
+ return this
+ }
// Stop running animation
, stop: function() {
/* stop current animation */
@@ -1603,6 +1622,7 @@
delete this._cy
delete this._size
delete this._plot
+ delete this._loop
delete this._after
delete this._during
delete this._viewbox
@@ -1708,7 +1728,15 @@
// rect.animate(1500, '>').move(200, 300).after(function() {
// this.fill({ color: '#f06' })
// })
-
+
+
+ // Shim layer with setTimeout fallback by Paul Irish
+ window.requestAnimFrame = (function(){
+ return window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ function (c) { window.setTimeout(c, 1000 / 60) }
+ })()
;[ 'click'
, 'dblclick'