diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-08-14 16:37:39 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-08-14 16:48:51 -0400 |
| commit | 6b3d07293bf674703b286cb396049fb8e83b86b7 (patch) | |
| tree | d929a2be9f81f6c2297725d7dbae1e2a690b987f /public/assets/javascripts/ui/lib/AnimatedView.js | |
| parent | f74635f1d28d3450d7c4ddb9869685dc20019f3a (diff) | |
AnimatedView
Diffstat (limited to 'public/assets/javascripts/ui/lib/AnimatedView.js')
| -rw-r--r-- | public/assets/javascripts/ui/lib/AnimatedView.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/lib/AnimatedView.js b/public/assets/javascripts/ui/lib/AnimatedView.js new file mode 100644 index 0000000..3c50b0a --- /dev/null +++ b/public/assets/javascripts/ui/lib/AnimatedView.js @@ -0,0 +1,31 @@ +var AnimatedView = View.extend({ + + _animating: false, + last_t: 0, + + startAnimating: function(){ + if (this._animating) return + this._animating = true + this._animate() + }, + + stopAnimating: function(){ + this._animating = false + }, + + _animate: function(t){ + if (! this._animating) return + + requestAnimationFrame(this._animate.bind(this)) + + var dt = t - this.last_t + this.last_t = t + + if (! t) return + + this.animate(t, dt) + }, + + animate: function(t, dt){}, + +})
\ No newline at end of file |
