Merge pull request #141 from felizuno/now2

Implementing the new OpenSeadragon.now()
This commit is contained in:
iangilman 2013-06-21 09:28:37 -07:00
commit 67e588b513
10 changed files with 22 additions and 22 deletions

View File

@ -287,7 +287,7 @@ function updateFade( button ) {
opacity;
if ( button.shouldFade ) {
currentTime = +new Date();
currentTime = $.now();
deltaTime = currentTime - button.fadeBeginTime;
opacity = 1.0 - deltaTime / button.fadeLength;
opacity = Math.min( 1.0, opacity );
@ -305,7 +305,7 @@ function updateFade( button ) {
function beginFading( button ) {
button.shouldFade = true;
button.fadeBeginTime = +new Date() + button.fadeDelay;
button.fadeBeginTime = $.now() + button.fadeDelay;
window.setTimeout( function(){
scheduleFade( button );
}, button.fadeDelay );

View File

@ -46,7 +46,7 @@
i;
$.extend( true, this, {
id: 'controldock-'+(+new Date())+'-'+Math.floor(Math.random()*1000000),
id: 'controldock-'+$.now()+'-'+Math.floor(Math.random()*1000000),
container: $.makeNeutralElement('form'),
controls: []
}, options );

View File

@ -299,7 +299,7 @@ $.Drawer.prototype = {
*/
reset: function() {
clearTiles( this );
this.lastResetTime = +new Date();
this.lastResetTime = $.now();
this.updateAgain = true;
return this;
},
@ -456,7 +456,7 @@ function updateViewport( drawer ) {
level,
best = null,
haveDrawn = false,
currentTime = +new Date(),
currentTime = $.now(),
viewportSize = drawer.viewport.getContainerSize(),
viewportBounds = drawer.viewport.getBounds( true ),
viewportTL = viewportBounds.getTopLeft(),

View File

@ -677,7 +677,7 @@
delegate.lastPoint = getMouseAbsolute( event );
delegate.lastMouseDownPoint = delegate.lastPoint;
delegate.lastMouseDownTime = +new Date();
delegate.lastMouseDownTime = $.now();
if ( tracker.pressHandler ) {
propagate = tracker.pressHandler(
@ -920,7 +920,7 @@
return;
}
var time = +new Date() - delegate.lastMouseDownTime,
var time = $.now() - delegate.lastMouseDownTime,
point = getMouseAbsolute( event ),
distance = delegate.lastMouseDownPoint.distanceTo( point ),
quick = time <= tracker.clickTimeThreshold &&

View File

@ -57,7 +57,7 @@ $.Navigator = function( options ){
//We may need to create a new element and id if they did not
//provide the id for the existing element
if( !options.id ){
options.id = 'navigator-' + (+new Date());
options.id = 'navigator-' + $.now();
this.element = $.makeNeutralElement( "div" );
options.controlOptions = {anchor: $.ControlAnchor.TOP_RIGHT,
attachToViewer: true,

View File

@ -1386,7 +1386,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
head = document.head ||
document.getElementsByTagName( "head" )[ 0 ] ||
document.documentElement,
jsonpCallback = options.callbackName || 'openseadragon' + (+new Date()),
jsonpCallback = options.callbackName || 'openseadragon' + $.now(),
previous = window[ jsonpCallback ],
replace = "$1" + jsonpCallback + "$2",
callbackParam = options.param || 'callback',
@ -1700,7 +1700,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
if ( !iIntervalId ) {
iIntervalId = setInterval( function() {
if ( aAnimQueue.length ) {
var time = new Date().getTime();
var time = $.now();
// Process all of the currently outstanding frame
// requests, but none that get added during the
// processing.

View File

@ -77,7 +77,7 @@ $.Profiler.prototype = {
}
this.midUpdate = true;
this.lastBeginTime = new Date().getTime();
this.lastBeginTime = $.now();
if (this.numUpdates < 1) {
return; // this is the first update
@ -103,7 +103,7 @@ $.Profiler.prototype = {
return;
}
this.lastEndTime = new Date().getTime();
this.lastEndTime = $.now();
this.midUpdate = false;
var time = this.lastEndTime - this.lastBeginTime;

View File

@ -70,7 +70,7 @@ $.ReferenceStrip = function( options ){
//We may need to create a new element and id if they did not
//provide the id for the existing element
if( !options.id ){
options.id = 'referencestrip-' + (+new Date());
options.id = 'referencestrip-' + $.now();
this.element = $.makeNeutralElement( "div" );
this.element.id = options.id;
this.element.className = 'referencestrip';
@ -192,12 +192,12 @@ $.ReferenceStrip = function( options ){
clickTimeThreshold: this.clickTimeThreshold,
clickDistThreshold: this.clickDistThreshold,
pressHandler: function( tracker ){
tracker.dragging = +new Date();
tracker.dragging = $.now();
},
releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){
var id = tracker.element.id,
page = Number( id.split( '-' )[ 2 ] ),
now = +new Date();
now = $.now();
if ( insideElementPress &&
insideElementRelease &&

View File

@ -76,7 +76,7 @@ $.Spring = function( options ) {
value: typeof ( this.initial ) == "number" ?
this.initial :
0,
time: new Date().getTime() // always work in milliseconds
time: $.now() // always work in milliseconds
};
this.start = {
@ -127,7 +127,7 @@ $.Spring.prototype = {
* @function
*/
update: function() {
this.current.time = new Date().getTime();
this.current.time = $.now();
this.current.value = (this.current.time >= this.target.time) ?
this.target.value :
this.start.value +

View File

@ -1263,7 +1263,7 @@ function beginControlsAutoHide( viewer ) {
}
viewer.controlsShouldFade = true;
viewer.controlsFadeBeginTime =
+new Date() +
$.now() +
viewer.controlsFadeDelay;
window.setTimeout( function(){
@ -1279,7 +1279,7 @@ function updateControlsFade( viewer ) {
opacity,
i;
if ( viewer.controlsShouldFade ) {
currentTime = new Date().getTime();
currentTime = $.now();
deltaTime = currentTime - viewer.controlsFadeBeginTime;
opacity = 1.0 - deltaTime / viewer.controlsFadeLength;
@ -1528,7 +1528,7 @@ function resolveUrl( prefix, url ) {
function beginZoomingIn() {
THIS[ this.hash ].lastZoomTime = +new Date();
THIS[ this.hash ].lastZoomTime = $.now();
THIS[ this.hash ].zoomFactor = this.zoomPerSecond;
THIS[ this.hash ].zooming = true;
scheduleZoom( this );
@ -1536,7 +1536,7 @@ function beginZoomingIn() {
function beginZoomingOut() {
THIS[ this.hash ].lastZoomTime = +new Date();
THIS[ this.hash ].lastZoomTime = $.now();
THIS[ this.hash ].zoomFactor = 1.0 / this.zoomPerSecond;
THIS[ this.hash ].zooming = true;
scheduleZoom( this );
@ -1559,7 +1559,7 @@ function doZoom() {
adjustFactor;
if ( THIS[ this.hash ].zooming && this.viewport) {
currentTime = +new Date();
currentTime = $.now();
deltaTime = currentTime - THIS[ this.hash ].lastZoomTime;
adjustedFactor = Math.pow( THIS[ this.hash ].zoomFactor, deltaTime / 1000 );