diff --git a/changelog.txt b/changelog.txt index 1cd6f9df..3a293e3e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -23,6 +23,7 @@ OPENSEADRAGON CHANGELOG * Removed 'position' property from MouseTracker keyDownHandler/keyUpHandler/keyHandler functions (#573) * Fixed pointer event model detection for IE 10 and IE 11 (#571) * Added setMouseNavEnabled() support to Navigator (#572) +* MouseTracker now defaults to tracking on (#558) 1.2.0: diff --git a/src/button.js b/src/button.js index 104955e0..42f68afc 100644 --- a/src/button.js +++ b/src/button.js @@ -355,7 +355,7 @@ $.Button = function( options ) { return true; } - }).setTracking( true ); + }); outTo( this, $.ButtonState.REST ); }; diff --git a/src/buttongroup.js b/src/buttongroup.js index 7505af0a..49cc9c2e 100644 --- a/src/buttongroup.js +++ b/src/buttongroup.js @@ -105,7 +105,7 @@ $.ButtonGroup = function( options ) { } } }, - }).setTracking( true ); + }); }; $.ButtonGroup.prototype = /** @lends OpenSeadragon.ButtonGroup.prototype */{ diff --git a/src/mousetracker.js b/src/mousetracker.js index 609fde7b..ec677fb7 100644 --- a/src/mousetracker.js +++ b/src/mousetracker.js @@ -54,6 +54,9 @@ * @param {Element|String} options.element * A reference to an element or an element id for which the pointer/key * events will be monitored. + * @param {Boolean} [options.startDisabled=false] + * If true, event tracking on the element will not start until + * {@link OpenSeadragon.MouseTracker.setTracking|setTracking} is called. * @param {Number} options.clickTimeThreshold * The number of milliseconds within which a pointer down-up event combination * will be treated as a click gesture. @@ -257,6 +260,9 @@ currentPinchCenter: null }; + if ( !options.startDisabled ) { + this.setTracking( true ); + } }; $.MouseTracker.prototype = /** @lends OpenSeadragon.MouseTracker.prototype */{ diff --git a/src/navigator.js b/src/navigator.js index fb0756e8..62136d03 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -210,7 +210,7 @@ $.Navigator = function( options ){ clickHandler: $.delegate( this, onCanvasClick ), releaseHandler: $.delegate( this, onCanvasRelease ), scrollHandler: $.delegate( this, onCanvasScroll ) - }).setTracking( true ); + }); }; diff --git a/src/referencestrip.js b/src/referencestrip.js index a872ca58..480009ec 100644 --- a/src/referencestrip.js +++ b/src/referencestrip.js @@ -127,7 +127,7 @@ $.ReferenceStrip = function ( options ) { exitHandler: $.delegate( this, onStripExit ), keyDownHandler: $.delegate( this, onKeyDown ), keyHandler: $.delegate( this, onKeyPress ) - } ).setTracking( true ); + } ); //Controls the position and orientation of the reference strip and sets the //appropriate width and height @@ -215,7 +215,7 @@ $.ReferenceStrip = function ( options ) { viewer.goToPage( page ); } } - } ).setTracking( true ); + } ); this.element.appendChild( element ); @@ -447,8 +447,10 @@ function loadPanels( strip, viewerSize, scroll ) { style.width = ( strip.panelWidth - 4 ) + 'px'; style.height = ( strip.panelHeight - 4 ) + 'px'; + // TODO: What is this for? Future keyboard navigation support? miniViewer.displayRegion.innerTracker = new $.MouseTracker( { - element: miniViewer.displayRegion + element: miniViewer.displayRegion, + startDisabled: true } ); element.getElementsByTagName( 'div' )[0].appendChild( diff --git a/src/viewer.js b/src/viewer.js index 04587719..865a92a5 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -297,6 +297,7 @@ $.Viewer = function( options ) { this.innerTracker = new $.MouseTracker({ element: this.canvas, + startDisabled: this.mouseNavEnabled ? false : true, clickTimeThreshold: this.clickTimeThreshold, clickDistThreshold: this.clickDistThreshold, dblClickTimeThreshold: this.dblClickTimeThreshold, @@ -316,17 +317,18 @@ $.Viewer = function( options ) { nonPrimaryReleaseHandler: $.delegate( this, onCanvasNonPrimaryRelease ), scrollHandler: $.delegate( this, onCanvasScroll ), pinchHandler: $.delegate( this, onCanvasPinch ) - }).setTracking( this.mouseNavEnabled ? true : false ); // default state + }); this.outerTracker = new $.MouseTracker({ element: this.container, + startDisabled: this.mouseNavEnabled ? false : true, clickTimeThreshold: this.clickTimeThreshold, clickDistThreshold: this.clickDistThreshold, dblClickTimeThreshold: this.dblClickTimeThreshold, dblClickDistThreshold: this.dblClickDistThreshold, enterHandler: $.delegate( this, onContainerEnter ), exitHandler: $.delegate( this, onContainerExit ) - }).setTracking( this.mouseNavEnabled ? true : false ); // always tracking + }); if( this.toolbar ){ this.toolbar = new $.ControlDock({ element: this.toolbar }); diff --git a/test/events.js b/test/events.js index 5f850082..677e805f 100644 --- a/test/events.js +++ b/test/events.js @@ -790,7 +790,7 @@ releaseHandler: onMouseTrackerRelease, clickHandler: onMouseTrackerClick, exitHandler: onMouseTrackerExit - } ).setTracking( true ); + } ); var event = { clientX:1,