Giter VIP home page Giter VIP logo

jquery-mousewheel's People

Contributors

adunkman avatar bowlofeggs avatar brandonaaron avatar can3p avatar chriscbrock avatar dependabot[bot] avatar dmethvin avatar evanhahn avatar jamesplease avatar kyleguate avatar mgol avatar scottgonzalez avatar vitch avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-mousewheel's Issues

ctrl + wheel in chrome

Nice extension but, default ctrl + wheel behavior (zoom) cannot be overriden in chrome browser, mousewheel event is not triggered. Is there any solution ?

Regards,
Cleoo

Scroll (preventdefault) on firefox 17 not working properly

(Originally reported this at the jScrollPane repo: vitch/jScrollPane#198)

I just noticed that at least I am facing a problem with the mouse scroll on Firefox 17: Scrolling the content area with the mouse wheel etc. will also scroll the whole page. This seems to apply to the examples included with jScrollPane and jQuery Mousewheel as well, specifically Test#2 (prevent default) is not working properly. Works normal on Firefox 16, Chrome and Safari.

Using jScrollPane v2.0.0beta12 - 2012-09-27, jQuery Mousewheel.js 3.0.6, Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:18.0) Gecko/20100101 Firefox/18.0

I'm guessing this is related to the new Wheel Event in FF17: https://wiki.mozilla.org/Gecko:Mouse_Wheel_Scrolling#DOM_mouse_wheel_events_and_Default_action

Scrolling over an iframe

I'm having issues with the plugin when scrolling inside an iframe in IE. I realize that when you scroll over an iframe the iframe captures the scroll event, but jquery ui draggable has an "iframefix" option that, from what I was able to see, wraps the iframe in a div or adds some sort of shim to the iframe. Not sure if anyone would be willing to look into something like this.

The mousewheel won't work when the content is long.

The mousewheel won't work when the content is long.
For example:
Download the jquery-mousewheel-3.0.6.zip file. Unzip the file, and change the "simple_example.html", copy the content "<p>Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. </p>" and paste it about 500 times.Then open the "simple_example.html" with chrome or ff.The mousewheel won't work.

Page scroll over input field after page reload (F5)

I am trying to use the mousewheel on an input field with the jQuery.ui spinner (http://jqueryui.com/spinner/#default). But after a page reload (F5) it don't just change the value on the input field but also scrolls the page which it shouldn't. On the jQuery.ui demo site it looks to work but on my test site the error occure. Firefox 16.0.2, jQuery 1.8.2, jQuery UI 1.9.0, In Chrome it seems to work.

Fix: jQuery 1.7.2 event fix for FF/IE

Not sure if this plugin is still being developed?

I have recently used this with jScrollPane and noticed that it doesn't work in FF/IE when using jQuery 1.7.2. I spent some time and figured out why that was and the fix is pretty easy

add the following lines

        /* Aaron fix */
        if (orgEvent.detail) { delta = -orgEvent.detail / 3; }
        if (orgEvent.wheelDelta) { delta = orgEvent.wheelDelta / 120; }

... right below

        // Old school scrollwheel delta
        if (event.wheelDelta) { delta = event.wheelDelta / 120; }
        if (event.detail) { delta = -event.detail / 3; }

As there hasn't been any updates in over 8 months and there are 3 pull requests, I may fork this and update

normalizing velocity

the best reference for how to do this is the google closure library, the file youll want to look at is mousewheelhandler.js i have ported one aspect of how they normalize velocity.... see below. Seems to work nicely.

/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.4
 *
 * Requires: 1.2.2+
 */


// need chrome visibility to fix scroll variances
(function($) {
    var userAgent = navigator.userAgent.toLowerCase();
    $.browser.chrome = /chrome/.test(userAgent);
})(jQuery);


(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

$.event.special.mousewheel = {
    setup: function() {
        if ( this.addEventListener ) {
            for ( var i=types.length; i; ) {
                this.addEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = handler;
        }
    },

    teardown: function() {
        if ( this.removeEventListener ) {
            for ( var i=types.length; i; ) {
                this.removeEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = null;
        }
    }
};

$.fn.extend({
    mousewheel: function(fn) {
        return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
    },

    unmousewheel: function(fn) {
        return this.unbind("mousewheel", fn);
    }
});


function handler(event) {
    var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
    event = $.event.fix(orgEvent);
    event.type = "mousewheel";


    // Old school scrollwheel delta
    if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
    if ( event.detail     ) { delta = -event.detail/3; }

    // New school multidimensional scroll (touchpads) deltas
    deltaY = delta;

    // Gecko
    if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
        deltaY = 0;
        deltaX = -1*delta;
    }

    // Webkit
    var wheelDeltaScaleFactor = 1;
    console.log(jQuery.browser);
    if (jQuery.browser.msie || (jQuery.browser.webkit && !jQuery.browser.chrome)) {
      wheelDeltaScaleFactor = 40;
    }

    if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120/wheelDeltaScaleFactor; }
    if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120/wheelDeltaScaleFactor; }

    // Add event and delta to the front of the arguments
    args.unshift(event, delta, deltaX, deltaY);

    return $.event.handle.apply(this, args);
}

})(jQuery);

Slow Down Mousewheel Speed

Hello. I want to dramatically slow down speed of mousewheel. It move too fast with mousewheel.

I try look for delta I can change, but cannot find any delta to edit.

What I can edit to make mousewheel move very slowly? Thank you.

Firefox 16.0.1 problem deltaX, deltaY missing

Problem with FF 16.0.1 version, deltaX and deltaY are NaN in mousewheel callback.
orgEvent doesn't have this values and defaults should be provided.
I've resolved this issue adding else statements like this:

// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; }
else deltaY = delta;
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; }
else deltaX = delta;

I don't know if this known FF problem or my portable FF issue, but the code above works fine.

Horizontal wheel-ing

Will the plugin support "horizontal" wheel-ing that you get
on, say, the MacBook notebooks when you swipe horizontally.

Thanks,
--P

Support wheel event

The DOM standard has a new 'wheel' event. This supports X and Y deltas and pixel/line/page scrolling. IIRC it's already implemented by WebKit and IE10 and Gecko is also working on implementing it.

Prevent Default only on deltaX

Hello, I tried to prevent default event only when scroll on X axis, without success.. What can I do to keep my page with deltaY default scrolling, and overwrite only deltaX default event?

Thanks

Scroll up/down x time faster than the version 3.0.6 on OSX

Hello,

I've made an update from 3.0.6 to the 3.1.3 and i notice a real problem on mac (safari or chrome).

The scroll up / down value is many time faster than the debian / windows version.

I've tried to put the /3 and /120 in the newest code, but seems not better,

i'll dig deeper soon to let you know, because i've not a mac right now

Thanks for your time and code,

JB

Bug while scrolling

Hi Aaron. I think I've found a bug. I get an odd blank area on the top of the control. Here's how I get it: I scroll down using the scrollbar at the right (not the mousewheel) and, while keeping the left mouse button pressed, I move it out of the control, which makes it disappear. This is the right behaviour, but when I move the mouse back into the control, a big blank space appears at the top.
I have tested it with 16 elements in scroll-bar, and what I can see is that "top" value for

is 100px instead of 0px.

Thanks!

Add support to disable default event

Hey thanks for the great jquery extension.

I noticed that the page still scrolls even if there is a mouse wheel event being triggered.

By adding two lines to your js file, I was able to disable this

https://gist.github.com/1519200

Just seeing if this is something that you'd like to incorporate into your project (possibly with a flag toggling this). I'm fine w/ distributing this change under the MIT license.

Too slow scrolling

it always scrolls pixel by pixel, no matter how tall content is
tested on FF 22, Chrome 28 with jquery 1.10.1

delay in picking up mousewheel event in Firefox 14

Tried a simple test in Firefox 14, Chrome 21, and IE9.

When I try to disable document scroll, it scrolls like 1-3 lines in Firefox 14 before stopping. In Chrome 21 and IE9, disabling document scroll prevents me from scrolling at all, period.

$(document).bind('touchmove mousewheel', function(event) {
    event.preventDefault();
});

Recreated in jsFiddle http://jsfiddle.net/2qrTF/

Move delta args inside event object

The reasoning is simple. Imagine having a scrollable element and a separate element, emulating a scrollbar. Mousewheel events on the scrollbar should trigger target element's mousewheel event, but a simple call to trigger is impossible due to the fact that delta parameters cannot be passed on.

Now if delta params are inside the event object, then proxying the event is as simple as

$('#scrollbar').on('mousewheel', function (event) {
    $('#scrollable-element').trigger($.extend($.Event('mousewheel'), {
        delta: event.delta,
        deltaX: event.deltaX,
        deltaY: event.deltaY
    }));
});

osx inertia

hi!

when using a trackpad or a magic mouse multiple events are triggered for every touch-scroll, sometimes taking as long as 1-2 seconds to stop, depending the scrolling "speed" and due to the inertia setting on mac osx.

I'm using mousewheel in a scenario where I move through news items on mousewheel and ideally I only want to move by on one each mousewheel action on windows, one each touch-scroll gesture on a mac trackpad.

The multiple events triggered make this impossible to do. I've tried unbinding and rebinding but as soon as I rebind the events triggered by the touch action before the unbind keep getting detected. I've tried filtering the delta to only scroll if it's between 2 values but its making the scroll very unreliable. Rebinding mousewheel only after the inertia events stop is also an impossibility because it would mean only allowing one scroll every two seconds.

do you have any ideas on how to overcome this?

Scroll speed / velocity in Webkit based browsers to fast

Hi Brandon,

Thanks for your great plugin, I found that the velocity returned for the latest Webkit browsers is to high. The following mod seems to do the trick:

// Webkit
// Currently the latest WebKit browsers need a value of 2700 instead of 120
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/2700; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/2700; }

Cheers,
Joost

mousewheel over text...

I don't know if it's really a issue, for me it is.

Look at: http://brandonaaron.net/code/mousewheel/demos

if you mousewheel inside the webpage (not inside the box), all of the content is moved;
If you mousewheel inside the box, only the text is changed and the webpage don't move at all;

It happens only if you mousewheel the webpage and then mousewheel OVER THE TEXT inside the box, the text is changed AND the webpage moves too, the same occours in the text field.

Horizontal Scrolling in IE

Im running this on ie8 and ie9 with a mighty mouse in parallels, the horizontal scroll seems to work in other areas of the OS just not in ie8 or ie9 (I havent tested elsewhere). Has anyone seen any evidence of being able to detect a horizontal mousewheel event on ANY element IE? I've been looking most of the day and have come up with nothing.

Ver 3.0.4 IE7 Invisible #logger in test

In the IE7 browser the #logger element is not visible, thus no log is present and it seems like wheel event is not working. After removing position:absolute; from css, i was able to see the test log.

IE8

I'm getting an error in IE8 saying 'axis' is null or not an object. Line 64 char 5. Is it you or me??

Functionality on iPhone/iPad

If you try to press scroll button it doesn't work, If you double tap an area thats not around the button it will goto that, but not the same way as with a mouse.

delta normalization between chrome & ff (osx)

(I apologize if this is covered by one of the existing normalization issues, but all of them are closed and I'm seeing this with the 3.0.6 version of the plugin)

Running Chrome 15.0.874.121 and Firefox 8.0 on OSX 10.6.8; testing with a mighty mouse scroll ball.
A single scroll click registers as 0.25 delta with Chrome, but 0.3333 with Firefox; the difference is about 30% which is very noticeable.

Not working with jQuery 1.7+

It seems that Mousewheel doesn't work anymore with jQuery 1.7+, at least using Aurora 10 and Mac OSX.
Falling back to jQuery 1.6.4 fixes the issue.

Event for [up + down] and [left + right] separately?

I have a small example of mousewheel running and the up / down scroll works beautifully to force a left / right scroll, however the actual left/right scroll with my macbook trackpad is very glitchy. Is there any way to preventDefault() for only up / down scroll and let the browse control left / right.

        $(document).ready(function(){

            $("body").mousewheel(function(event, delta, deltaX, deltaY) {

                event.preventDefault();

                this.scrollLeft -= (delta * 20);

                console.log(delta, deltaX, deltaY);

                //this.scrollLeft -= (delta * 30);

            });

        });

Chrome vs Firefox velocity on OSX

Hi Brandon,

Thanks for your work on the jquery mousewheel plugin. I am plannin on using it to provide mousewheel scrolling for a horizontal site.

On the demo page I see a velocity of a bout 25 with Chrome and about 1.3 in Firefox. It seems the delta needs to be multiplied to get a typical scrolling experience (by around 30). But this the scrolling over sensitive in Chrome. Maybe this is specific to Chrome on OSX.

Regards, Mark

Middle Click (Wheel Click) Event is not handled

Scrolling mouse wheel up /down gives a positive/negative wheelDelta value respectively but when I click the wheel (which enables auto scroll) and move the mouse around, nothing happens. Is it a bug or this feature is not implemented yet?

Event on input fields fired before value changes

Not sure if this is by design or a bug but the mousewheel event on input fields (e.g. an <input type="number">) is fired before the value of the field changes. For example when you use the mouse wheel to scroll through numbers.

Example

Accessing the value of the field through val() in the mousewheel callback returns the previous, old value.

jQuery version 1.7.1, mousewheel version 3.0.6

mousewheel doesn't work in IE10

Hello,
in IE10 the code above always returns "0,0,0"

$("body").mousewheel(function (event, delta, deltaX, deltaY) {
console.log(delta, deltaX, deltaY);
});

IE8 no longer supported ?

If I'm not mistaken, it seems to me that IE8 is not supported.

What can I do to have mousewheel working with IE8 ? I tried a lot of solutions tweaking your code these last days, without results and I despair...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.