Skip to content

Instantly share code, notes, and snippets.

@Drnutsu
Created September 17, 2015 17:07
Show Gist options
  • Save Drnutsu/0173131ebedd9bf8cd76 to your computer and use it in GitHub Desktop.
Save Drnutsu/0173131ebedd9bf8cd76 to your computer and use it in GitHub Desktop.
$('#parent').bind('mousewheel', function (e) {
if (!(e.originalEvent.wheelDelta == 120)) {
var top = parseInt($("#child").css("top"));
$("#child").css("top", (top - 100) + "px");
top = parseInt($("#child").css("top"));
if (top <= -500) {
setTimeout(function () {
$("#child").css("top", "-500px");
}, 100);
}
} else {
var top = parseInt($("#child").css("top"));
$("#child").css("top", (top + 100) + "px");
top = parseInt($("#child").css("top"));
if (top >= 0) {
setTimeout(function () {
$("#child").css("top", "0");
}, 100);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment