From 423e2abf779981ff9d17a9998c1da1a0c9d16ce3 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 11 Feb 2015 12:05:28 +0000 Subject: [PATCH] Fix mousewheel handler on indicators in expose view causes problem, and not working in FF --- etemplate/js/expose.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/etemplate/js/expose.js b/etemplate/js/expose.js index 136f3ec0af..1fb3353311 100644 --- a/etemplate/js/expose.js +++ b/etemplate/js/expose.js @@ -440,23 +440,9 @@ function expose (widget) var total_count = nm.controller._grid.getTotalCount(); if(total_count >= gallery.num) { - gallery.container.find('.indicator').off() + var $indicator = gallery.container.find('.indicator'); + $indicator.off() .addClass('paginating') - .mousewheel(function(event, delta) { - if(delta > 0 && parseInt($j(this).css('left')) > gallery.container.width() / 2) return; - - //Reload next pictures into the gallery by scrolling on thumbnails - if (delta<0 && $j(this).width() + parseInt($j(this).css('left')) < gallery.container.width()) - { - var nextIndex = gallery.indicatorContainer.find('[title="loading"]')[0]; - if (nextIndex) self.expose_onslideend(gallery,nextIndex.dataset.index -1); - return; - } - // Move it about 5 indicators - $j(this).css('left',parseInt($j(this).css('left'))-(-delta*gallery.activeIndicator.width()*5)+'px'); - - event.preventDefault(); - }) .swipe(function(event, direction, distance) { if(direction == jQuery.fn.swipe.directions.LEFT) { @@ -472,6 +458,23 @@ function expose (widget) } $j(this).css('left',min(0,parseInt($j(this).css('left'))-(distance*30))+'px'); }); + // Bind the mousewheel handler for FF (DOMMousewheel), and other browsers (mousewheel) + $indicator.bind('mousewheel DOMMousewheel',function(event, _delta) { + var delta = _delta || event.originalEvent.wheelDelta / 120; + if(delta > 0 && parseInt($j(this).css('left')) > gallery.container.width() / 2) return; + + //Reload next pictures into the gallery by scrolling on thumbnails + if (delta<0 && $j(this).width() + parseInt($j(this).css('left')) < gallery.container.width()) + { + var nextIndex = gallery.indicatorContainer.find('[title="loading"]')[0]; + if (nextIndex) self.expose_onslideend(gallery,nextIndex.dataset.index -1); + return; + } + // Move it about 5 indicators + $j(this).css('left',parseInt($j(this).css('left'))-(-delta*gallery.activeIndicator.width()*5)+'px'); + + event.preventDefault(); + }); } } },