Created
January 26, 2012 15:41
-
-
Save datamosh/1683324 to your computer and use it in GitHub Desktop.
jQuery Scroll fix for messiha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$('#timeline').mousedown(function (event) { | |
// Form fix! | |
var target = $(event.target); if(target.attr('type') != undefined) target.focus(); | |
$(this) | |
.data('down', true) | |
.data('x', event.clientX) | |
.data('scrollLeft', this.scrollLeft); | |
return false; | |
}).mouseup(function (event) { | |
$(this).data('down', false); | |
}).mousemove(function (event) { | |
if ($(this).data('down') == true) { | |
this.scrollLeft = $(this).data('scrollLeft') + ($(this).data('x') - event.clientX) * 2; // twice as fast | |
} | |
}).mousewheel(function (event, delta) { | |
this.scrollLeft -= (delta * 30); | |
}).css({ | |
'overflow' : 'hidden', | |
'cursor' : '-moz-grab' | |
}); | |
}); | |
$(window).mouseout(function (event) { | |
if ($('#timeline').data('down')) { | |
try { | |
if (event.originalTarget.nodeName == 'BODY' || event.originalTarget.nodeName == 'HTML') { | |
$('#timeline').data('down', false); | |
} | |
} catch (e) {} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment