Esperamos que esta solución es útil para usted ... que funcionará en todos los elementos con nombre de la clase 'scroll- pista'. También debe proporcionar un nuevo atributo al elemento desplazable: datos de desplazamiento = '{ "x": "0", "y": "0"}' puede probarlo aquí: http://jsfiddle.net/CgZDD/
-js-
$(document).ready(function(){
// make sure overflow is set to 'scroll'
$('.scroll-track').css({
overflow: 'scroll'
});
$('.scroll-track').scroll(function() {
var scrollData = $(this).data('scroll');
if(scrollData.y > $(this).scrollTop()){
$('#scrollDir').append($(this).attr('id') + ' up');
}else if(scrollData.y != $(this).scrollTop()){
$('#scrollDir').append($(this).attr('id') + ' down');
}
if(scrollData.x > $(this).scrollLeft()){
$('#scrollDir').append($(this).attr('id') + ' left');
}else if(scrollData.x != $(this).scrollLeft()){
$('#scrollDir').append($(this).attr('id') + ' right');
}
$('#scrollDir').append('<br />');
scrollData.x = $(this).scrollLeft();
scrollData.y = $(this).scrollTop();
$(this).data('scroll', scrollData);
});
});