From 7040618fd680417a2289455126e1d6089c06067a Mon Sep 17 00:00:00 2001 From: Robert Buels Date: Sat, 3 Nov 2012 11:16:01 -0400 Subject: [PATCH] keep the GenomeView from double-click zooming when rapidly closing a bunch of tracks with their close buttons --- release-notes.txt | 9 ++++++--- src/JBrowse/GenomeView.js | 17 +++++++++++++++++ src/JBrowse/View/Track/BlockBased.js | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/release-notes.txt b/release-notes.txt index 7559e311cb..88013fe24d 100644 --- a/release-notes.txt +++ b/release-notes.txt @@ -88,8 +88,8 @@ zoom in and out. If ALT is added, it zooms further. Thanks to Karsten Hokamp for the excellent suggestion. - * Holding SHIFT while scrolling with the arrow keys causes the view - to scroll further. + * Holding SHIFT while scrolling left and right with the arrow keys + causes the view to scroll further. * Added a `theme` configuration variable to allow changing the graphical theme to something different from the default "tundra". @@ -98,7 +98,10 @@ * Greatly sped up rendering of HTML subfeatures by caching the heights of subfeature HTML elements. - * Fix bug with the genome view scrolling in response to arrow keys + * Fixed bug in which the genome view executed a double-click zoom when + users rapidly clicked on multiple track 'close' buttons. + + * Fixed bug with the genome view scrolling in response to arrow keys being pressed when typing in the location box. 1.6.5 2012-10-26 12:10:08 America/New_York diff --git a/src/JBrowse/GenomeView.js b/src/JBrowse/GenomeView.js index bcafd2bc8f..711ab7f92f 100644 --- a/src/JBrowse/GenomeView.js +++ b/src/JBrowse/GenomeView.js @@ -653,7 +653,24 @@ GenomeView.prototype.afterSlide = function() { this.showVisibleBlocks(true); }; +/** + * Suppress double-click events in the genome view for a certain amount of time, default 100 ms. + */ +GenomeView.prototype.suppressDoubleClick = function( /** Number */ time ) { + + if( this._noDoubleClick ) { + window.clearTimeout( this._noDoubleClick ); + } + + var thisB = this; + this._noDoubleClick = window.setTimeout( + function(){ delete thisB._noDoubleClick; }, + time || 100 + ); +}; + GenomeView.prototype.doubleClickZoom = function(event) { + if( this._noDoubleClick ) return; if( this.dragging ) return; if( "animation" in this ) return; diff --git a/src/JBrowse/View/Track/BlockBased.js b/src/JBrowse/View/Track/BlockBased.js index 45e52dfafd..c7dccfcda4 100644 --- a/src/JBrowse/View/Track/BlockBased.js +++ b/src/JBrowse/View/Track/BlockBased.js @@ -148,6 +148,7 @@ return declare( null, var closeButton = dojo.create('div',{ className: 'track-close-button', onclick: dojo.hitch(this,function(evt){ + this.browser.view.suppressDoubleClick( 100 ); this.browser.publish( '/jbrowse/v1/v/tracks/hide', [this.config]); evt.stopPropagation(); })