mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Event Handler Signatures Changed to 'fn(event)'
All event handler signatures changed to 'fn(event)' eventSource property added to the event object passed Redundant event source properties removed ('button' and 'viewer' Documentation updated in MouseTracker changelog.txt updated
This commit is contained in:
parent
b72ce46b8d
commit
d574700b3d
@ -3,8 +3,12 @@ OPENSEADRAGON CHANGELOG
|
|||||||
|
|
||||||
1.0.0: (in progress)
|
1.0.0: (in progress)
|
||||||
|
|
||||||
|
* BREAKING CHANGE: All EventSource and MouseTracker event handler method signatures changed to 'handlerMethod(event)' where event == { eventSource, userData, ... } (#251) (Also fixes #23, #224, #239)
|
||||||
|
* The new eventSource property in the event object replaces the old eventSource parameter that was passed to handler methods.
|
||||||
|
* Where the event object duplicated the eventSource value, those properties have been removed. This effects the following events:
|
||||||
|
* All Button events - 'button' property removed
|
||||||
|
* All Viewer (Viewer, Drawer, Viewport) events - 'viewer' property removed
|
||||||
* BREAKING CHANGE: Renamed EventHandler to EventSource (#225)
|
* BREAKING CHANGE: Renamed EventHandler to EventSource (#225)
|
||||||
* BREAKING CHANGE: MouseTracker event handler method signatures changed to 'handlerMethod( tracker, eventData)' (#23)
|
|
||||||
* BREAKING CHANGE: Event names changed for consistency: changed to lower case, compound names hyphenated, and "on" prefixes removed (#226):
|
* BREAKING CHANGE: Event names changed for consistency: changed to lower case, compound names hyphenated, and "on" prefixes removed (#226):
|
||||||
* Viewer "animationstart" changed to "animation-start"
|
* Viewer "animationstart" changed to "animation-start"
|
||||||
* Viewer "animationfinish" changed to "animation-finish"
|
* Viewer "animationfinish" changed to "animation-finish"
|
||||||
@ -15,8 +19,6 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Button "onExit" changed to "exit"
|
* Button "onExit" changed to "exit"
|
||||||
* Button "onFocus" changed to "focus"
|
* Button "onFocus" changed to "focus"
|
||||||
* Button "onBlur" changed to "blur"
|
* Button "onBlur" changed to "blur"
|
||||||
* BREAKING CHANGE: Button event handler method signatures changed to 'handlerMethod( eventSource, eventData)' where eventData == { button } (#224)
|
|
||||||
* BREAKING CHANGE: TileSource 'ready' event handler signature changed to 'handlerMethod( eventSource, eventData)' where eventData == { tileSource } (#239)
|
|
||||||
* MouseTracker now passes the original event objects to its handler methods (#23)
|
* MouseTracker now passes the original event objects to its handler methods (#23)
|
||||||
* MouseTracker now supports an optional 'moveHandler' method for tracking mousemove events (#215)
|
* MouseTracker now supports an optional 'moveHandler' method for tracking mousemove events (#215)
|
||||||
* Fixed: Element-relative mouse coordinates now correct if the element and/or page is scrolled (using new OpenSeadragon.getElementOffset() method) (#131)
|
* Fixed: Element-relative mouse coordinates now correct if the element and/or page is scrolled (using new OpenSeadragon.getElementOffset() method) (#131)
|
||||||
|
@ -175,59 +175,59 @@ $.Button = function( options ) {
|
|||||||
clickTimeThreshold: this.clickTimeThreshold,
|
clickTimeThreshold: this.clickTimeThreshold,
|
||||||
clickDistThreshold: this.clickDistThreshold,
|
clickDistThreshold: this.clickDistThreshold,
|
||||||
|
|
||||||
enterHandler: function( tracker, eventData ) {
|
enterHandler: function( event ) {
|
||||||
if ( eventData.insideElementPressed ) {
|
if ( event.insideElementPressed ) {
|
||||||
inTo( _this, $.ButtonState.DOWN );
|
inTo( _this, $.ButtonState.DOWN );
|
||||||
_this.raiseEvent( "enter", { button: _this } );
|
_this.raiseEvent( "enter", {} );
|
||||||
} else if ( !eventData.buttonDownAny ) {
|
} else if ( !event.buttonDownAny ) {
|
||||||
inTo( _this, $.ButtonState.HOVER );
|
inTo( _this, $.ButtonState.HOVER );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
focusHandler: function ( tracker, eventData ) {
|
focusHandler: function ( event ) {
|
||||||
this.enterHandler( tracker, eventData );
|
this.enterHandler( event );
|
||||||
_this.raiseEvent( "focus", { button: _this } );
|
_this.raiseEvent( "focus", {} );
|
||||||
},
|
},
|
||||||
|
|
||||||
exitHandler: function( tracker, eventData ) {
|
exitHandler: function( event ) {
|
||||||
outTo( _this, $.ButtonState.GROUP );
|
outTo( _this, $.ButtonState.GROUP );
|
||||||
if ( eventData.insideElementPressed ) {
|
if ( event.insideElementPressed ) {
|
||||||
_this.raiseEvent( "exit", { button: _this } );
|
_this.raiseEvent( "exit", {} );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
blurHandler: function ( tracker, eventData ) {
|
blurHandler: function ( event ) {
|
||||||
this.exitHandler( tracker, eventData );
|
this.exitHandler( event );
|
||||||
_this.raiseEvent( "blur", { button: _this } );
|
_this.raiseEvent( "blur", {} );
|
||||||
},
|
},
|
||||||
|
|
||||||
pressHandler: function ( tracker, eventData ) {
|
pressHandler: function ( event ) {
|
||||||
inTo( _this, $.ButtonState.DOWN );
|
inTo( _this, $.ButtonState.DOWN );
|
||||||
_this.raiseEvent( "press", { button: _this } );
|
_this.raiseEvent( "press", {} );
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseHandler: function( tracker, eventData ) {
|
releaseHandler: function( event ) {
|
||||||
if ( eventData.insideElementPressed && eventData.insideElementReleased ) {
|
if ( event.insideElementPressed && event.insideElementReleased ) {
|
||||||
outTo( _this, $.ButtonState.HOVER );
|
outTo( _this, $.ButtonState.HOVER );
|
||||||
_this.raiseEvent( "release", { button: _this } );
|
_this.raiseEvent( "release", {} );
|
||||||
} else if ( eventData.insideElementPressed ) {
|
} else if ( event.insideElementPressed ) {
|
||||||
outTo( _this, $.ButtonState.GROUP );
|
outTo( _this, $.ButtonState.GROUP );
|
||||||
} else {
|
} else {
|
||||||
inTo( _this, $.ButtonState.HOVER );
|
inTo( _this, $.ButtonState.HOVER );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clickHandler: function( tracker, eventData ) {
|
clickHandler: function( event ) {
|
||||||
if ( eventData.quick ) {
|
if ( event.quick ) {
|
||||||
_this.raiseEvent("click", { button: _this });
|
_this.raiseEvent("click", {});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
keyHandler: function( tracker, eventData ){
|
keyHandler: function( event ){
|
||||||
//console.log( "%s : handling key %s!", _this.tooltip, eventData.keyCode);
|
//console.log( "%s : handling key %s!", _this.tooltip, event.keyCode);
|
||||||
if( 13 === eventData.keyCode ){
|
if( 13 === event.keyCode ){
|
||||||
_this.raiseEvent( "click", { button: _this } );
|
_this.raiseEvent( "click", {} );
|
||||||
_this.raiseEvent( "release", { button: _this } );
|
_this.raiseEvent( "release", {} );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -85,23 +85,23 @@ $.ButtonGroup = function( options ) {
|
|||||||
element: this.element,
|
element: this.element,
|
||||||
clickTimeThreshold: this.clickTimeThreshold,
|
clickTimeThreshold: this.clickTimeThreshold,
|
||||||
clickDistThreshold: this.clickDistThreshold,
|
clickDistThreshold: this.clickDistThreshold,
|
||||||
enterHandler: function ( tracker, eventData ) {
|
enterHandler: function ( event ) {
|
||||||
var i;
|
var i;
|
||||||
for ( i = 0; i < _this.buttons.length; i++ ) {
|
for ( i = 0; i < _this.buttons.length; i++ ) {
|
||||||
_this.buttons[ i ].notifyGroupEnter();
|
_this.buttons[ i ].notifyGroupEnter();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
exitHandler: function ( tracker, eventData ) {
|
exitHandler: function ( event ) {
|
||||||
var i;
|
var i;
|
||||||
if ( !eventData.insideElementPressed ) {
|
if ( !event.insideElementPressed ) {
|
||||||
for ( i = 0; i < _this.buttons.length; i++ ) {
|
for ( i = 0; i < _this.buttons.length; i++ ) {
|
||||||
_this.buttons[ i ].notifyGroupExit();
|
_this.buttons[ i ].notifyGroupExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
releaseHandler: function ( tracker, eventData ) {
|
releaseHandler: function ( event ) {
|
||||||
var i;
|
var i;
|
||||||
if ( !eventData.insideElementReleased ) {
|
if ( !event.insideElementReleased ) {
|
||||||
for ( i = 0; i < _this.buttons.length; i++ ) {
|
for ( i = 0; i < _this.buttons.length; i++ ) {
|
||||||
_this.buttons[ i ].notifyGroupExit();
|
_this.buttons[ i ].notifyGroupExit();
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ $.ButtonGroup.prototype = {
|
|||||||
* @name OpenSeadragon.ButtonGroup.prototype.emulateEnter
|
* @name OpenSeadragon.ButtonGroup.prototype.emulateEnter
|
||||||
*/
|
*/
|
||||||
emulateEnter: function() {
|
emulateEnter: function() {
|
||||||
this.tracker.enterHandler( this.tracker, {} );
|
this.tracker.enterHandler( { eventSource: this.tracker } );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +129,7 @@ $.ButtonGroup.prototype = {
|
|||||||
* @name OpenSeadragon.ButtonGroup.prototype.emulateExit
|
* @name OpenSeadragon.ButtonGroup.prototype.emulateExit
|
||||||
*/
|
*/
|
||||||
emulateExit: function() {
|
emulateExit: function() {
|
||||||
this.tracker.exitHandler( this.tracker, {} );
|
this.tracker.exitHandler( { eventSource: this.tracker } );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,7 +205,6 @@ $.Drawer.prototype = {
|
|||||||
this.updateAgain = true;
|
this.updateAgain = true;
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'add-overlay', {
|
this.viewer.raiseEvent( 'add-overlay', {
|
||||||
viewer: this.viewer,
|
|
||||||
element: element,
|
element: element,
|
||||||
location: options.location,
|
location: options.location,
|
||||||
placement: options.placement
|
placement: options.placement
|
||||||
@ -237,7 +236,6 @@ $.Drawer.prototype = {
|
|||||||
}
|
}
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'update-overlay', {
|
this.viewer.raiseEvent( 'update-overlay', {
|
||||||
viewer: this.viewer,
|
|
||||||
element: element,
|
element: element,
|
||||||
location: location,
|
location: location,
|
||||||
placement: placement
|
placement: placement
|
||||||
@ -267,7 +265,6 @@ $.Drawer.prototype = {
|
|||||||
}
|
}
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'remove-overlay', {
|
this.viewer.raiseEvent( 'remove-overlay', {
|
||||||
viewer: this.viewer,
|
|
||||||
element: element
|
element: element
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -286,9 +283,7 @@ $.Drawer.prototype = {
|
|||||||
this.updateAgain = true;
|
this.updateAgain = true;
|
||||||
}
|
}
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'clear-overlay', {
|
this.viewer.raiseEvent( 'clear-overlay', {} );
|
||||||
viewer: this.viewer
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -481,9 +476,7 @@ function updateViewport( drawer ) {
|
|||||||
drawer.updateAgain = false;
|
drawer.updateAgain = false;
|
||||||
|
|
||||||
if( drawer.viewer ){
|
if( drawer.viewer ){
|
||||||
drawer.viewer.raiseEvent( 'update-viewport', {
|
drawer.viewer.raiseEvent( 'update-viewport', {} );
|
||||||
viewer: drawer.viewer
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var tile,
|
var tile,
|
||||||
@ -658,7 +651,6 @@ function updateLevel( drawer, haveDrawn, drawLevel, level, levelOpacity, levelVi
|
|||||||
|
|
||||||
if( drawer.viewer ){
|
if( drawer.viewer ){
|
||||||
drawer.viewer.raiseEvent( 'update-level', {
|
drawer.viewer.raiseEvent( 'update-level', {
|
||||||
viewer: drawer.viewer,
|
|
||||||
havedrawn: haveDrawn,
|
havedrawn: haveDrawn,
|
||||||
level: level,
|
level: level,
|
||||||
opacity: levelOpacity,
|
opacity: levelOpacity,
|
||||||
@ -722,7 +714,6 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le
|
|||||||
|
|
||||||
if( drawer.viewer ){
|
if( drawer.viewer ){
|
||||||
drawer.viewer.raiseEvent( 'update-tile', {
|
drawer.viewer.raiseEvent( 'update-tile', {
|
||||||
viewer: drawer.viewer,
|
|
||||||
tile: tile
|
tile: tile
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1236,7 +1227,6 @@ function drawTiles( drawer, lastDrawn ){
|
|||||||
|
|
||||||
if( drawer.viewer ){
|
if( drawer.viewer ){
|
||||||
drawer.viewer.raiseEvent( 'tile-drawn', {
|
drawer.viewer.raiseEvent( 'tile-drawn', {
|
||||||
viewer: drawer.viewer,
|
|
||||||
tile: tile
|
tile: tile
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -121,8 +121,9 @@ $.EventSource.prototype = {
|
|||||||
length = events.length;
|
length = events.length;
|
||||||
for ( i = 0; i < length; i++ ) {
|
for ( i = 0; i < length; i++ ) {
|
||||||
if ( events[ i ] ) {
|
if ( events[ i ] ) {
|
||||||
|
args.eventSource = source;
|
||||||
args.userData = events[ i ].userData;
|
args.userData = events[ i ].userData;
|
||||||
events[ i ].handler( source, args );
|
events[ i ].handler( args );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -222,21 +222,21 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Boolean} eventData.insideElementPressed
|
* @param {Boolean} event.insideElementPressed
|
||||||
* True if the left mouse button is currently being pressed and was
|
* True if the left mouse button is currently being pressed and was
|
||||||
* initiated inside the tracked element, otherwise false.
|
* initiated inside the tracked element, otherwise false.
|
||||||
* @param {Boolean} eventData.buttonDownAny
|
* @param {Boolean} event.buttonDownAny
|
||||||
* Was the button down anywhere in the screen during the event.
|
* Was the button down anywhere in the screen during the event.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
enterHandler: function () { },
|
enterHandler: function () { },
|
||||||
@ -245,21 +245,21 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Boolean} eventData.insideElementPressed
|
* @param {Boolean} event.insideElementPressed
|
||||||
* True if the left mouse button is currently being pressed and was
|
* True if the left mouse button is currently being pressed and was
|
||||||
* initiated inside the tracked element, otherwise false.
|
* initiated inside the tracked element, otherwise false.
|
||||||
* @param {Boolean} eventData.buttonDownAny
|
* @param {Boolean} event.buttonDownAny
|
||||||
* Was the button down anywhere in the screen during the event.
|
* Was the button down anywhere in the screen during the event.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
exitHandler: function () { },
|
exitHandler: function () { },
|
||||||
@ -268,16 +268,16 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
pressHandler: function () { },
|
pressHandler: function () { },
|
||||||
@ -286,21 +286,21 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Boolean} eventData.insideElementPressed
|
* @param {Boolean} event.insideElementPressed
|
||||||
* True if the left mouse button is currently being pressed and was
|
* True if the left mouse button is currently being pressed and was
|
||||||
* initiated inside the tracked element, otherwise false.
|
* initiated inside the tracked element, otherwise false.
|
||||||
* @param {Boolean} eventData.insideElementReleased
|
* @param {Boolean} event.insideElementReleased
|
||||||
* True if the cursor still inside the tracked element when the button was released.
|
* True if the cursor still inside the tracked element when the button was released.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
releaseHandler: function () { },
|
releaseHandler: function () { },
|
||||||
@ -309,16 +309,16 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
moveHandler: function () { },
|
moveHandler: function () { },
|
||||||
@ -327,20 +327,20 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Number} eventData.scroll
|
* @param {Number} event.scroll
|
||||||
* The scroll delta for the event.
|
* The scroll delta for the event.
|
||||||
* @param {Boolean} eventData.shift
|
* @param {Boolean} event.shift
|
||||||
* True if the shift key was pressed during this event.
|
* True if the shift key was pressed during this event.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
scrollHandler: function () { },
|
scrollHandler: function () { },
|
||||||
@ -349,20 +349,20 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Number} eventData.quick
|
* @param {Number} event.quick
|
||||||
* True only if the clickDistThreshold and clickDeltaThreshold are both pased. Useful for ignoring events.
|
* True only if the clickDistThreshold and clickDeltaThreshold are both pased. Useful for ignoring events.
|
||||||
* @param {Boolean} eventData.shift
|
* @param {Boolean} event.shift
|
||||||
* True if the shift key was pressed during this event.
|
* True if the shift key was pressed during this event.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
clickHandler: function () { },
|
clickHandler: function () { },
|
||||||
@ -371,20 +371,20 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {OpenSeadragon.Point} event.position
|
||||||
* @param {OpenSeadragon.Point} eventData.position
|
|
||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {OpenSeadragon.Point} eventData.delta
|
* @param {OpenSeadragon.Point} event.delta
|
||||||
* The x,y components of the difference between start drag and end drag. Usefule for ignoring or weighting the events.
|
* The x,y components of the difference between start drag and end drag. Usefule for ignoring or weighting the events.
|
||||||
* @param {Boolean} eventData.shift
|
* @param {Boolean} event.shift
|
||||||
* True if the shift key was pressed during this event.
|
* True if the shift key was pressed during this event.
|
||||||
* @param {Boolean} eventData.isTouchEvent
|
* @param {Boolean} event.isTouchEvent
|
||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
dragHandler: function () { },
|
dragHandler: function () { },
|
||||||
@ -393,16 +393,16 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {Number} event.keyCode
|
||||||
* @param {Number} eventData.keyCode
|
|
||||||
* The key code that was pressed.
|
* The key code that was pressed.
|
||||||
* @param {Boolean} eventData.shift
|
* @param {Boolean} event.shift
|
||||||
* True if the shift key was pressed during this event.
|
* True if the shift key was pressed during this event.
|
||||||
* @param {Object} eventData.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
keyHandler: function () { },
|
keyHandler: function () { },
|
||||||
@ -411,12 +411,12 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {Object} event.originalEvent
|
||||||
* @param {Object} eventData.originalEvent
|
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
focusHandler: function () { },
|
focusHandler: function () { },
|
||||||
@ -425,12 +425,12 @@
|
|||||||
* Implement or assign implmentation to these handlers during or after
|
* Implement or assign implmentation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.MouseTracker} tracker
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} eventData
|
* @param {Object} event.originalEvent
|
||||||
* @param {Object} eventData.originalEvent
|
|
||||||
* The original event object.
|
* The original event object.
|
||||||
* @param {Object} eventData.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
blurHandler: function () { }
|
blurHandler: function () { }
|
||||||
@ -629,8 +629,8 @@
|
|||||||
var propagate;
|
var propagate;
|
||||||
if ( tracker.focusHandler ) {
|
if ( tracker.focusHandler ) {
|
||||||
propagate = tracker.focusHandler(
|
propagate = tracker.focusHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
@ -651,8 +651,8 @@
|
|||||||
var propagate;
|
var propagate;
|
||||||
if ( tracker.blurHandler ) {
|
if ( tracker.blurHandler ) {
|
||||||
propagate = tracker.blurHandler(
|
propagate = tracker.blurHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
@ -673,8 +673,8 @@
|
|||||||
var propagate;
|
var propagate;
|
||||||
if ( tracker.keyHandler ) {
|
if ( tracker.keyHandler ) {
|
||||||
propagate = tracker.keyHandler(
|
propagate = tracker.keyHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( event, tracker.element ),
|
||||||
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
@ -728,8 +728,8 @@
|
|||||||
|
|
||||||
if ( tracker.enterHandler ) {
|
if ( tracker.enterHandler ) {
|
||||||
propagate = tracker.enterHandler(
|
propagate = tracker.enterHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
||||||
insideElementPressed: delegate.insideElementPressed,
|
insideElementPressed: delegate.insideElementPressed,
|
||||||
buttonDownAny: IS_BUTTON_DOWN,
|
buttonDownAny: IS_BUTTON_DOWN,
|
||||||
@ -784,8 +784,8 @@
|
|||||||
|
|
||||||
if ( tracker.exitHandler ) {
|
if ( tracker.exitHandler ) {
|
||||||
propagate = tracker.exitHandler(
|
propagate = tracker.exitHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
||||||
insideElementPressed: delegate.insideElementPressed,
|
insideElementPressed: delegate.insideElementPressed,
|
||||||
buttonDownAny: IS_BUTTON_DOWN,
|
buttonDownAny: IS_BUTTON_DOWN,
|
||||||
@ -828,8 +828,8 @@
|
|||||||
|
|
||||||
if ( tracker.pressHandler ) {
|
if ( tracker.pressHandler ) {
|
||||||
propagate = tracker.pressHandler(
|
propagate = tracker.pressHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
@ -923,8 +923,8 @@
|
|||||||
|
|
||||||
if ( tracker.releaseHandler ) {
|
if ( tracker.releaseHandler ) {
|
||||||
propagate = tracker.releaseHandler(
|
propagate = tracker.releaseHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
||||||
insideElementPressed: insideElementPressed,
|
insideElementPressed: insideElementPressed,
|
||||||
insideElementReleased: insideElementReleased,
|
insideElementReleased: insideElementReleased,
|
||||||
@ -1041,8 +1041,8 @@
|
|||||||
event = $.getEvent( event );
|
event = $.getEvent( event );
|
||||||
|
|
||||||
var propagate = tracker.moveHandler(
|
var propagate = tracker.moveHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( event, tracker.element ),
|
||||||
isTouchEvent: false,
|
isTouchEvent: false,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
@ -1096,8 +1096,8 @@
|
|||||||
|
|
||||||
if ( tracker.scrollHandler ) {
|
if ( tracker.scrollHandler ) {
|
||||||
propagate = tracker.scrollHandler(
|
propagate = tracker.scrollHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
// Note: Ok to call getMouseRelative on passed event for isTouch==true since
|
// Note: Ok to call getMouseRelative on passed event for isTouch==true since
|
||||||
// event.pageX/event.pageY are added to the original touchmove event in
|
// event.pageX/event.pageY are added to the original touchmove event in
|
||||||
// onTouchMove().
|
// onTouchMove().
|
||||||
@ -1142,8 +1142,8 @@
|
|||||||
|
|
||||||
if ( tracker.clickHandler ) {
|
if ( tracker.clickHandler ) {
|
||||||
propagate = tracker.clickHandler(
|
propagate = tracker.clickHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
||||||
quick: quick,
|
quick: quick,
|
||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
@ -1180,8 +1180,8 @@
|
|||||||
|
|
||||||
if ( tracker.dragHandler ) {
|
if ( tracker.dragHandler ) {
|
||||||
propagate = tracker.dragHandler(
|
propagate = tracker.dragHandler(
|
||||||
tracker,
|
|
||||||
{
|
{
|
||||||
|
eventSource: tracker,
|
||||||
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
||||||
delta: delta,
|
delta: delta,
|
||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
|
@ -251,13 +251,13 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onCanvasClick( tracker, eventData ) {
|
function onCanvasClick( event ) {
|
||||||
var newBounds,
|
var newBounds,
|
||||||
viewerPosition,
|
viewerPosition,
|
||||||
dimensions;
|
dimensions;
|
||||||
if (! this.drag) {
|
if (! this.drag) {
|
||||||
if ( this.viewer.viewport ) {
|
if ( this.viewer.viewport ) {
|
||||||
viewerPosition = this.viewport.deltaPointsFromPixels( eventData.position );
|
viewerPosition = this.viewport.deltaPointsFromPixels( event.position );
|
||||||
dimensions = this.viewer.viewport.getBounds().getSize();
|
dimensions = this.viewer.viewport.getBounds().getSize();
|
||||||
newBounds = new $.Rect(
|
newBounds = new $.Rect(
|
||||||
viewerPosition.x - dimensions.x/2,
|
viewerPosition.x - dimensions.x/2,
|
||||||
@ -285,18 +285,18 @@ function onCanvasClick( tracker, eventData ) {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onCanvasDrag( tracker, eventData ) {
|
function onCanvasDrag( event ) {
|
||||||
if ( this.viewer.viewport ) {
|
if ( this.viewer.viewport ) {
|
||||||
this.drag = true;
|
this.drag = true;
|
||||||
if( !this.panHorizontal ){
|
if( !this.panHorizontal ){
|
||||||
eventData.delta.x = 0;
|
event.delta.x = 0;
|
||||||
}
|
}
|
||||||
if( !this.panVertical ){
|
if( !this.panVertical ){
|
||||||
eventData.delta.y = 0;
|
event.delta.y = 0;
|
||||||
}
|
}
|
||||||
this.viewer.viewport.panBy(
|
this.viewer.viewport.panBy(
|
||||||
this.viewport.deltaPointsFromPixels(
|
this.viewport.deltaPointsFromPixels(
|
||||||
eventData.delta
|
event.delta
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -308,8 +308,8 @@ function onCanvasDrag( tracker, eventData ) {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onCanvasRelease( tracker, eventData ) {
|
function onCanvasRelease( event ) {
|
||||||
if ( eventData.insideElementPressed && this.viewer.viewport ) {
|
if ( event.insideElementPressed && this.viewer.viewport ) {
|
||||||
this.viewer.viewport.applyConstraints();
|
this.viewer.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,10 +320,10 @@ function onCanvasRelease( tracker, eventData ) {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onCanvasScroll( tracker, position, scroll, shift ) {
|
function onCanvasScroll( event ) {
|
||||||
var factor;
|
var factor;
|
||||||
if ( this.viewer.viewport ) {
|
if ( this.viewer.viewport ) {
|
||||||
factor = Math.pow( this.zoomPerScroll, scroll );
|
factor = Math.pow( this.zoomPerScroll, event.scroll );
|
||||||
this.viewer.viewport.zoomBy(
|
this.viewer.viewport.zoomBy(
|
||||||
factor,
|
factor,
|
||||||
this.viewport.getCenter()
|
this.viewport.getCenter()
|
||||||
|
@ -189,19 +189,19 @@ $.ReferenceStrip = function ( options ) {
|
|||||||
element: element,
|
element: element,
|
||||||
clickTimeThreshold: this.clickTimeThreshold,
|
clickTimeThreshold: this.clickTimeThreshold,
|
||||||
clickDistThreshold: this.clickDistThreshold,
|
clickDistThreshold: this.clickDistThreshold,
|
||||||
pressHandler: function ( tracker, eventData ) {
|
pressHandler: function ( event ) {
|
||||||
tracker.dragging = $.now();
|
event.eventSource.dragging = $.now();
|
||||||
},
|
},
|
||||||
releaseHandler: function ( tracker, eventData ) {
|
releaseHandler: function ( event ) {
|
||||||
var id = tracker.element.id,
|
var id = event.eventSource.element.id,
|
||||||
page = Number( id.split( '-' )[2] ),
|
page = Number( id.split( '-' )[2] ),
|
||||||
now = $.now();
|
now = $.now();
|
||||||
|
|
||||||
if ( eventData.insideElementPressed &&
|
if ( event.insideElementPressed &&
|
||||||
eventData.insideElementReleased &&
|
event.insideElementReleased &&
|
||||||
tracker.dragging &&
|
event.eventSource.dragging &&
|
||||||
( now - tracker.dragging ) < tracker.clickTimeThreshold ) {
|
( now - event.eventSource.dragging ) < event.eventSource.clickTimeThreshold ) {
|
||||||
tracker.dragging = null;
|
event.eventSource.dragging = null;
|
||||||
viewer.goToPage( page );
|
viewer.goToPage( page );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ $.extend( $.ReferenceStrip.prototype, $.EventSource.prototype, $.Viewer.prototyp
|
|||||||
|
|
||||||
this.currentPage = page;
|
this.currentPage = page;
|
||||||
$.getElement( element.id + '-displayregion' ).focus();
|
$.getElement( element.id + '-displayregion' ).focus();
|
||||||
onStripEnter.call( this, this.innerTracker, {} );
|
onStripEnter.call( this, { eventSource: this.innerTracker } );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@ -289,7 +289,7 @@ $.extend( $.ReferenceStrip.prototype, $.EventSource.prototype, $.Viewer.prototyp
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onStripDrag( tracker, eventData ) {
|
function onStripDrag( event ) {
|
||||||
|
|
||||||
var offsetLeft = Number( this.element.style.marginLeft.replace( 'px', '' ) ),
|
var offsetLeft = Number( this.element.style.marginLeft.replace( 'px', '' ) ),
|
||||||
offsetTop = Number( this.element.style.marginTop.replace( 'px', '' ) ),
|
offsetTop = Number( this.element.style.marginTop.replace( 'px', '' ) ),
|
||||||
@ -299,31 +299,31 @@ function onStripDrag( tracker, eventData ) {
|
|||||||
this.dragging = true;
|
this.dragging = true;
|
||||||
if ( this.element ) {
|
if ( this.element ) {
|
||||||
if ( 'horizontal' == this.scroll ) {
|
if ( 'horizontal' == this.scroll ) {
|
||||||
if ( -eventData.delta.x > 0 ) {
|
if ( -event.delta.x > 0 ) {
|
||||||
//forward
|
//forward
|
||||||
if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) {
|
if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) {
|
||||||
this.element.style.marginLeft = ( offsetLeft + ( eventData.delta.x * 2 ) ) + 'px';
|
this.element.style.marginLeft = ( offsetLeft + ( event.delta.x * 2 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.x, offsetLeft + ( eventData.delta.x * 2 ) );
|
loadPanels( this, viewerSize.x, offsetLeft + ( event.delta.x * 2 ) );
|
||||||
}
|
}
|
||||||
} else if ( -eventData.delta.x < 0 ) {
|
} else if ( -event.delta.x < 0 ) {
|
||||||
//reverse
|
//reverse
|
||||||
if ( offsetLeft < 0 ) {
|
if ( offsetLeft < 0 ) {
|
||||||
this.element.style.marginLeft = ( offsetLeft + ( eventData.delta.x * 2 ) ) + 'px';
|
this.element.style.marginLeft = ( offsetLeft + ( event.delta.x * 2 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.x, offsetLeft + ( eventData.delta.x * 2 ) );
|
loadPanels( this, viewerSize.x, offsetLeft + ( event.delta.x * 2 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( -eventData.delta.y > 0 ) {
|
if ( -event.delta.y > 0 ) {
|
||||||
//forward
|
//forward
|
||||||
if ( offsetTop > -( scrollHeight - viewerSize.y ) ) {
|
if ( offsetTop > -( scrollHeight - viewerSize.y ) ) {
|
||||||
this.element.style.marginTop = ( offsetTop + ( eventData.delta.y * 2 ) ) + 'px';
|
this.element.style.marginTop = ( offsetTop + ( event.delta.y * 2 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.y, offsetTop + ( eventData.delta.y * 2 ) );
|
loadPanels( this, viewerSize.y, offsetTop + ( event.delta.y * 2 ) );
|
||||||
}
|
}
|
||||||
} else if ( -eventData.delta.y < 0 ) {
|
} else if ( -event.delta.y < 0 ) {
|
||||||
//reverse
|
//reverse
|
||||||
if ( offsetTop < 0 ) {
|
if ( offsetTop < 0 ) {
|
||||||
this.element.style.marginTop = ( offsetTop + ( eventData.delta.y * 2 ) ) + 'px';
|
this.element.style.marginTop = ( offsetTop + ( event.delta.y * 2 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.y, offsetTop + ( eventData.delta.y * 2 ) );
|
loadPanels( this, viewerSize.y, offsetTop + ( event.delta.y * 2 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ function onStripDrag( tracker, eventData ) {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onStripScroll( tracker, eventData ) {
|
function onStripScroll( event ) {
|
||||||
var offsetLeft = Number( this.element.style.marginLeft.replace( 'px', '' ) ),
|
var offsetLeft = Number( this.element.style.marginLeft.replace( 'px', '' ) ),
|
||||||
offsetTop = Number( this.element.style.marginTop.replace( 'px', '' ) ),
|
offsetTop = Number( this.element.style.marginTop.replace( 'px', '' ) ),
|
||||||
scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ),
|
scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ),
|
||||||
@ -347,31 +347,31 @@ function onStripScroll( tracker, eventData ) {
|
|||||||
viewerSize = $.getElementSize( this.viewer.canvas );
|
viewerSize = $.getElementSize( this.viewer.canvas );
|
||||||
if ( this.element ) {
|
if ( this.element ) {
|
||||||
if ( 'horizontal' == this.scroll ) {
|
if ( 'horizontal' == this.scroll ) {
|
||||||
if ( eventData.scroll > 0 ) {
|
if ( event.scroll > 0 ) {
|
||||||
//forward
|
//forward
|
||||||
if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) {
|
if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) {
|
||||||
this.element.style.marginLeft = ( offsetLeft - ( eventData.scroll * 60 ) ) + 'px';
|
this.element.style.marginLeft = ( offsetLeft - ( event.scroll * 60 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.x, offsetLeft - ( eventData.scroll * 60 ) );
|
loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 60 ) );
|
||||||
}
|
}
|
||||||
} else if ( eventData.scroll < 0 ) {
|
} else if ( event.scroll < 0 ) {
|
||||||
//reverse
|
//reverse
|
||||||
if ( offsetLeft < 0 ) {
|
if ( offsetLeft < 0 ) {
|
||||||
this.element.style.marginLeft = ( offsetLeft - ( eventData.scroll * 60 ) ) + 'px';
|
this.element.style.marginLeft = ( offsetLeft - ( event.scroll * 60 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.x, offsetLeft - ( eventData.scroll * 60 ) );
|
loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 60 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( eventData.scroll < 0 ) {
|
if ( event.scroll < 0 ) {
|
||||||
//scroll up
|
//scroll up
|
||||||
if ( offsetTop > viewerSize.y - scrollHeight ) {
|
if ( offsetTop > viewerSize.y - scrollHeight ) {
|
||||||
this.element.style.marginTop = ( offsetTop + ( eventData.scroll * 60 ) ) + 'px';
|
this.element.style.marginTop = ( offsetTop + ( event.scroll * 60 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.y, offsetTop + ( eventData.scroll * 60 ) );
|
loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 60 ) );
|
||||||
}
|
}
|
||||||
} else if ( eventData.scroll > 0 ) {
|
} else if ( event.scroll > 0 ) {
|
||||||
//scroll dowm
|
//scroll dowm
|
||||||
if ( offsetTop < 0 ) {
|
if ( offsetTop < 0 ) {
|
||||||
this.element.style.marginTop = ( offsetTop + ( eventData.scroll * 60 ) ) + 'px';
|
this.element.style.marginTop = ( offsetTop + ( event.scroll * 60 ) ) + 'px';
|
||||||
loadPanels( this, viewerSize.y, offsetTop + ( eventData.scroll * 60 ) );
|
loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 60 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,22 +453,22 @@ function loadPanels( strip, viewerSize, scroll ) {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onStripEnter( tracker, eventData ) {
|
function onStripEnter( event ) {
|
||||||
|
|
||||||
//$.setElementOpacity(tracker.element, 0.8);
|
//$.setElementOpacity(event.eventSource.element, 0.8);
|
||||||
|
|
||||||
//tracker.element.style.border = '1px solid #555';
|
//event.eventSource.element.style.border = '1px solid #555';
|
||||||
//tracker.element.style.background = '#000';
|
//event.eventSource.element.style.background = '#000';
|
||||||
|
|
||||||
if ( 'horizontal' == this.scroll ) {
|
if ( 'horizontal' == this.scroll ) {
|
||||||
|
|
||||||
//tracker.element.style.paddingTop = "0px";
|
//event.eventSource.element.style.paddingTop = "0px";
|
||||||
tracker.element.style.marginBottom = "0px";
|
event.eventSource.element.style.marginBottom = "0px";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//tracker.element.style.paddingRight = "0px";
|
//event.eventSource.element.style.paddingRight = "0px";
|
||||||
tracker.element.style.marginLeft = "0px";
|
event.eventSource.element.style.marginLeft = "0px";
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -480,16 +480,16 @@ function onStripEnter( tracker, eventData ) {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onStripExit( tracker, eventData ) {
|
function onStripExit( event ) {
|
||||||
if ( 'horizontal' == this.scroll ) {
|
if ( 'horizontal' == this.scroll ) {
|
||||||
|
|
||||||
//tracker.element.style.paddingTop = "10px";
|
//event.eventSource.element.style.paddingTop = "10px";
|
||||||
tracker.element.style.marginBottom = "-" + ( $.getElementSize( tracker.element ).y / 2 ) + "px";
|
event.eventSource.element.style.marginBottom = "-" + ( $.getElementSize( event.eventSource.element ).y / 2 ) + "px";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//tracker.element.style.paddingRight = "10px";
|
//event.eventSource.element.style.paddingRight = "10px";
|
||||||
tracker.element.style.marginLeft = "-" + ( $.getElementSize( tracker.element ).x / 2 ) + "px";
|
event.eventSource.element.style.marginLeft = "-" + ( $.getElementSize( event.eventSource.element ).x / 2 ) + "px";
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -502,37 +502,37 @@ function onStripExit( tracker, eventData ) {
|
|||||||
* @inner
|
* @inner
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
function onKeyPress( tracker, eventData ) {
|
function onKeyPress( event ) {
|
||||||
//console.log( eventData.keyCode );
|
//console.log( event.keyCode );
|
||||||
|
|
||||||
switch ( eventData.keyCode ) {
|
switch ( event.keyCode ) {
|
||||||
case 61: //=|+
|
case 61: //=|+
|
||||||
onStripScroll.call( this, this.tracker, { position: null, scroll: 1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
||||||
return false;
|
return false;
|
||||||
case 45: //-|_
|
case 45: //-|_
|
||||||
onStripScroll.call( this, this.tracker, { position: null, scroll: -1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
||||||
return false;
|
return false;
|
||||||
case 48: //0|)
|
case 48: //0|)
|
||||||
case 119: //w
|
case 119: //w
|
||||||
case 87: //W
|
case 87: //W
|
||||||
case 38: //up arrow
|
case 38: //up arrow
|
||||||
onStripScroll.call( this, this.tracker, { position: null, scroll: 1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
||||||
return false;
|
return false;
|
||||||
case 115: //s
|
case 115: //s
|
||||||
case 83: //S
|
case 83: //S
|
||||||
case 40: //down arrow
|
case 40: //down arrow
|
||||||
onStripScroll.call( this, this.tracker, { position: null, scroll: -1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
||||||
return false;
|
return false;
|
||||||
case 97: //a
|
case 97: //a
|
||||||
case 37: //left arrow
|
case 37: //left arrow
|
||||||
onStripScroll.call( this, this.tracker, { position: null, scroll: -1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
||||||
return false;
|
return false;
|
||||||
case 100: //d
|
case 100: //d
|
||||||
case 39: //right arrow
|
case 39: //right arrow
|
||||||
onStripScroll.call( this, this.tracker, { position: null, scroll: 1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
//console.log( 'navigator keycode %s', eventData.keyCode );
|
//console.log( 'navigator keycode %s', event.keyCode );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,8 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
|
|||||||
for ( i = 0; i < arguments.length; i++ ) {
|
for ( i = 0; i < arguments.length; i++ ) {
|
||||||
if ( $.isFunction( arguments[ i ] ) ) {
|
if ( $.isFunction( arguments[ i ] ) ) {
|
||||||
callback = arguments[ i ];
|
callback = arguments[ i ];
|
||||||
this.addHandler( 'ready', function ( placeHolderSource, placeHolderEventData ) {
|
this.addHandler( 'ready', function ( event ) {
|
||||||
callback( placeHolderSource, placeHolderEventData );
|
callback( event );
|
||||||
} );
|
} );
|
||||||
//only one callback per constructor
|
//only one callback per constructor
|
||||||
break;
|
break;
|
||||||
|
132
src/viewer.js
132
src/viewer.js
@ -172,8 +172,8 @@ $.Viewer = function( options ) {
|
|||||||
//Inherit some behaviors and properties
|
//Inherit some behaviors and properties
|
||||||
$.EventSource.call( this );
|
$.EventSource.call( this );
|
||||||
|
|
||||||
this.addHandler( 'open-failed', function (source, args) {
|
this.addHandler( 'open-failed', function ( event ) {
|
||||||
var msg = $.getString( "Errors.OpenFailed", args.source, args.message);
|
var msg = $.getString( "Errors.OpenFailed", event.eventSource, event.message);
|
||||||
_this._showMessage( msg );
|
_this._showMessage( msg );
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -265,8 +265,8 @@ $.Viewer = function( options ) {
|
|||||||
window.scrollTo( 0, point.y );
|
window.scrollTo( 0, point.y );
|
||||||
},
|
},
|
||||||
|
|
||||||
keyHandler: function( tracker, eventData ){
|
keyHandler: function( event ){
|
||||||
switch( eventData.keyCode ){
|
switch( event.keyCode ){
|
||||||
case 61://=|+
|
case 61://=|+
|
||||||
_this.viewport.zoomBy(1.1);
|
_this.viewport.zoomBy(1.1);
|
||||||
_this.viewport.applyConstraints();
|
_this.viewport.applyConstraints();
|
||||||
@ -282,7 +282,7 @@ $.Viewer = function( options ) {
|
|||||||
case 119://w
|
case 119://w
|
||||||
case 87://W
|
case 87://W
|
||||||
case 38://up arrow
|
case 38://up arrow
|
||||||
if ( eventData.shift ) {
|
if ( event.shift ) {
|
||||||
_this.viewport.zoomBy(1.1);
|
_this.viewport.zoomBy(1.1);
|
||||||
} else {
|
} else {
|
||||||
_this.viewport.panBy(new $.Point(0, -0.05));
|
_this.viewport.panBy(new $.Point(0, -0.05));
|
||||||
@ -292,7 +292,7 @@ $.Viewer = function( options ) {
|
|||||||
case 115://s
|
case 115://s
|
||||||
case 83://S
|
case 83://S
|
||||||
case 40://down arrow
|
case 40://down arrow
|
||||||
if ( eventData.shift ) {
|
if ( event.shift ) {
|
||||||
_this.viewport.zoomBy(0.9);
|
_this.viewport.zoomBy(0.9);
|
||||||
} else {
|
} else {
|
||||||
_this.viewport.panBy(new $.Point(0, 0.05));
|
_this.viewport.panBy(new $.Point(0, 0.05));
|
||||||
@ -310,7 +310,7 @@ $.Viewer = function( options ) {
|
|||||||
_this.viewport.applyConstraints();
|
_this.viewport.applyConstraints();
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
//console.log( 'navigator keycode %s', eventData.keyCode );
|
//console.log( 'navigator keycode %s', event.keyCode );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -438,11 +438,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
if ( $.type( tileSource ) == 'string') {
|
if ( $.type( tileSource ) == 'string') {
|
||||||
//If its still a string it means it must be a url at this point
|
//If its still a string it means it must be a url at this point
|
||||||
tileSource = new $.TileSource( tileSource, function( eventSource, eventData ){
|
tileSource = new $.TileSource( tileSource, function( event ){
|
||||||
openTileSource( _this, eventData.tileSource );
|
openTileSource( _this, event.tileSource );
|
||||||
});
|
});
|
||||||
tileSource.addHandler( 'open-failed', function ( name, args ) {
|
tileSource.addHandler( 'open-failed', function ( event ) {
|
||||||
_this.raiseEvent( 'open-failed', args );
|
_this.raiseEvent( 'open-failed', event );
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){
|
} else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){
|
||||||
@ -506,7 +506,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
VIEWERS[ this.hash ] = null;
|
VIEWERS[ this.hash ] = null;
|
||||||
delete VIEWERS[ this.hash ];
|
delete VIEWERS[ this.hash ];
|
||||||
|
|
||||||
this.raiseEvent( 'close', { viewer: this } );
|
this.raiseEvent( 'close', {} );
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -569,7 +569,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
*/
|
*/
|
||||||
setMouseNavEnabled: function( enabled ){
|
setMouseNavEnabled: function( enabled ){
|
||||||
this.innerTracker.setTracking( enabled );
|
this.innerTracker.setTracking( enabled );
|
||||||
this.raiseEvent( 'mouse-enabled', { enabled: enabled, viewer: this } );
|
this.raiseEvent( 'mouse-enabled', { enabled: enabled } );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -603,7 +603,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
} else {
|
} else {
|
||||||
beginControlsAutoHide( this );
|
beginControlsAutoHide( this );
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'controls-enabled', { enabled: enabled, viewer: this } );
|
this.raiseEvent( 'controls-enabled', { enabled: enabled } );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -731,7 +731,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
THIS[ this.hash ].fullPage = true;
|
THIS[ this.hash ].fullPage = true;
|
||||||
|
|
||||||
// mouse will be inside container now
|
// mouse will be inside container now
|
||||||
$.delegate( this, onContainerEnter )( null, {} );
|
$.delegate( this, onContainerEnter )( {} );
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -790,11 +790,11 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
THIS[ this.hash ].fullPage = false;
|
THIS[ this.hash ].fullPage = false;
|
||||||
|
|
||||||
// mouse will likely be outside now
|
// mouse will likely be outside now
|
||||||
$.delegate( this, onContainerExit )( null, {} );
|
$.delegate( this, onContainerExit )( {} );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'fullpage', { fullpage: fullPage, viewer: this } );
|
this.raiseEvent( 'fullpage', { fullpage: fullPage } );
|
||||||
|
|
||||||
if ( this.viewport ) {
|
if ( this.viewport ) {
|
||||||
oldBounds = this.viewport.getBounds();
|
oldBounds = this.viewport.getBounds();
|
||||||
@ -854,7 +854,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
*/
|
*/
|
||||||
setVisible: function( visible ){
|
setVisible: function( visible ){
|
||||||
this.container.style.visibility = visible ? "" : "hidden";
|
this.container.style.visibility = visible ? "" : "hidden";
|
||||||
this.raiseEvent( 'visible', { visible: visible, viewer: this } );
|
this.raiseEvent( 'visible', { visible: visible } );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1076,7 +1076,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
goToPage: function( page ){
|
goToPage: function( page ){
|
||||||
//page is a 1 based index so normalize now
|
//page is a 1 based index so normalize now
|
||||||
//page = page;
|
//page = page;
|
||||||
this.raiseEvent( 'page', { page: page, viewer: this } );
|
this.raiseEvent( 'page', { page: page } );
|
||||||
|
|
||||||
if( this.tileSources.length > page ){
|
if( this.tileSources.length > page ){
|
||||||
|
|
||||||
@ -1334,7 +1334,7 @@ function openTileSource( viewer, source ) {
|
|||||||
}
|
}
|
||||||
VIEWERS[ _this.hash ] = _this;
|
VIEWERS[ _this.hash ] = _this;
|
||||||
|
|
||||||
_this.raiseEvent( 'open', { source: source, viewer: _this } );
|
_this.raiseEvent( 'open', { source: source } );
|
||||||
|
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@ -1427,37 +1427,37 @@ function onBlur(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasClick( tracker, eventData ) {
|
function onCanvasClick( event ) {
|
||||||
var zoomPerClick,
|
var zoomPerClick,
|
||||||
factor;
|
factor;
|
||||||
if ( this.viewport && eventData.quick ) { // ignore clicks where mouse moved
|
if ( this.viewport && event.quick ) { // ignore clicks where mouse moved
|
||||||
zoomPerClick = this.zoomPerClick;
|
zoomPerClick = this.zoomPerClick;
|
||||||
factor = eventData.shift ? 1.0 / zoomPerClick : zoomPerClick;
|
factor = event.shift ? 1.0 / zoomPerClick : zoomPerClick;
|
||||||
this.viewport.zoomBy(
|
this.viewport.zoomBy(
|
||||||
factor,
|
factor,
|
||||||
this.viewport.pointFromPixel( eventData.position, true )
|
this.viewport.pointFromPixel( event.position, true )
|
||||||
);
|
);
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'canvas-click', {
|
this.raiseEvent( 'canvas-click', {
|
||||||
tracker: tracker,
|
tracker: event.eventSource,
|
||||||
position: eventData.position,
|
position: event.position,
|
||||||
quick: eventData.quick,
|
quick: event.quick,
|
||||||
shift: eventData.shift
|
shift: event.shift
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasDrag( tracker, eventData ) {
|
function onCanvasDrag( event ) {
|
||||||
if ( this.viewport ) {
|
if ( this.viewport ) {
|
||||||
if( !this.panHorizontal ){
|
if( !this.panHorizontal ){
|
||||||
eventData.delta.x = 0;
|
event.delta.x = 0;
|
||||||
}
|
}
|
||||||
if( !this.panVertical ){
|
if( !this.panVertical ){
|
||||||
eventData.delta.y = 0;
|
event.delta.y = 0;
|
||||||
}
|
}
|
||||||
this.viewport.panBy(
|
this.viewport.panBy(
|
||||||
this.viewport.deltaPointsFromPixels(
|
this.viewport.deltaPointsFromPixels(
|
||||||
eventData.delta.negate()
|
event.delta.negate()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if( this.constrainDuringPan ){
|
if( this.constrainDuringPan ){
|
||||||
@ -1465,83 +1465,83 @@ function onCanvasDrag( tracker, eventData ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'canvas-drag', {
|
this.raiseEvent( 'canvas-drag', {
|
||||||
tracker: tracker,
|
tracker: event.eventSource,
|
||||||
position: eventData.position,
|
position: event.position,
|
||||||
delta: eventData.delta,
|
delta: event.delta,
|
||||||
shift: eventData.shift
|
shift: event.shift
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasRelease( tracker, eventData ) {
|
function onCanvasRelease( event ) {
|
||||||
if ( eventData.insideElementPressed && this.viewport ) {
|
if ( event.insideElementPressed && this.viewport ) {
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'canvas-release', {
|
this.raiseEvent( 'canvas-release', {
|
||||||
tracker: tracker,
|
tracker: event.eventSource,
|
||||||
position: eventData.position,
|
position: event.position,
|
||||||
insideElementPressed: eventData.insideElementPressed,
|
insideElementPressed: event.insideElementPressed,
|
||||||
insideElementReleased: eventData.insideElementReleased
|
insideElementReleased: event.insideElementReleased
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasScroll( tracker, eventData ) {
|
function onCanvasScroll( event ) {
|
||||||
var factor;
|
var factor;
|
||||||
if ( this.viewport ) {
|
if ( this.viewport ) {
|
||||||
factor = Math.pow( this.zoomPerScroll, eventData.scroll );
|
factor = Math.pow( this.zoomPerScroll, event.scroll );
|
||||||
this.viewport.zoomBy(
|
this.viewport.zoomBy(
|
||||||
factor,
|
factor,
|
||||||
this.viewport.pointFromPixel( eventData.position, true )
|
this.viewport.pointFromPixel( event.position, true )
|
||||||
);
|
);
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'canvas-scroll', {
|
this.raiseEvent( 'canvas-scroll', {
|
||||||
tracker: tracker,
|
tracker: event.eventSource,
|
||||||
position: eventData.position,
|
position: event.position,
|
||||||
scroll: eventData.scroll,
|
scroll: event.scroll,
|
||||||
shift: eventData.shift
|
shift: event.shift
|
||||||
});
|
});
|
||||||
//cancels event
|
//cancels event
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onContainerExit( tracker, eventData ) {
|
function onContainerExit( event ) {
|
||||||
if ( !eventData.insideElementPressed ) {
|
if ( !event.insideElementPressed ) {
|
||||||
THIS[ this.hash ].mouseInside = false;
|
THIS[ this.hash ].mouseInside = false;
|
||||||
if ( !THIS[ this.hash ].animating ) {
|
if ( !THIS[ this.hash ].animating ) {
|
||||||
beginControlsAutoHide( this );
|
beginControlsAutoHide( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'container-exit', {
|
this.raiseEvent( 'container-exit', {
|
||||||
tracker: tracker,
|
tracker: event.eventSource,
|
||||||
position: eventData.position,
|
position: event.position,
|
||||||
insideElementPressed: eventData.insideElementPressed,
|
insideElementPressed: event.insideElementPressed,
|
||||||
buttonDownAny: eventData.buttonDownAny
|
buttonDownAny: event.buttonDownAny
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onContainerRelease( tracker, eventData ) {
|
function onContainerRelease( event ) {
|
||||||
if ( !eventData.insideElementReleased ) {
|
if ( !event.insideElementReleased ) {
|
||||||
THIS[ this.hash ].mouseInside = false;
|
THIS[ this.hash ].mouseInside = false;
|
||||||
if ( !THIS[ this.hash ].animating ) {
|
if ( !THIS[ this.hash ].animating ) {
|
||||||
beginControlsAutoHide( this );
|
beginControlsAutoHide( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.raiseEvent( 'container-release', {
|
this.raiseEvent( 'container-release', {
|
||||||
tracker: tracker,
|
tracker: event.eventSource,
|
||||||
position: eventData.position,
|
position: event.position,
|
||||||
insideElementPressed: eventData.insideElementPressed,
|
insideElementPressed: event.insideElementPressed,
|
||||||
insideElementReleased: eventData.insideElementReleased
|
insideElementReleased: event.insideElementReleased
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onContainerEnter( tracker, eventData ) {
|
function onContainerEnter( event ) {
|
||||||
THIS[ this.hash ].mouseInside = true;
|
THIS[ this.hash ].mouseInside = true;
|
||||||
abortControlsAutoHide( this );
|
abortControlsAutoHide( this );
|
||||||
this.raiseEvent( 'container-enter', {
|
this.raiseEvent( 'container-enter', {
|
||||||
tracker: tracker,
|
tracker: event.eventSource,
|
||||||
position: eventData.position,
|
position: event.position,
|
||||||
insideElementPressed: eventData.insideElementPressed,
|
insideElementPressed: event.insideElementPressed,
|
||||||
buttonDownAny: eventData.buttonDownAny
|
buttonDownAny: event.buttonDownAny
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +122,7 @@ $.Viewport.prototype = {
|
|||||||
|
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'reset-size', {
|
this.viewer.raiseEvent( 'reset-size', {
|
||||||
contentSize: contentSize,
|
contentSize: contentSize
|
||||||
viewer: this.viewer
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,8 +168,7 @@ $.Viewport.prototype = {
|
|||||||
goHome: function( immediately ) {
|
goHome: function( immediately ) {
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'home', {
|
this.viewer.raiseEvent( 'home', {
|
||||||
immediately: immediately,
|
immediately: immediately
|
||||||
viewer: this.viewer
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this.fitBounds( this.getHomeBounds(), immediately );
|
return this.fitBounds( this.getHomeBounds(), immediately );
|
||||||
@ -370,8 +368,7 @@ $.Viewport.prototype = {
|
|||||||
|
|
||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'constrain', {
|
this.viewer.raiseEvent( 'constrain', {
|
||||||
immediately: immediately,
|
immediately: immediately
|
||||||
viewer: this.viewer
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,8 +520,7 @@ $.Viewport.prototype = {
|
|||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'pan', {
|
this.viewer.raiseEvent( 'pan', {
|
||||||
center: center,
|
center: center,
|
||||||
immediately: immediately,
|
immediately: immediately
|
||||||
viewer: this.viewer
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,8 +563,7 @@ $.Viewport.prototype = {
|
|||||||
this.viewer.raiseEvent( 'zoom', {
|
this.viewer.raiseEvent( 'zoom', {
|
||||||
zoom: zoom,
|
zoom: zoom,
|
||||||
refPoint: refPoint,
|
refPoint: refPoint,
|
||||||
immediately: immediately,
|
immediately: immediately
|
||||||
viewer: this.viewer
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,8 +626,7 @@ $.Viewport.prototype = {
|
|||||||
if( this.viewer ){
|
if( this.viewer ){
|
||||||
this.viewer.raiseEvent( 'resize', {
|
this.viewer.raiseEvent( 'resize', {
|
||||||
newContainerSize: newContainerSize,
|
newContainerSize: newContainerSize,
|
||||||
maintain: maintain,
|
maintain: maintain
|
||||||
viewer: this.viewer
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
asyncTest('Open', function() {
|
asyncTest('Open', function() {
|
||||||
ok(viewer, 'Viewer exists');
|
ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
var openHandler = function(eventSender, eventData) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
ok(true, 'Open event was sent');
|
||||||
equal(eventSender, viewer, 'Sender of open event was viewer');
|
ok(event, 'Handler received event data');
|
||||||
ok(eventData, 'Handler also received event data');
|
equal(event.eventSource, viewer, 'Sender of open event was viewer');
|
||||||
ok(viewer.viewport, 'Viewport exists');
|
ok(viewer.viewport, 'Viewport exists');
|
||||||
ok(viewer.source, 'source exists');
|
ok(viewer.source, 'source exists');
|
||||||
ok(viewer._updateRequestId, 'timer is on');
|
ok(viewer._updateRequestId, 'timer is on');
|
||||||
@ -46,12 +46,12 @@
|
|||||||
asyncTest('Open Error Handling', function() {
|
asyncTest('Open Error Handling', function() {
|
||||||
ok(viewer, 'Viewer exists');
|
ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
viewer.addHandler('open', function(eventSender, eventData) {
|
viewer.addHandler('open', function(event) {
|
||||||
ok(false, "The open event should not fire for failed opens");
|
ok(false, "The open event should not fire for failed opens");
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('open-failed', function(eventSender, eventData) {
|
viewer.addHandler('open-failed', function(event) {
|
||||||
ok(true, "The open-failed event should be fired when the source 404s");
|
ok(true, "The open-failed event should be fired when the source 404s");
|
||||||
|
|
||||||
equal($(".openseadragon-message").length, 1, "Open failures should display a message");
|
equal($(".openseadragon-message").length, 1, "Open failures should display a message");
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'addHandler without userData', function () {
|
asyncTest( 'addHandler without userData', function () {
|
||||||
var openHandler = function ( eventSender, eventData ) {
|
var openHandler = function ( event ) {
|
||||||
viewer.removeHandler( 'open', openHandler );
|
viewer.removeHandler( 'open', openHandler );
|
||||||
ok( eventData, 'Event handler received event data' );
|
ok( event, 'Event handler received event data' );
|
||||||
if ( eventData ) {
|
if ( event ) {
|
||||||
strictEqual( eventData.userData, null, 'User data defaulted to null' );
|
strictEqual( event.eventSource, viewer, 'eventSource sent, eventSource is viewer' );
|
||||||
|
strictEqual( event.userData, null, 'User data defaulted to null' );
|
||||||
}
|
}
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
start();
|
||||||
@ -45,12 +46,12 @@
|
|||||||
var userData = { item1: 'Test user data', item2: Math.random() },
|
var userData = { item1: 'Test user data', item2: Math.random() },
|
||||||
originalUserData = { item1: userData.item1, item2: userData.item2 };
|
originalUserData = { item1: userData.item1, item2: userData.item2 };
|
||||||
|
|
||||||
var openHandler = function ( eventSender, eventData ) {
|
var openHandler = function ( event ) {
|
||||||
viewer.removeHandler( 'open', openHandler );
|
viewer.removeHandler( 'open', openHandler );
|
||||||
ok( eventData, 'Event handler received event data' );
|
ok( event, 'Event handler received event data' );
|
||||||
ok( eventData && eventData.userData, 'Event handler received user data' );
|
ok( event && event.userData, 'Event handler received user data' );
|
||||||
if ( eventData && eventData.userData ) {
|
if ( event && event.userData ) {
|
||||||
deepEqual( eventData.userData, originalUserData, 'User data was untouched' );
|
deepEqual( event.userData, originalUserData, 'User data was untouched' );
|
||||||
}
|
}
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
start();
|
||||||
@ -71,11 +72,12 @@
|
|||||||
releasesHandledEventSource = 0,
|
releasesHandledEventSource = 0,
|
||||||
clicksHandledEventSource = 0,
|
clicksHandledEventSource = 0,
|
||||||
eventsHandledMouseTracker = 0,
|
eventsHandledMouseTracker = 0,
|
||||||
|
eventSourcePassedMouseTracker = 0,
|
||||||
originalEventsPassedMouseTracker = 0,
|
originalEventsPassedMouseTracker = 0,
|
||||||
releasesExpected = 1,
|
releasesExpected = 1,
|
||||||
clicksExpected = 1;
|
clicksExpected = 1;
|
||||||
|
|
||||||
var onOpen = function ( eventSender, eventData ) {
|
var onOpen = function ( event ) {
|
||||||
viewer.removeHandler( 'open', onOpen );
|
viewer.removeHandler( 'open', onOpen );
|
||||||
|
|
||||||
viewer.addHandler( 'canvas-drag', onEventSourceDrag );
|
viewer.addHandler( 'canvas-drag', onEventSourceDrag );
|
||||||
@ -115,61 +117,64 @@
|
|||||||
$canvas.simulate( 'blur', event );
|
$canvas.simulate( 'blur', event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onEventSourceDrag = function ( eventSender, eventData ) {
|
var onEventSourceDrag = function ( event ) {
|
||||||
dragsHandledEventSource++;
|
dragsHandledEventSource++;
|
||||||
};
|
};
|
||||||
|
|
||||||
var onEventSourceRelease = function ( eventSender, eventData ) {
|
var onEventSourceRelease = function ( event ) {
|
||||||
releasesHandledEventSource++;
|
releasesHandledEventSource++;
|
||||||
};
|
};
|
||||||
|
|
||||||
var onEventSourceClick = function ( eventSender, eventData ) {
|
var onEventSourceClick = function ( event ) {
|
||||||
clicksHandledEventSource++;
|
clicksHandledEventSource++;
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkOriginalEventReceived = function ( eventData ) {
|
var checkOriginalEventReceived = function ( event ) {
|
||||||
eventsHandledMouseTracker++;
|
eventsHandledMouseTracker++;
|
||||||
|
if ( event && event.eventSource === mouseTracker ) {
|
||||||
|
eventSourcePassedMouseTracker++;
|
||||||
|
}
|
||||||
//TODO Provide a better check for the original event...simulate doesn't currently extend the object
|
//TODO Provide a better check for the original event...simulate doesn't currently extend the object
|
||||||
// with arbitrary user data.
|
// with arbitrary user data.
|
||||||
if ( eventData && eventData.originalEvent ) {
|
if ( event && event.originalEvent ) {
|
||||||
originalEventsPassedMouseTracker++;
|
originalEventsPassedMouseTracker++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerFocus = function ( tracker, eventData ) {
|
var onMouseTrackerFocus = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerBlur = function ( tracker, eventData ) {
|
var onMouseTrackerBlur = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerEnter = function ( tracker, eventData ) {
|
var onMouseTrackerEnter = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerPress = function ( tracker, eventData ) {
|
var onMouseTrackerPress = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerMove = function ( tracker, eventData ) {
|
var onMouseTrackerMove = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerDrag = function ( tracker, eventData ) {
|
var onMouseTrackerDrag = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerRelease = function ( tracker, eventData ) {
|
var onMouseTrackerRelease = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerClick = function ( tracker, eventData ) {
|
var onMouseTrackerClick = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
};
|
};
|
||||||
|
|
||||||
var onMouseTrackerExit = function ( tracker, eventData ) {
|
var onMouseTrackerExit = function ( event ) {
|
||||||
checkOriginalEventReceived( eventData );
|
checkOriginalEventReceived( event );
|
||||||
|
|
||||||
mouseTracker.destroy();
|
mouseTracker.destroy();
|
||||||
viewer.removeHandler( 'canvas-drag', onEventSourceDrag );
|
viewer.removeHandler( 'canvas-drag', onEventSourceDrag );
|
||||||
@ -180,8 +185,9 @@
|
|||||||
equal( releasesHandledEventSource, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
|
equal( releasesHandledEventSource, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
|
||||||
equal( clicksHandledEventSource, releasesExpected, "'canvas-click' event count matches expected (" + releasesExpected + ")" );
|
equal( clicksHandledEventSource, releasesExpected, "'canvas-click' event count matches expected (" + releasesExpected + ")" );
|
||||||
|
|
||||||
|
equal( eventSourcePassedMouseTracker, eventsHandledMouseTracker, "Event source received count matches expected (" + eventsHandledMouseTracker + ")" );
|
||||||
equal( originalEventsPassedMouseTracker, eventsHandledMouseTracker, "Original event received count matches expected (" + eventsHandledMouseTracker + ")" );
|
equal( originalEventsPassedMouseTracker, eventsHandledMouseTracker, "Original event received count matches expected (" + eventsHandledMouseTracker + ")" );
|
||||||
deepEqual( eventData.userData, originalUserData, 'MouseTracker userData was untouched' );
|
deepEqual( event.userData, originalUserData, 'MouseTracker userData was untouched' );
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
start();
|
||||||
|
@ -26,20 +26,20 @@
|
|||||||
|
|
||||||
ok(viewer, 'Viewer exists');
|
ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
var openHandler = function(eventSender, eventData) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
ok(true, 'Open event was sent');
|
||||||
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
var tileDrawnHandler = function(eventSender, eventData) {
|
var tileDrawnHandler = function(event) {
|
||||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
||||||
ok(true, 'A tile has been drawn');
|
ok(true, 'A tile has been drawn');
|
||||||
viewer.addHandler('close', closeHandler);
|
viewer.addHandler('close', closeHandler);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
var closeHandler = function() {
|
var closeHandler = function(event) {
|
||||||
viewer.removeHandler('close', closeHandler);
|
viewer.removeHandler('close', closeHandler);
|
||||||
$('#example').empty();
|
$('#example').empty();
|
||||||
ok(true, 'Close event was sent');
|
ok(true, 'Close event was sent');
|
||||||
|
@ -479,13 +479,13 @@ QUnit.config.autostart = false;
|
|||||||
showNavigator: true
|
showNavigator: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var openHandler1 = function(eventSender, eventData) {
|
var openHandler1 = function(event) {
|
||||||
viewer.removeHandler('open', openHandler1);
|
viewer.removeHandler('open', openHandler1);
|
||||||
ok(viewer.navigator, 'navigator exists');
|
ok(viewer.navigator, 'navigator exists');
|
||||||
viewer.navigator.addHandler('open', navOpenHandler1);
|
viewer.navigator.addHandler('open', navOpenHandler1);
|
||||||
};
|
};
|
||||||
|
|
||||||
var navOpenHandler1 = function(eventSender, eventData) {
|
var navOpenHandler1 = function(event) {
|
||||||
viewer.navigator.removeHandler('open', navOpenHandler1);
|
viewer.navigator.removeHandler('open', navOpenHandler1);
|
||||||
equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
||||||
ok(viewer.navigator._updateRequestId, 'navigator timer is on');
|
ok(viewer.navigator._updateRequestId, 'navigator timer is on');
|
||||||
@ -494,25 +494,25 @@ QUnit.config.autostart = false;
|
|||||||
viewer.open('/test/data/tall.dzi');
|
viewer.open('/test/data/tall.dzi');
|
||||||
};
|
};
|
||||||
|
|
||||||
var closeHandler1 = function() {
|
var closeHandler1 = function(event) {
|
||||||
viewer.removeHandler('close', closeHandler1);
|
viewer.removeHandler('close', closeHandler1);
|
||||||
ok(true, 'calling open closes the old one');
|
ok(true, 'calling open closes the old one');
|
||||||
equal(viewer.navigator.source, null, 'navigator source has been cleared');
|
equal(viewer.navigator.source, null, 'navigator source has been cleared');
|
||||||
};
|
};
|
||||||
|
|
||||||
var openHandler2 = function(eventSender, eventData) {
|
var openHandler2 = function(event) {
|
||||||
viewer.removeHandler('open', openHandler2);
|
viewer.removeHandler('open', openHandler2);
|
||||||
viewer.navigator.addHandler('open', navOpenHandler2);
|
viewer.navigator.addHandler('open', navOpenHandler2);
|
||||||
};
|
};
|
||||||
|
|
||||||
var navOpenHandler2 = function(eventSender, eventData) {
|
var navOpenHandler2 = function(event) {
|
||||||
viewer.navigator.removeHandler('open', navOpenHandler2);
|
viewer.navigator.removeHandler('open', navOpenHandler2);
|
||||||
equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
||||||
viewer.addHandler('close', closeHandler2);
|
viewer.addHandler('close', closeHandler2);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
var closeHandler2 = function() {
|
var closeHandler2 = function(event) {
|
||||||
viewer.removeHandler('close', closeHandler2);
|
viewer.removeHandler('close', closeHandler2);
|
||||||
ok(!viewer.navigator._updateRequestId, 'navigator timer is off');
|
ok(!viewer.navigator._updateRequestId, 'navigator timer is off');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user