Package org.timepedia.chronoscope.client.browser.event

Source Code of org.timepedia.chronoscope.client.browser.event.ChartMouseWheelHandler

/**
*
*/
package org.timepedia.chronoscope.client.browser.event;

import com.google.gwt.event.dom.client.MouseWheelHandler;
import com.google.gwt.event.dom.client.MouseWheelEvent;

import org.timepedia.chronoscope.client.Chart;

/**
* Handles the event where the user scrolls the mouse wheel.
*
* @author Chad Takahashi
*/
public class ChartMouseWheelHandler extends AbstractEventHandler<MouseWheelHandler> implements MouseWheelHandler {

  public void onMouseWheel(MouseWheelEvent event) {
    try {
      ChartState chartInfo = getChartState(event);
      Chart chart = chartInfo.chart;

      int wheelDir = event.getNativeEvent().getMouseWheelVelocityY();
      boolean isMouseWheelUp = (wheelDir <= 0);
      if (isMouseWheelUp) {
        chart.nextZoom();
      }
      else {
        chart.prevZoom();
      }
     
      chartInfo.setHandled(true);
     
    } catch (Exception e) {
      e.printStackTrace();
    }
   
    // Do not move scroll
    event.preventDefault();
  }

}
TOP

Related Classes of org.timepedia.chronoscope.client.browser.event.ChartMouseWheelHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.