Is there a way to prevent my slider from continuously scrolling? I think it has something to do with the offset parameter but I'm having trouble figuring it out. Any assistance would be greatly appreciated.
var $container = $(container);
var resizeFn = function () {
var small = $(window).width() < 800;
$container.toggleClass('four', small).toggleClass('six', !small);
}
var toggleButtons = function () {
}
var nextPane = function (e) {
e && e.preventDefault();
var $container = $(this).closest('.grid-container');
var $items = $('.items', $container);
var offset = $items.css('marginLeft').replace('px', '');
var width = $container.width() + parseInt($('.item', $container).css('marginRight').replace('px', ''));
$items.css('marginLeft', offset - width);
}
var prevPane = function (e) {
e && e.preventDefault();
var $container = $(this).closest('.grid-container');
var $items = $('.items', $container);
var offset = $items.css('marginLeft').replace('px', '');
var width = $container.width() + parseInt($('.item', $container).css('marginRight').replace('px', ''));
$items.css('marginLeft', offset + width);
}
resizeFn();
$(window).resize(resizeFn);
$('.next', $container).click(nextPane);
$('.prev', $container).click(prevPane);