From 878269e0e9d3fd566a8a3a8492ac1875e425ba03 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 3 Jan 2012 17:54:20 -0500 Subject: [PATCH] modifying public property names in spring.js, currentValue and currentTime are now current.point and current.time --- openseadragon.js | 31 ++++++++++++++++++------------- src/spring.js | 31 ++++++++++++++++++------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/openseadragon.js b/openseadragon.js index 79cb9b12..7f5d57b8 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -3060,18 +3060,23 @@ $.Spring = function( options ) { $.extend( true, this, options); - this.currentValue = typeof ( this.initial ) == "number" ? this.initial : 0; - this.startValue = this.currentValue; - this.targetValue = this.currentValue; + this.current = { + point: typeof ( this.initial ) == "number" ? + this.initial : + 0, + time: new Date().getTime() // always work in milliseconds + } - this.currentTime = new Date().getTime(); // always work in milliseconds - this.startTime = this.currentTime; - this.targetTime = this.currentTime; + this.startValue = this.current.point; + this.startTime = this.current.time; + + this.targetValue = this.current.point; + this.targetTime = this.current.time; }; $.Spring.prototype = { getCurrent: function() { - return this.currentValue; + return this.current.point; }, getTarget: function() { @@ -3080,14 +3085,14 @@ $.Spring.prototype = { resetTo: function(target) { this.targetValue = target; - this.targetTime = this.currentTime; + this.targetTime = this.current.time; this.startValue = this.targetValue; this.startTime = this.targetTime; }, springTo: function(target) { - this.startValue = this.currentValue; - this.startTime = this.currentTime; + this.startValue = this.current.point; + this.startTime = this.current.time; this.targetValue = target; this.targetTime = this.startTime + 1000 * this.animationTime; }, @@ -3098,14 +3103,14 @@ $.Spring.prototype = { }, update: function() { - this.currentTime = new Date().getTime(); - this.currentValue = (this.currentTime >= this.targetTime) ? + this.current.time = new Date().getTime(); + this.current.point = (this.current.time >= this.targetTime) ? this.targetValue : this.startValue + (this.targetValue - this.startValue) * transform( this.springStiffness, - (this.currentTime - this.startTime) / + (this.current.time - this.startTime) / (this.targetTime - this.startTime) ); } diff --git a/src/spring.js b/src/spring.js index 80bdd067..5ff8dc80 100644 --- a/src/spring.js +++ b/src/spring.js @@ -23,18 +23,23 @@ $.Spring = function( options ) { $.extend( true, this, options); - this.currentValue = typeof ( this.initial ) == "number" ? this.initial : 0; - this.startValue = this.currentValue; - this.targetValue = this.currentValue; + this.current = { + point: typeof ( this.initial ) == "number" ? + this.initial : + 0, + time: new Date().getTime() // always work in milliseconds + } - this.currentTime = new Date().getTime(); // always work in milliseconds - this.startTime = this.currentTime; - this.targetTime = this.currentTime; + this.startValue = this.current.point; + this.startTime = this.current.time; + + this.targetValue = this.current.point; + this.targetTime = this.current.time; }; $.Spring.prototype = { getCurrent: function() { - return this.currentValue; + return this.current.point; }, getTarget: function() { @@ -43,14 +48,14 @@ $.Spring.prototype = { resetTo: function(target) { this.targetValue = target; - this.targetTime = this.currentTime; + this.targetTime = this.current.time; this.startValue = this.targetValue; this.startTime = this.targetTime; }, springTo: function(target) { - this.startValue = this.currentValue; - this.startTime = this.currentTime; + this.startValue = this.current.point; + this.startTime = this.current.time; this.targetValue = target; this.targetTime = this.startTime + 1000 * this.animationTime; }, @@ -61,14 +66,14 @@ $.Spring.prototype = { }, update: function() { - this.currentTime = new Date().getTime(); - this.currentValue = (this.currentTime >= this.targetTime) ? + this.current.time = new Date().getTime(); + this.current.point = (this.current.time >= this.targetTime) ? this.targetValue : this.startValue + (this.targetValue - this.startValue) * transform( this.springStiffness, - (this.currentTime - this.startTime) / + (this.current.time - this.startTime) / (this.targetTime - this.startTime) ); }