From 0c7659fff52aa85881706e363f1922ba27fbfa48 Mon Sep 17 00:00:00 2001 From: Adrien Denat Date: Mon, 8 Apr 2019 08:44:36 -0300 Subject: [PATCH] feat: apply width to placeholder only if required (ref #253 #243) --- packages/simplebar/src/simplebar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/simplebar/src/simplebar.js b/packages/simplebar/src/simplebar.js index f59b17ae..be2fdc5e 100755 --- a/packages/simplebar/src/simplebar.js +++ b/packages/simplebar/src/simplebar.js @@ -244,7 +244,6 @@ export default class SimpleBar { // Save a reference to the instance, so we know this DOM node has already been instancied this.el.SimpleBar = this; - // We stop here on server-side if (canUseDOM) { this.initDOM(); @@ -415,6 +414,7 @@ export default class SimpleBar { recalculate() { const isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1; + const isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1; this.elStyles = window.getComputedStyle(this.el); @@ -425,7 +425,9 @@ export default class SimpleBar { } ${this.elStyles.paddingBottom} ${this.elStyles.paddingLeft}`; this.contentEl.style.height = isHeightAuto ? 'auto' : '100%'; - this.placeholderEl.style.width = `${this.contentEl.scrollWidth}px`; + this.placeholderEl.style.width = isWidthAuto + ? `${this.contentEl.scrollWidth}px` + : 'auto'; this.placeholderEl.style.height = `${this.contentEl.scrollHeight}px`; this.wrapperEl.style.margin = `-${this.elStyles.paddingTop} -${