Search code examples
javascriptgoogle-chromegwtdom-events

How to catch Zoom event with GWT and Chrome


I've seen there is much conversation about how to get the current zoom factor in the browser, but I haven't found out why this snippet works in Firefox, and not in Chrome.

public class MyComposite extends Composite
{
  public MyComposite()
  {
    HTMLPanel panel = new HTMLPanel("<applet>...</applet>");
    panel.addDomHandler(new MouseWheelHandler()
    {
        @Override
        public void onMouseWheel(MouseWheelEvent event)
        {
            event.stopPropagation();
            event.preventDefault();
        }
    }, MouseWheelEvent.getType());
    initWidget(panel);
  }
}

In both browsers, when I scroll inside the div containing the applet, the scroll is not propagated to the parent (which is fine). And when I scroll outside of the div, the window is scrolled (which is also fine).

But when I do Ctrl+MouseWheel, in Firefox the zoom event is caught by the handler and not propagated whereas in Chrome the handler seems not to be called, and the event is then propagated. I would like to stop the propagation in Chrome as well.

Is there a bug in Chrome or am I doing something wrong ?


Solution

  • Late heads-up : this seems to be a bug in Chrome. I filed a report a couple of years ago but it seems not to be a priority for them. If you stumble upon this post and you want that "feature" too, please leave a message on that report, maybe it will speed up the things...