aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-09-02 21:44:19 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-09-02 21:44:19 +0200
commit29b2bd7f811584380b35434d5bf29913ffe93459 (patch)
tree031bba153572ba7d16f8aa702cb4ac4612770514
parent3f623a9e61a9015ceef3735bca167e9410313e49 (diff)
downloadsvg.js-29b2bd7f811584380b35434d5bf29913ffe93459.tar.gz
svg.js-29b2bd7f811584380b35434d5bf29913ffe93459.zip
add terminate method to timeline so memory can be freed
-rw-r--r--src/animation/Timeline.js47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js
index 39e0f1a..2f6f5d3 100644
--- a/src/animation/Timeline.js
+++ b/src/animation/Timeline.js
@@ -27,26 +27,8 @@ export default class Timeline extends EventTarget {
this._timeSource = timeSource
- // Store the timing variables
- this._startTime = 0
- this._speed = 1.0
-
- // Determines how long a runner is hold in memory. Can be a dt or true/false
- this._persist = 0
-
- // Keep track of the running animations and their starting parameters
- this._nextFrame = null
- this._paused = true
- this._runners = []
- this._runnerIds = []
- this._lastRunnerId = -1
- this._time = 0
- this._lastSourceTime = 0
- this._lastStepTime = 0
-
- // Make sure that step is always called in class context
- this._step = this._stepFn.bind(this, false)
- this._stepImmediate = this._stepFn.bind(this, true)
+ // terminate resets all variables to their initial state
+ this.terminate()
}
active() {
@@ -326,6 +308,31 @@ export default class Timeline extends EventTarget {
return this
}
+
+ terminate() {
+ // cleanup memory
+
+ // Store the timing variables
+ this._startTime = 0
+ this._speed = 1.0
+
+ // Determines how long a runner is hold in memory. Can be a dt or true/false
+ this._persist = 0
+
+ // Keep track of the running animations and their starting parameters
+ this._nextFrame = null
+ this._paused = true
+ this._runners = []
+ this._runnerIds = []
+ this._lastRunnerId = -1
+ this._time = 0
+ this._lastSourceTime = 0
+ this._lastStepTime = 0
+
+ // Make sure that step is always called in class context
+ this._step = this._stepFn.bind(this, false)
+ this._stepImmediate = this._stepFn.bind(this, true)
+ }
}
registerMethods({