originalEvent Pass through to EventSource events

This commit is contained in:
Mark Salsbery 2013-10-15 11:11:08 -07:00
parent e06a5c73c7
commit 984dd267b6
3 changed files with 27 additions and 17 deletions

View File

@ -30,6 +30,9 @@ OPENSEADRAGON CHANGELOG
* Added a number of easier coordinate conversion methods to viewport (#243) * Added a number of easier coordinate conversion methods to viewport (#243)
* Added the ability to create a viewer and start at a specified page (#252) * Added the ability to create a viewer and start at a specified page (#252)
* Fixed image resolve issue with collection mode (#255) * Fixed image resolve issue with collection mode (#255)
* DOM events are now passed through as 'event.originalEvent' in viewer and button events where appropriate. Effects the following events:
* Viewer: 'canvas-release', 'canvas-click', 'canvas-drag', 'canvas-scroll', 'container-enter', 'container-exit', 'container-release'
* Button: 'enter', 'exit', 'press', 'release', 'focus', 'blur', 'click'
0.9.131: 0.9.131:

View File

@ -178,7 +178,7 @@ $.Button = function( options ) {
enterHandler: function( event ) { enterHandler: function( event ) {
if ( event.insideElementPressed ) { if ( event.insideElementPressed ) {
inTo( _this, $.ButtonState.DOWN ); inTo( _this, $.ButtonState.DOWN );
_this.raiseEvent( "enter", {} ); _this.raiseEvent( "enter", { originalEvent: event.originalEvent } );
} else if ( !event.buttonDownAny ) { } else if ( !event.buttonDownAny ) {
inTo( _this, $.ButtonState.HOVER ); inTo( _this, $.ButtonState.HOVER );
} }
@ -186,30 +186,30 @@ $.Button = function( options ) {
focusHandler: function ( event ) { focusHandler: function ( event ) {
this.enterHandler( event ); this.enterHandler( event );
_this.raiseEvent( "focus", {} ); _this.raiseEvent( "focus", { originalEvent: event.originalEvent } );
}, },
exitHandler: function( event ) { exitHandler: function( event ) {
outTo( _this, $.ButtonState.GROUP ); outTo( _this, $.ButtonState.GROUP );
if ( event.insideElementPressed ) { if ( event.insideElementPressed ) {
_this.raiseEvent( "exit", {} ); _this.raiseEvent( "exit", { originalEvent: event.originalEvent } );
} }
}, },
blurHandler: function ( event ) { blurHandler: function ( event ) {
this.exitHandler( event ); this.exitHandler( event );
_this.raiseEvent( "blur", {} ); _this.raiseEvent( "blur", { originalEvent: event.originalEvent } );
}, },
pressHandler: function ( event ) { pressHandler: function ( event ) {
inTo( _this, $.ButtonState.DOWN ); inTo( _this, $.ButtonState.DOWN );
_this.raiseEvent( "press", {} ); _this.raiseEvent( "press", { originalEvent: event.originalEvent } );
}, },
releaseHandler: function( event ) { releaseHandler: function( event ) {
if ( event.insideElementPressed && event.insideElementReleased ) { if ( event.insideElementPressed && event.insideElementReleased ) {
outTo( _this, $.ButtonState.HOVER ); outTo( _this, $.ButtonState.HOVER );
_this.raiseEvent( "release", {} ); _this.raiseEvent( "release", { originalEvent: event.originalEvent } );
} else if ( event.insideElementPressed ) { } else if ( event.insideElementPressed ) {
outTo( _this, $.ButtonState.GROUP ); outTo( _this, $.ButtonState.GROUP );
} else { } else {
@ -219,15 +219,15 @@ $.Button = function( options ) {
clickHandler: function( event ) { clickHandler: function( event ) {
if ( event.quick ) { if ( event.quick ) {
_this.raiseEvent("click", {}); _this.raiseEvent("click", { originalEvent: event.originalEvent });
} }
}, },
keyHandler: function( event ){ keyHandler: function( event ){
//console.log( "%s : handling key %s!", _this.tooltip, event.keyCode); //console.log( "%s : handling key %s!", _this.tooltip, event.keyCode);
if( 13 === event.keyCode ){ if( 13 === event.keyCode ){
_this.raiseEvent( "click", {} ); _this.raiseEvent( "click", { originalEvent: event.originalEvent } );
_this.raiseEvent( "release", {} ); _this.raiseEvent( "release", { originalEvent: event.originalEvent } );
return false; return false;
} }
return true; return true;

View File

@ -530,7 +530,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', {} ); this.raiseEvent( 'close' );
return this; return this;
}, },
@ -1487,7 +1487,8 @@ function onCanvasClick( event ) {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
quick: event.quick, quick: event.quick,
shift: event.shift shift: event.shift,
originalEvent: event.originalEvent
}); });
} }
@ -1512,7 +1513,8 @@ function onCanvasDrag( event ) {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
delta: event.delta, delta: event.delta,
shift: event.shift shift: event.shift,
originalEvent: event.originalEvent
}); });
} }
@ -1524,7 +1526,8 @@ function onCanvasRelease( event ) {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
insideElementPressed: event.insideElementPressed, insideElementPressed: event.insideElementPressed,
insideElementReleased: event.insideElementReleased insideElementReleased: event.insideElementReleased,
originalEvent: event.originalEvent
}); });
} }
@ -1542,7 +1545,8 @@ function onCanvasScroll( event ) {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
scroll: event.scroll, scroll: event.scroll,
shift: event.shift shift: event.shift,
originalEvent: event.originalEvent
}); });
//cancels event //cancels event
return false; return false;
@ -1559,7 +1563,8 @@ function onContainerExit( event ) {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
insideElementPressed: event.insideElementPressed, insideElementPressed: event.insideElementPressed,
buttonDownAny: event.buttonDownAny buttonDownAny: event.buttonDownAny,
originalEvent: event.originalEvent
}); });
} }
@ -1574,7 +1579,8 @@ function onContainerRelease( event ) {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
insideElementPressed: event.insideElementPressed, insideElementPressed: event.insideElementPressed,
insideElementReleased: event.insideElementReleased insideElementReleased: event.insideElementReleased,
originalEvent: event.originalEvent
}); });
} }
@ -1585,7 +1591,8 @@ function onContainerEnter( event ) {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
insideElementPressed: event.insideElementPressed, insideElementPressed: event.insideElementPressed,
buttonDownAny: event.buttonDownAny buttonDownAny: event.buttonDownAny,
originalEvent: event.originalEvent
}); });
} }