Skip to content

Commit d5de1a8

Browse files
committed
Merge pull request #16 from LearnBoost/options
improvement options parameter
2 parents 686ce85 + 5fdbc2f commit d5de1a8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

antiscroll.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
function Antiscroll (el, opts) {
3333
this.el = $(el);
3434
this.options = opts || {};
35+
36+
this.x = false !== this.options.x;
37+
this.y = false !== this.options.y;
3538
this.padding = undefined == this.options.padding ? 2 : this.options.padding;
39+
3640
this.inner = this.el.find('.antiscroll-inner');
3741
this.inner.css({
3842
'width': '+=' + scrollbarSize()
@@ -51,14 +55,14 @@
5155
var needHScroll = this.inner.get(0).scrollWidth > this.el.width()
5256
, needVScroll = this.inner.get(0).scrollHeight > this.el.height();
5357

54-
if (!this.horizontal && needHScroll) {
58+
if (!this.horizontal && needHScroll && this.x) {
5559
this.horizontal = new Scrollbar.Horizontal(this);
5660
} else if (this.horizontal && !needHScroll) {
5761
this.horizontal.destroy();
5862
this.horizontal = null
5963
}
6064

61-
if (!this.vertical && needVScroll) {
65+
if (!this.vertical && needVScroll && this.y) {
6266
this.vertical = new Scrollbar.Vertical(this);
6367
} else if (this.vertical && !needVScroll) {
6468
this.vertical.destroy();

0 commit comments

Comments
 (0)