diff --git a/changelog.txt b/changelog.txt index 348d3cfa..9a78b48f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -30,6 +30,9 @@ OPENSEADRAGON CHANGELOG * 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) * 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: diff --git a/src/button.js b/src/button.js index e32ca35a..8a09cdb0 100644 --- a/src/button.js +++ b/src/button.js @@ -178,7 +178,7 @@ $.Button = function( options ) { enterHandler: function( event ) { if ( event.insideElementPressed ) { inTo( _this, $.ButtonState.DOWN ); - _this.raiseEvent( "enter", {} ); + _this.raiseEvent( "enter", { originalEvent: event.originalEvent } ); } else if ( !event.buttonDownAny ) { inTo( _this, $.ButtonState.HOVER ); } @@ -186,30 +186,30 @@ $.Button = function( options ) { focusHandler: function ( event ) { this.enterHandler( event ); - _this.raiseEvent( "focus", {} ); + _this.raiseEvent( "focus", { originalEvent: event.originalEvent } ); }, exitHandler: function( event ) { outTo( _this, $.ButtonState.GROUP ); if ( event.insideElementPressed ) { - _this.raiseEvent( "exit", {} ); + _this.raiseEvent( "exit", { originalEvent: event.originalEvent } ); } }, blurHandler: function ( event ) { this.exitHandler( event ); - _this.raiseEvent( "blur", {} ); + _this.raiseEvent( "blur", { originalEvent: event.originalEvent } ); }, pressHandler: function ( event ) { inTo( _this, $.ButtonState.DOWN ); - _this.raiseEvent( "press", {} ); + _this.raiseEvent( "press", { originalEvent: event.originalEvent } ); }, releaseHandler: function( event ) { if ( event.insideElementPressed && event.insideElementReleased ) { outTo( _this, $.ButtonState.HOVER ); - _this.raiseEvent( "release", {} ); + _this.raiseEvent( "release", { originalEvent: event.originalEvent } ); } else if ( event.insideElementPressed ) { outTo( _this, $.ButtonState.GROUP ); } else { @@ -219,15 +219,15 @@ $.Button = function( options ) { clickHandler: function( event ) { if ( event.quick ) { - _this.raiseEvent("click", {}); + _this.raiseEvent("click", { originalEvent: event.originalEvent }); } }, keyHandler: function( event ){ //console.log( "%s : handling key %s!", _this.tooltip, event.keyCode); if( 13 === event.keyCode ){ - _this.raiseEvent( "click", {} ); - _this.raiseEvent( "release", {} ); + _this.raiseEvent( "click", { originalEvent: event.originalEvent } ); + _this.raiseEvent( "release", { originalEvent: event.originalEvent } ); return false; } return true; diff --git a/src/viewer.js b/src/viewer.js index eef46142..d12c007f 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -530,7 +530,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, VIEWERS[ this.hash ] = null; delete VIEWERS[ this.hash ]; - this.raiseEvent( 'close', {} ); + this.raiseEvent( 'close' ); return this; }, @@ -1487,7 +1487,8 @@ function onCanvasClick( event ) { tracker: event.eventSource, position: event.position, quick: event.quick, - shift: event.shift + shift: event.shift, + originalEvent: event.originalEvent }); } @@ -1512,7 +1513,8 @@ function onCanvasDrag( event ) { tracker: event.eventSource, position: event.position, delta: event.delta, - shift: event.shift + shift: event.shift, + originalEvent: event.originalEvent }); } @@ -1524,7 +1526,8 @@ function onCanvasRelease( event ) { tracker: event.eventSource, position: event.position, insideElementPressed: event.insideElementPressed, - insideElementReleased: event.insideElementReleased + insideElementReleased: event.insideElementReleased, + originalEvent: event.originalEvent }); } @@ -1542,7 +1545,8 @@ function onCanvasScroll( event ) { tracker: event.eventSource, position: event.position, scroll: event.scroll, - shift: event.shift + shift: event.shift, + originalEvent: event.originalEvent }); //cancels event return false; @@ -1559,7 +1563,8 @@ function onContainerExit( event ) { tracker: event.eventSource, position: event.position, insideElementPressed: event.insideElementPressed, - buttonDownAny: event.buttonDownAny + buttonDownAny: event.buttonDownAny, + originalEvent: event.originalEvent }); } @@ -1574,7 +1579,8 @@ function onContainerRelease( event ) { tracker: event.eventSource, position: event.position, insideElementPressed: event.insideElementPressed, - insideElementReleased: event.insideElementReleased + insideElementReleased: event.insideElementReleased, + originalEvent: event.originalEvent }); } @@ -1585,7 +1591,8 @@ function onContainerEnter( event ) { tracker: event.eventSource, position: event.position, insideElementPressed: event.insideElementPressed, - buttonDownAny: event.buttonDownAny + buttonDownAny: event.buttonDownAny, + originalEvent: event.originalEvent }); }