removed remaining psuedo-private properties from spring.js

This commit is contained in:
thatcher 2012-01-03 17:44:52 -05:00
parent 3bff4fe532
commit 55f1e47156
2 changed files with 38 additions and 26 deletions

View File

@ -3057,51 +3057,57 @@ $.Spring = function( options ) {
}; };
} }
$.extend( true, this, options ); $.extend( true, this, options);
this._currentValue = typeof ( this.initial ) == "number" ? this.initial : 0; this.currentValue = typeof ( this.initial ) == "number" ? this.initial : 0;
this._startValue = this._currentValue; this.startValue = this.currentValue;
this._targetValue = this._currentValue; this.targetValue = this.currentValue;
this._currentTime = new Date().getTime(); // always work in milliseconds this.currentTime = new Date().getTime(); // always work in milliseconds
this._startTime = this._currentTime; this.startTime = this.currentTime;
this._targetTime = this._currentTime; this.targetTime = this.currentTime;
}; };
$.Spring.prototype = { $.Spring.prototype = {
getCurrent: function() { getCurrent: function() {
return this._currentValue; return this.currentValue;
}, },
getTarget: function() { getTarget: function() {
return this._targetValue; return this.targetValue;
}, },
resetTo: function(target) { resetTo: function(target) {
this._targetValue = target; this.targetValue = target;
this._targetTime = this._currentTime; this.targetTime = this.currentTime;
this._startValue = this._targetValue; this.startValue = this.targetValue;
this._startTime = this._targetTime; this.startTime = this.targetTime;
}, },
springTo: function(target) { springTo: function(target) {
this._startValue = this._currentValue; this.startValue = this.currentValue;
this._startTime = this._currentTime; this.startTime = this.currentTime;
this._targetValue = target; this.targetValue = target;
this._targetTime = this._startTime + 1000 * this.animationTime; this.targetTime = this.startTime + 1000 * this.animationTime;
}, },
shiftBy: function(delta) { shiftBy: function(delta) {
this._startValue += delta; this.startValue += delta;
this._targetValue += delta; this.targetValue += delta;
}, },
update: function() { update: function() {
this._currentTime = new Date().getTime(); this.currentTime = new Date().getTime();
this._currentValue = (this._currentTime >= this._targetTime) ? this._targetValue : this.currentValue = (this.currentTime >= this.targetTime) ?
this._startValue + (this._targetValue - this._startValue) * this.targetValue :
transform( this.springStiffness, (this._currentTime - this._startTime) / (this._targetTime - this._startTime)); this.startValue +
(this.targetValue - this.startValue) *
transform(
this.springStiffness,
(this.currentTime - this.startTime) /
(this.targetTime - this.startTime)
);
} }
} }

View File

@ -62,9 +62,15 @@ $.Spring.prototype = {
update: function() { update: function() {
this.currentTime = new Date().getTime(); this.currentTime = new Date().getTime();
this.currentValue = (this.currentTime >= this.targetTime) ? this.targetValue : this.currentValue = (this.currentTime >= this.targetTime) ?
this.startValue + (this.targetValue - this.startValue) * this.targetValue :
transform( this.springStiffness, (this.currentTime - this.startTime) / (this.targetTime - this.startTime)); this.startValue +
(this.targetValue - this.startValue) *
transform(
this.springStiffness,
(this.currentTime - this.startTime) /
(this.targetTime - this.startTime)
);
} }
} }