Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions antiscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,33 @@
, 'height': '+=' + scrollbarSize()
});

if (this.inner.get(0).scrollWidth > this.el.width()) {
this.refresh();
};

/**
* refresh scrollbars
*
* @api public
*/
Antiscroll.prototype.refresh = function() {
var needHScroll = this.inner.get(0).scrollWidth > this.el.width()
, needVScroll = this.inner.get(0).scrollHeight > this.el.height();

if (!this.horizontal && needHScroll) {
this.horizontal = new Scrollbar.Horizontal(this);
} else if (this.horizontal && !needHScroll) {
this.horizontal.destroy();
this.horizontal = null
}

if (this.inner.get(0).scrollHeight > this.el.height()) {
if (!this.vertical && needVScroll) {
this.vertical = new Scrollbar.Vertical(this);
} else if (this.vertical && !needVScroll) {
this.vertical.destroy();
this.vertical = null
}
}

};

/**
* Cleans up.
Expand Down
Loading