From 1dfbbe9e56a50dc56b4128d55f4417c237efd81d Mon Sep 17 00:00:00 2001 From: Hyunje Alex Jun Date: Thu, 10 Dec 2015 13:17:59 +0900 Subject: [PATCH] Set scrollbar size to 0 when inactive Resolve #415 --- src/js/plugin/update-geometry.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/js/plugin/update-geometry.js b/src/js/plugin/update-geometry.js index 8dce8d7..7ae4179 100644 --- a/src/js/plugin/update-geometry.js +++ b/src/js/plugin/update-geometry.js @@ -89,9 +89,6 @@ module.exports = function (element) { i.scrollbarXLeft = h.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth)); } else { i.scrollbarXActive = false; - i.scrollbarXWidth = 0; - i.scrollbarXLeft = 0; - element.scrollLeft = 0; } if (!i.settings.suppressScrollY && i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight) { @@ -102,9 +99,6 @@ module.exports = function (element) { i.scrollbarYTop = h.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight)); } else { i.scrollbarYActive = false; - i.scrollbarYHeight = 0; - i.scrollbarYTop = 0; - updateScroll(element, 'top', 0); } if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) { @@ -116,6 +110,20 @@ module.exports = function (element) { updateCss(element, i); - cls[i.scrollbarXActive ? 'add' : 'remove'](element, 'ps-active-x'); - cls[i.scrollbarYActive ? 'add' : 'remove'](element, 'ps-active-y'); + if (i.scrollbarXActive) { + cls.add(element, 'ps-active-x'); + } else { + cls.remove(element, 'ps-active-x'); + i.scrollbarXWidth = 0; + i.scrollbarXLeft = 0; + updateScroll(element, 'left', 0); + } + if (i.scrollbarYActive) { + cls.add(element, 'ps-active-y'); + } else { + cls.remove(element, 'ps-active-y'); + i.scrollbarYHeight = 0; + i.scrollbarYTop = 0; + updateScroll(element, 'top', 0); + } };