Pass mousewheel event through fixed content

后端 未结 5 2040
有刺的猬
有刺的猬 2020-12-31 04:42

The best way to understand this is to look at this fiddle.

Notice how mouse wheel over the fixed content in the red box does nothing. I would like the

5条回答
  •  爱一瞬间的悲伤
    2020-12-31 05:28

    I had this problem and this works for me (using jquery):

    $(document).ready( function (){
        $('#fixed').on('mousewheel',function(event) {
            var scroll = $('#container').scrollTop();
            $('#container').scrollTop(scroll - event.originalEvent.wheelDeltaY);
            return true;
        });
    });
    

    Works on Safari and Chrome: http://jsfiddle.net/5bwWe/36/

提交回复
热议问题