From a04a5a1d7c03a3084efcd48b0d28d2f416100528 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 23 Aug 2018 14:22:35 +0530 Subject: [PATCH] fix(columnWidth): Compensate for scrollbar only if there is vertical scroll --- src/dom.js | 4 ++++ src/style.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/dom.js b/src/dom.js index 8c3f91d..c08ff85 100644 --- a/src/dom.js +++ b/src/dom.js @@ -200,3 +200,7 @@ $.scrollbarWidth = function scrollbarWidth() { return scrollbarWidth; }; + +$.hasVerticalOverflow = function (element) { + return element.scrollHeight > element.offsetHeight + 10; +}; diff --git a/src/style.js b/src/style.js index 118e85c..d91be24 100644 --- a/src/style.js +++ b/src/style.js @@ -206,6 +206,8 @@ export default class Style { } compensateScrollbarWidth() { + if (!$.hasVerticalOverflow(this.bodyScrollable)) return; + requestAnimationFrame(() => { const scrollbarWidth = $.scrollbarWidth(); const lastCol = this.datamanager.getColumn(-1);