Skip to content

Commit 4d097de

Browse files
committed
add option to use margin-left, margin-top instead of top, left css properties.
1 parent fc1115e commit 4d097de

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/scrollable/scrollable.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
speed: 400,
3434
vertical: false,
3535
touch: true,
36-
wheelSpeed: 0
36+
wheelSpeed: 0,
37+
useMargin: false,
38+
offset: 0
3739
}
3840
};
3941

@@ -169,8 +171,12 @@
169171
fire.trigger(e, [i, time]);
170172
if (e.isDefaultPrevented() || !item.length) { return self; }
171173
}
172-
173-
var props = vertical ? {top: -item.position().top} : {left: -item.position().left};
174+
var props;
175+
if(conf.useMargin) {
176+
props = vertical ? {'margin-top': (conf.offset - (i*item.width())) } : {'margin-left': (conf.offset -(i*item.width())) };
177+
} else {
178+
props = vertical ? {top: (conf.offset - item.position().top)} : {left: (conf.offset - item.position().left)};
179+
}
174180

175181
index = i;
176182
current = self;
@@ -360,6 +366,7 @@
360366
$(this).data("scrollable", el);
361367
});
362368

369+
363370
return conf.api ? el: this;
364371

365372
};

0 commit comments

Comments
 (0)