#314 ✓not_for_core
ronin-30403 (at lighthouseapp)

Event.stop doesn't work in Safari for mousewheel

Reported by ronin-30403 (at lighthouseapp) | August 29th, 2008 @ 03:21 PM

First a piece of code:


Event.observe(window, 'load', function() {
	Event.observe($('id'), 'mousewheel', Player.onMouseWheel);
	Event.observe($('id'), 'DOMMouseScroll',Player.onMouseWheel);
}


var Player = {
	onMouseWheel: function(e) {
	// doesn't matter
	Event.stop(e);
}

Everything works everywhere, except one case: if you scroll page using two fingers on trackpad (MacBook, MacBook Pro, etc.) in Safari. It seems that Event.stop doesn't work. Not sure, but may be two finder scrolling sends one more event, so we need to stop it as well.

At present moment you can look at the problem here: http://www.songsterr.com/a/wa/so...

Comments and changes to this ticket

  • John-David Dalton

    John-David Dalton August 29th, 2008 @ 04:42 PM

    • State changed from “new” to “not_for_core”

    I think this would make a great extension. Could you patch this in and submit it to Scripteka.com ?

    I know jQuery handles this as a plugin as well.

  • John-David Dalton

    John-David Dalton August 29th, 2008 @ 04:58 PM

    
    
    // Mouse Wheel Detection
    // http://andrewdupont.net/2007/11/07/pseudo-custom-events-in-prototype-16/
    // http://www.simpltry.com/2006/12/27/emulating-mouse-wheel-map-zooming/#more-31
    // usage: $(element).observe('mouse:wheel', function() {...});
    
    (function() {
      function wheel(event) {
        var realDelta;
        //normalize the delta
        if (event.wheelDelta) {
          realDelta = event.wheelDelta / 120; //IE & Opera
        } else if (event.detail) {
          realDelta = -event.detail / 3; //W3C
        } else return;
    
        var customEvent = event.element()
          .fire("mouse:wheel", { delta: realDelta });
    
        if(customEvent.stopped)
          event.stop();
      }
    
      document.observe("mousewheel", wheel)
        .observe("DOMMouseScroll", wheel);
    })();
    
    
  • ronin-30403 (at lighthouseapp)

    ronin-30403 (at lighthouseapp) September 5th, 2008 @ 12:26 AM

    I know jQuery handles this as a plugin as well.

    Actually I've spent a lot of time, but I haven't found solution.

    E.g. this example http://brandonaaron.net/jquery/p... doesn't work for me. I guess we cannot prevent default action of two fingers scrolling on trackpad. Not sure, but maybe it's a Safari bug.

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:10 AM

    • Tag changed from dom, events, safari to events, safari, section:dom

    [not-tagged:"dom" tagged:"section:dom" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:48 AM

    • Tag changed from events, safari, section:dom to events, section:dom

    [not-tagged:"safari" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:43 AM

    • Tag changed from events, section:dom to section:dom

    [not-tagged:"events" bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Pages