Skip to content

Instantly share code, notes, and snippets.

@vitaliykononov
Created September 20, 2013 13:45
Show Gist options
  • Save vitaliykononov/6637773 to your computer and use it in GitHub Desktop.
Save vitaliykononov/6637773 to your computer and use it in GitHub Desktop.
Apple Iphone like slider effect with the JQuery Mousewheel Plugin and scrollTo http://www.apple.com/iphone-5s/
var isScrolling = false;
$('.container').mousewheel(function (event, delta) {
if (!isScrolling) {
isScrolling = true;
if (delta < 0) {
if ($next = $('#navbox').find('.active').next('li').children('a').attr('href')) {
$('.container').scrollTo($next, {
offset: 0,
duration: 1000,
onAfter: function () {
isScrolling = false;
}
});
} else
isScrolling = false;
}
else if (delta > 0) {
if ($prev = $('#navbox').find('.active').prev('li').children('a').attr('href')) {
$('.container').scrollTo($prev, {
offset: 0,
duration: 1000,
onAfter: function () {
isScrolling = false;
}
});
} else
isScrolling = false;
}
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment