06/07/2012

Javascript - Testar delta do mouse wheel

<script>
    window.addEventListener('DOMMouseScroll', testaWheel, false);
    window.onmousewheel = testaWheel;
    document.onmousewheel = testaWheel;
    function testaWheel(e) {
        if (!e) // IE
            e = window.event;
        if (e.wheelDelta) { // IE / Opera / Chrome
            delta = e.wheelDelta/120;
        } else if (e.detail) { // Firefox
            delta = -e.detail/3;
        }
    }
</script> 
Exemplo:
Delta =

Nenhum comentário:

Postar um comentário