mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Merge pull request #141 from felizuno/now2
Implementing the new OpenSeadragon.now()
This commit is contained in:
commit
67e588b513
@ -287,7 +287,7 @@ function updateFade( button ) {
|
|||||||
opacity;
|
opacity;
|
||||||
|
|
||||||
if ( button.shouldFade ) {
|
if ( button.shouldFade ) {
|
||||||
currentTime = +new Date();
|
currentTime = $.now();
|
||||||
deltaTime = currentTime - button.fadeBeginTime;
|
deltaTime = currentTime - button.fadeBeginTime;
|
||||||
opacity = 1.0 - deltaTime / button.fadeLength;
|
opacity = 1.0 - deltaTime / button.fadeLength;
|
||||||
opacity = Math.min( 1.0, opacity );
|
opacity = Math.min( 1.0, opacity );
|
||||||
@ -305,7 +305,7 @@ function updateFade( button ) {
|
|||||||
|
|
||||||
function beginFading( button ) {
|
function beginFading( button ) {
|
||||||
button.shouldFade = true;
|
button.shouldFade = true;
|
||||||
button.fadeBeginTime = +new Date() + button.fadeDelay;
|
button.fadeBeginTime = $.now() + button.fadeDelay;
|
||||||
window.setTimeout( function(){
|
window.setTimeout( function(){
|
||||||
scheduleFade( button );
|
scheduleFade( button );
|
||||||
}, button.fadeDelay );
|
}, button.fadeDelay );
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
i;
|
i;
|
||||||
|
|
||||||
$.extend( true, this, {
|
$.extend( true, this, {
|
||||||
id: 'controldock-'+(+new Date())+'-'+Math.floor(Math.random()*1000000),
|
id: 'controldock-'+$.now()+'-'+Math.floor(Math.random()*1000000),
|
||||||
container: $.makeNeutralElement('form'),
|
container: $.makeNeutralElement('form'),
|
||||||
controls: []
|
controls: []
|
||||||
}, options );
|
}, options );
|
||||||
|
@ -299,7 +299,7 @@ $.Drawer.prototype = {
|
|||||||
*/
|
*/
|
||||||
reset: function() {
|
reset: function() {
|
||||||
clearTiles( this );
|
clearTiles( this );
|
||||||
this.lastResetTime = +new Date();
|
this.lastResetTime = $.now();
|
||||||
this.updateAgain = true;
|
this.updateAgain = true;
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -456,7 +456,7 @@ function updateViewport( drawer ) {
|
|||||||
level,
|
level,
|
||||||
best = null,
|
best = null,
|
||||||
haveDrawn = false,
|
haveDrawn = false,
|
||||||
currentTime = +new Date(),
|
currentTime = $.now(),
|
||||||
viewportSize = drawer.viewport.getContainerSize(),
|
viewportSize = drawer.viewport.getContainerSize(),
|
||||||
viewportBounds = drawer.viewport.getBounds( true ),
|
viewportBounds = drawer.viewport.getBounds( true ),
|
||||||
viewportTL = viewportBounds.getTopLeft(),
|
viewportTL = viewportBounds.getTopLeft(),
|
||||||
|
@ -677,7 +677,7 @@
|
|||||||
|
|
||||||
delegate.lastPoint = getMouseAbsolute( event );
|
delegate.lastPoint = getMouseAbsolute( event );
|
||||||
delegate.lastMouseDownPoint = delegate.lastPoint;
|
delegate.lastMouseDownPoint = delegate.lastPoint;
|
||||||
delegate.lastMouseDownTime = +new Date();
|
delegate.lastMouseDownTime = $.now();
|
||||||
|
|
||||||
if ( tracker.pressHandler ) {
|
if ( tracker.pressHandler ) {
|
||||||
propagate = tracker.pressHandler(
|
propagate = tracker.pressHandler(
|
||||||
@ -920,7 +920,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var time = +new Date() - delegate.lastMouseDownTime,
|
var time = $.now() - delegate.lastMouseDownTime,
|
||||||
point = getMouseAbsolute( event ),
|
point = getMouseAbsolute( event ),
|
||||||
distance = delegate.lastMouseDownPoint.distanceTo( point ),
|
distance = delegate.lastMouseDownPoint.distanceTo( point ),
|
||||||
quick = time <= tracker.clickTimeThreshold &&
|
quick = time <= tracker.clickTimeThreshold &&
|
||||||
|
@ -57,7 +57,7 @@ $.Navigator = function( options ){
|
|||||||
//We may need to create a new element and id if they did not
|
//We may need to create a new element and id if they did not
|
||||||
//provide the id for the existing element
|
//provide the id for the existing element
|
||||||
if( !options.id ){
|
if( !options.id ){
|
||||||
options.id = 'navigator-' + (+new Date());
|
options.id = 'navigator-' + $.now();
|
||||||
this.element = $.makeNeutralElement( "div" );
|
this.element = $.makeNeutralElement( "div" );
|
||||||
options.controlOptions = {anchor: $.ControlAnchor.TOP_RIGHT,
|
options.controlOptions = {anchor: $.ControlAnchor.TOP_RIGHT,
|
||||||
attachToViewer: true,
|
attachToViewer: true,
|
||||||
|
@ -1386,7 +1386,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
head = document.head ||
|
head = document.head ||
|
||||||
document.getElementsByTagName( "head" )[ 0 ] ||
|
document.getElementsByTagName( "head" )[ 0 ] ||
|
||||||
document.documentElement,
|
document.documentElement,
|
||||||
jsonpCallback = options.callbackName || 'openseadragon' + (+new Date()),
|
jsonpCallback = options.callbackName || 'openseadragon' + $.now(),
|
||||||
previous = window[ jsonpCallback ],
|
previous = window[ jsonpCallback ],
|
||||||
replace = "$1" + jsonpCallback + "$2",
|
replace = "$1" + jsonpCallback + "$2",
|
||||||
callbackParam = options.param || 'callback',
|
callbackParam = options.param || 'callback',
|
||||||
@ -1700,7 +1700,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
if ( !iIntervalId ) {
|
if ( !iIntervalId ) {
|
||||||
iIntervalId = setInterval( function() {
|
iIntervalId = setInterval( function() {
|
||||||
if ( aAnimQueue.length ) {
|
if ( aAnimQueue.length ) {
|
||||||
var time = new Date().getTime();
|
var time = $.now();
|
||||||
// Process all of the currently outstanding frame
|
// Process all of the currently outstanding frame
|
||||||
// requests, but none that get added during the
|
// requests, but none that get added during the
|
||||||
// processing.
|
// processing.
|
||||||
|
@ -77,7 +77,7 @@ $.Profiler.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.midUpdate = true;
|
this.midUpdate = true;
|
||||||
this.lastBeginTime = new Date().getTime();
|
this.lastBeginTime = $.now();
|
||||||
|
|
||||||
if (this.numUpdates < 1) {
|
if (this.numUpdates < 1) {
|
||||||
return; // this is the first update
|
return; // this is the first update
|
||||||
@ -103,7 +103,7 @@ $.Profiler.prototype = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastEndTime = new Date().getTime();
|
this.lastEndTime = $.now();
|
||||||
this.midUpdate = false;
|
this.midUpdate = false;
|
||||||
|
|
||||||
var time = this.lastEndTime - this.lastBeginTime;
|
var time = this.lastEndTime - this.lastBeginTime;
|
||||||
|
@ -70,7 +70,7 @@ $.ReferenceStrip = function( options ){
|
|||||||
//We may need to create a new element and id if they did not
|
//We may need to create a new element and id if they did not
|
||||||
//provide the id for the existing element
|
//provide the id for the existing element
|
||||||
if( !options.id ){
|
if( !options.id ){
|
||||||
options.id = 'referencestrip-' + (+new Date());
|
options.id = 'referencestrip-' + $.now();
|
||||||
this.element = $.makeNeutralElement( "div" );
|
this.element = $.makeNeutralElement( "div" );
|
||||||
this.element.id = options.id;
|
this.element.id = options.id;
|
||||||
this.element.className = 'referencestrip';
|
this.element.className = 'referencestrip';
|
||||||
@ -192,12 +192,12 @@ $.ReferenceStrip = function( options ){
|
|||||||
clickTimeThreshold: this.clickTimeThreshold,
|
clickTimeThreshold: this.clickTimeThreshold,
|
||||||
clickDistThreshold: this.clickDistThreshold,
|
clickDistThreshold: this.clickDistThreshold,
|
||||||
pressHandler: function( tracker ){
|
pressHandler: function( tracker ){
|
||||||
tracker.dragging = +new Date();
|
tracker.dragging = $.now();
|
||||||
},
|
},
|
||||||
releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){
|
releaseHandler: function( tracker, position, insideElementPress, insideElementRelease ){
|
||||||
var id = tracker.element.id,
|
var id = tracker.element.id,
|
||||||
page = Number( id.split( '-' )[ 2 ] ),
|
page = Number( id.split( '-' )[ 2 ] ),
|
||||||
now = +new Date();
|
now = $.now();
|
||||||
|
|
||||||
if ( insideElementPress &&
|
if ( insideElementPress &&
|
||||||
insideElementRelease &&
|
insideElementRelease &&
|
||||||
|
@ -76,7 +76,7 @@ $.Spring = function( options ) {
|
|||||||
value: typeof ( this.initial ) == "number" ?
|
value: typeof ( this.initial ) == "number" ?
|
||||||
this.initial :
|
this.initial :
|
||||||
0,
|
0,
|
||||||
time: new Date().getTime() // always work in milliseconds
|
time: $.now() // always work in milliseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
this.start = {
|
this.start = {
|
||||||
@ -127,7 +127,7 @@ $.Spring.prototype = {
|
|||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
update: function() {
|
update: function() {
|
||||||
this.current.time = new Date().getTime();
|
this.current.time = $.now();
|
||||||
this.current.value = (this.current.time >= this.target.time) ?
|
this.current.value = (this.current.time >= this.target.time) ?
|
||||||
this.target.value :
|
this.target.value :
|
||||||
this.start.value +
|
this.start.value +
|
||||||
|
@ -1263,7 +1263,7 @@ function beginControlsAutoHide( viewer ) {
|
|||||||
}
|
}
|
||||||
viewer.controlsShouldFade = true;
|
viewer.controlsShouldFade = true;
|
||||||
viewer.controlsFadeBeginTime =
|
viewer.controlsFadeBeginTime =
|
||||||
+new Date() +
|
$.now() +
|
||||||
viewer.controlsFadeDelay;
|
viewer.controlsFadeDelay;
|
||||||
|
|
||||||
window.setTimeout( function(){
|
window.setTimeout( function(){
|
||||||
@ -1279,7 +1279,7 @@ function updateControlsFade( viewer ) {
|
|||||||
opacity,
|
opacity,
|
||||||
i;
|
i;
|
||||||
if ( viewer.controlsShouldFade ) {
|
if ( viewer.controlsShouldFade ) {
|
||||||
currentTime = new Date().getTime();
|
currentTime = $.now();
|
||||||
deltaTime = currentTime - viewer.controlsFadeBeginTime;
|
deltaTime = currentTime - viewer.controlsFadeBeginTime;
|
||||||
opacity = 1.0 - deltaTime / viewer.controlsFadeLength;
|
opacity = 1.0 - deltaTime / viewer.controlsFadeLength;
|
||||||
|
|
||||||
@ -1528,7 +1528,7 @@ function resolveUrl( prefix, url ) {
|
|||||||
|
|
||||||
|
|
||||||
function beginZoomingIn() {
|
function beginZoomingIn() {
|
||||||
THIS[ this.hash ].lastZoomTime = +new Date();
|
THIS[ this.hash ].lastZoomTime = $.now();
|
||||||
THIS[ this.hash ].zoomFactor = this.zoomPerSecond;
|
THIS[ this.hash ].zoomFactor = this.zoomPerSecond;
|
||||||
THIS[ this.hash ].zooming = true;
|
THIS[ this.hash ].zooming = true;
|
||||||
scheduleZoom( this );
|
scheduleZoom( this );
|
||||||
@ -1536,7 +1536,7 @@ function beginZoomingIn() {
|
|||||||
|
|
||||||
|
|
||||||
function beginZoomingOut() {
|
function beginZoomingOut() {
|
||||||
THIS[ this.hash ].lastZoomTime = +new Date();
|
THIS[ this.hash ].lastZoomTime = $.now();
|
||||||
THIS[ this.hash ].zoomFactor = 1.0 / this.zoomPerSecond;
|
THIS[ this.hash ].zoomFactor = 1.0 / this.zoomPerSecond;
|
||||||
THIS[ this.hash ].zooming = true;
|
THIS[ this.hash ].zooming = true;
|
||||||
scheduleZoom( this );
|
scheduleZoom( this );
|
||||||
@ -1559,7 +1559,7 @@ function doZoom() {
|
|||||||
adjustFactor;
|
adjustFactor;
|
||||||
|
|
||||||
if ( THIS[ this.hash ].zooming && this.viewport) {
|
if ( THIS[ this.hash ].zooming && this.viewport) {
|
||||||
currentTime = +new Date();
|
currentTime = $.now();
|
||||||
deltaTime = currentTime - THIS[ this.hash ].lastZoomTime;
|
deltaTime = currentTime - THIS[ this.hash ].lastZoomTime;
|
||||||
adjustedFactor = Math.pow( THIS[ this.hash ].zoomFactor, deltaTime / 1000 );
|
adjustedFactor = Math.pow( THIS[ this.hash ].zoomFactor, deltaTime / 1000 );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user