Skip to content

Commit

Permalink
feat: apply width to placeholder only if required (ref #253 #243)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grsmto committed Apr 8, 2019
1 parent f2ebb29 commit 0c7659f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/simplebar/src/simplebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand All @@ -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} -${
Expand Down

0 comments on commit 0c7659f

Please sign in to comment.