From 1d315786a09b72066874c80660be5d6801a62fa8 Mon Sep 17 00:00:00 2001 From: Hyunje Alex Jun Date: Mon, 15 Sep 2014 21:45:27 +0100 Subject: [PATCH] Hide scrollbars while updating to stop affecting geometries. Scrollbars keep affecting the geometries and it leads to wrong scrollWidth and scrollHeight. So hide them in advance and show them again after updating. --- src/perfect-scrollbar.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index cb7114d..fc4f868 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -201,6 +201,10 @@ }; var updateBarSizeAndPosition = function () { + // Hide scrollbars not to affect scrollWidth and scrollHeight + $scrollbarXRail.hide(); + $scrollbarYRail.hide(); + containerWidth = settings.includePadding ? $this.innerWidth() : $this.width(); containerHeight = settings.includePadding ? $this.innerHeight() : $this.height(); contentWidth = $this.prop('scrollWidth'); @@ -238,6 +242,10 @@ } updateScrollbarCss(); + + // Show scrollbars again after updated + $scrollbarXRail.show(); + $scrollbarYRail.show(); }; var bindMouseScrollXHandler = function () {