From 545997bace25950a11942d9afc4e026cd9e631e1 Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Tue, 20 Jan 2015 18:35:58 -0800 Subject: [PATCH] MouseTracker now defaults to tracking on (#558) --- changelog.txt | 1 + src/button.js | 2 +- src/buttongroup.js | 2 +- src/mousetracker.js | 6 ++++++ src/navigator.js | 5 +++-- src/referencestrip.js | 8 +++++--- src/viewer.js | 6 ++++-- test/events.js | 2 +- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/changelog.txt b/changelog.txt index e6c0369e..6412a2b0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -21,6 +21,7 @@ OPENSEADRAGON CHANGELOG * Arrow key navigation fixed across platforms (#565) * Removed textarea element from viewer DOM. Viewer.canvas now handles keyboard navigation (#569) * Removed 'position' property from MouseTracker keyDownHandler/keyUpHandler/keyHandler functions (#573) +* 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 86e87076..20f58541 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 9e18d6ca..7c25b742 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -174,16 +174,17 @@ $.Navigator = function( options ){ clickHandler: $.delegate( this, onCanvasClick ), releaseHandler: $.delegate( this, onCanvasRelease ), scrollHandler: $.delegate( this, onCanvasScroll ) - }).setTracking( true ); + }); /*this.displayRegion.outerTracker = new $.MouseTracker({ element: this.container, + startDisabled: this.mouseNavEnabled ? false : true, clickTimeThreshold: this.clickTimeThreshold, clickDistThreshold: this.clickDistThreshold, enterHandler: $.delegate( this, onContainerEnter ), exitHandler: $.delegate( this, onContainerExit ), releaseHandler: $.delegate( this, onContainerRelease ) - }).setTracking( this.mouseNavEnabled ? true : false ); // always tracking*/ + });*/ viewer.addControl( 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,