From f7a10eed3a8c7f8c249e5798a62a3c08568220db Mon Sep 17 00:00:00 2001 From: Etienne Pigeyre Date: Mon, 25 Sep 2017 17:16:36 +0200 Subject: [PATCH] Add a forceDisplay option for indicators If you are working with indicators for parallax effect on a responsive website (especially with horizontal navigation) you might want to prevent the indicators to be hidden when the container is not big enough to scroll. In this case, I've added the 'forceDisplay' option for the indicator. Just use 'forceDisplay: true' in the indicator option array. --- build/iscroll-probe.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/iscroll-probe.js b/build/iscroll-probe.js index 68e9e43a..6761e131 100644 --- a/build/iscroll-probe.js +++ b/build/iscroll-probe.js @@ -1044,6 +1044,7 @@ IScroll.prototype = { _initIndicators: function () { var interactive = this.options.interactiveScrollbars, customStyle = typeof this.options.scrollbars != 'string', + forceDisplay, indicators = [], indicator; @@ -1062,6 +1063,7 @@ IScroll.prototype = { resize: this.options.resizeScrollbars, shrink: this.options.shrinkScrollbars, fade: this.options.fadeScrollbars, + forceDisplay:false, listenX: false }; @@ -1079,6 +1081,7 @@ IScroll.prototype = { resize: this.options.resizeScrollbars, shrink: this.options.shrinkScrollbars, fade: this.options.fadeScrollbars, + forceDisplay: false, listenY: false }; @@ -2006,11 +2009,11 @@ Indicator.prototype = { refresh: function () { this.transitionTime(); - if ( this.options.listenX && !this.options.listenY ) { + if ( !this.options.forceDisplay && this.options.listenX && !this.options.listenY ) { this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none'; - } else if ( this.options.listenY && !this.options.listenX ) { + } else if ( !this.options.forceDisplay && this.options.listenY && !this.options.listenX ) { this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none'; - } else { + } else if ( !this.options.forceDisplay ) { this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none'; }