diff --git a/ui (gen4)/features/ui-slideshow.js b/ui (gen4)/features/ui-slideshow.js index e2ca38a9..7ef4b01f 100755 --- a/ui (gen4)/features/ui-slideshow.js +++ b/ui (gen4)/features/ui-slideshow.js @@ -288,6 +288,7 @@ module.Slideshow = core.ImageGridFeatures.Feature({ tag: 'ui-slideshow', depends: [ 'ui', + 'ui-control', 'ui-single-image', ], @@ -354,40 +355,41 @@ module.Slideshow = core.ImageGridFeatures.Feature({ return } + var toggle_debounce = false + var hold = this.__slideshow_hold_handler = this.__slideshow_hold_handler - || function(){ - var h = that.__slideshow_holding - - if(h == null && that.toggleSlideshowTimer('?') == 'running'){ - that.__slideshow_holding = 1 - that.suspendSlideshowTimer() - - // handle multiple events stacked... - } else { - that.__slideshow_holding += 1 - } - } + || function(evt){ + !toggle_debounce + && that.toggleSlideshowTimer('?') == 'running' + && that.suspendSlideshowTimer() } var release = this.__slideshow_release_handler = this.__slideshow_release_handler + || function(evt){ + !toggle_debounce + && that.toggleSlideshowTimer('?') != 'running' + && that.resetSlideshowTimer() } + var toggle = this.__slideshow_toggle_handler + = this.__slideshow_toggle_handler || function(){ - var h = that.__slideshow_holding = - // unstack multiple events... - (that.__slideshow_holding || -1) - 1 - - if(h == 0){ - that.resetSlideshowTimer() - delete that.__slideshow_holding + if(!toggle_debounce){ + that.toggleSlideshowTimer() + toggle_debounce = true + setTimeout(function(){ + toggle_debounce = false + }, that.config['image-click-debounce-timeout'] || 100) } } if(this.toggleSlideshow('?') == 'on'){ - this.dom.on('keydown mousedown', hold) - this.dom.on('keydown mouseup', release) + this.dom.on('mousedown', hold) + this.dom.on('mouseup', release) + this.dom.on('tap', toggle) } else { - this.dom.off('keyup mousedown', hold) - this.dom.off('keyup mouseup', release) + this.dom.off('mousedown', hold) + this.dom.off('mouseup', release) + this.dom.off('touchend', toggle) } }] //*/