noeldelgado / gemini-scrollbar

:first_quarter_moon: Custom overlay-scrollbars with native scrolling mechanism for web applications
https://noeldelgado.github.io/gemini-scrollbar/
MIT License
429 stars 63 forks source link

add test to see if scrollbar is needed #43

Open amaau opened 7 years ago

amaau commented 7 years ago

in update function, something like

this._viewElement.style.height = ((this.element.offsetHeight + SCROLLBAR_WIDTH).toString() + 'px');
this._viewElement.style.width = ((this.element.offsetWidth + SCROLLBAR_WIDTH).toString() + 'px');

const needY = this.element.offsetHeight < this._viewElement.scrollHeight;
const needX = this.element.offsetWidth <  this._viewElement.scrollWidth;

if (needY){
    if (!this.needY) this._scrollbarVerticalElement.style.display = '';
    //here all thumb size calculation
}else if (this.needY){
    this._scrollbarVerticalElement.style.display = 'none';
}
this.needY = needY

//samething for needX

if (needX || needY) this._scrollHandler();
return this;