/*
---------------------------------------------------------------------------
EVENT CALLBACKS
---------------------------------------------------------------------------
 
Mouse wheel handler for zooming support
194126
function(wheelDelta, timeStamp, pageX, pageY) {

			var self = this;
			var change = wheelDelta > 0 ? 0.97 : 1.03;

			return self.zoomTo(self.__zoomLevel * change, false, pageX - self.__clientLeft, pageY - self.__clientTop);

		}
829730
function ( MouseEvent ) { 
		var ZoomBounds = _Pins.LatLngBounds;
		if ( ZoomBounds.isValid ( ) ) {
			_Map.fitBounds ( ZoomBounds );
		}
		MouseEvent.stopPropagation ( );
	}
1249650
function handleWheelEvent( tracker, event, originalEvent ) {
        var nDelta = 0,
            propagate;

        // The nDelta variable is gated to provide smooth z-index scrolling
        //   since the mouse wheel allows for substantial deltas meant for rapid
        //   y-index scrolling.
        // event.deltaMode: 0=pixel, 1=line, 2=page
        // TODO: Deltas in pixel mode should be accumulated then a scroll value computed after $.DEFAULT_SETTINGS.pixelsPerWheelLine threshold reached
        nDelta = event.deltaY < 0 ? 1 : -1;

        if ( tracker.scrollHandler ) {
            propagate = tracker.scrollHandler(
                {
                    eventSource:          tracker,
                    pointerType:          'mouse',
                    position:             getMouseRelative( event, tracker.element ),
                    scroll:               nDelta,
                    shift:                event.shiftKey,
                    isTouchEvent:         false,
                    originalEvent:        originalEvent,
                    preventDefaultAction: false,
                    userData:             tracker.userData
                }
            );
            if ( propagate === false ) {
                $.cancelEvent( originalEvent );
            }
        }
    }
883351
@Override
	public void onMouseUp(MouseUpEvent event) {
		// handle click if any?
		if (dragging) {
			// shift or CTRL is used when depressed either at beginning or end:
			shiftOrCtrl = (event.isShiftKeyDown() || event.isControlKeyDown());

			if (timestamp + clickTimeout > new Date().getTime()
					&& (bounds.getWidth() < pixelTolerance || bounds.getHeight() < pixelTolerance)) {
				stopDragging();
				// click behavior instead of drag
				ToggleSelectionAction action = new ToggleSelectionAction(mapWidget, priorityToSelectedLayer,
						pixelTolerance);
				action.toggle(getScreenPosition(event), !shiftOrCtrl);
				return;
			}
		}
		// normal "rectangle" handling
		super.onMouseUp(event);
	}
1275781
function zoomTo(ratio, pivot, _originalEvent) {
    var options = this.options,
        canvasData = this.canvasData;
    var width = canvasData.width,
        height = canvasData.height,
        naturalWidth = canvasData.naturalWidth,
        naturalHeight = canvasData.naturalHeight;


    ratio = Number(ratio);

    if (ratio >= 0 && this.ready && !this.disabled && options.zoomable) {
      var newWidth = naturalWidth * ratio;
      var newHeight = naturalHeight * ratio;

      if (dispatchEvent(this.element, EVENT_ZOOM, {
        originalEvent: _originalEvent,
        oldRatio: width / naturalWidth,
        ratio: newWidth / naturalWidth
      }) === false) {
        return this;
      }

      if (_originalEvent) {
        var pointers = this.pointers;

        var offset = getOffset(this.cropper);
        var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
          pageX: _originalEvent.pageX,
          pageY: _originalEvent.pageY
        };

        // Zoom from the triggering point of the event
        canvasData.left -= (newWidth - width) * ((center.pageX - offset.left - canvasData.left) / width);
        canvasData.top -= (newHeight - height) * ((center.pageY - offset.top - canvasData.top) / height);
      } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
        canvasData.left -= (newWidth - width) * ((pivot.x - canvasData.left) / width);
        canvasData.top -= (newHeight - height) * ((pivot.y - canvasData.top) / height);
      } else {
        // Zoom from the center of the canvas
        canvasData.left -= (newWidth - width) / 2;
        canvasData.top -= (newHeight - height) / 2;
      }

      canvasData.width = newWidth;
      canvasData.height = newHeight;
      this.renderCanvas(true);
    }

    return this;
  }
168468
function(e, win) {
      var event = $.event.get(e, win);
      var wheel = $.event.getWheel(event);
      that.handleEvent('MouseWheel', e, win, wheel);
    }
1137519
function (event){

    /*
    // @TODO Context menu?
    if(event.isRightClick()) {
      event.stop();

      var overlay = this.overlay;
      overlay.hide();

      function cancelContextMenu () {
        overlay.show();
        E.stopObserving(document, 'mousemove', cancelContextMenu);
      }
      E.observe(document, 'mousemove', cancelContextMenu);
      return;
    }
    */

    if (this.mouseUpHandler) return;
    this.mouseUpHandler = _.bind(function (e) {
      E.stopObserving(document, 'mouseup', this.mouseUpHandler);
      E.stopObserving(document, 'mousemove', this.mouseDownMoveHandler);
      this.mouseDownMoveHandler = null;
      this.mouseUpHandler = null;
      // @TODO why?
      //e.stop();
      E.fire(this.el, 'flotr:mouseup', [e, this]);
    }, this);
    this.mouseDownMoveHandler = _.bind(function (e) {
        var pos = this.getEventPosition(e);
        E.fire(this.el, 'flotr:mousemove', [event, pos, this]);
        this.lastMousePos = pos;
    }, this);
    E.observe(document, 'mouseup', this.mouseUpHandler);
    E.observe(document, 'mousemove', this.mouseDownMoveHandler);
    E.fire(this.el, 'flotr:mousedown', [event, this]);
    this.ignoreClick = false;
  }
519881
function(evt) {
        if (!OpenLayers.Event.isLeftClick(evt) && !OpenLayers.Event.isSingleTouch(evt)) {
            return;
        }
        this.map.events.on({
            "touchmove": this.passEventToSlider,
            "mousemove": this.passEventToSlider,
            "mouseup": this.passEventToSlider,
            scope: this
        });
        this.mouseDragStart = evt.xy.clone();
        this.zoomStart = evt.xy.clone();
        this.div.style.cursor = "move";
        // reset the div offsets just in case the div moved
        this.zoombarDiv.offsets = null; 
        OpenLayers.Event.stop(evt);
    }
336949
function clickHandlerKink() {
    timeline.pluginSetOrGetState("trimClinicalTimeline", false);
    //create a bounding box to ease the clicking of axis
    xAxisBBox = d3.select(timeline.divId()+" > svg > g > g.axis")[0][0].getBBox()
    d3.select(timeline.divId()+"> svg > g")
      .insert("rect")
      .attr("x", xAxisBBox.x)
      .attr("y", 4)
      .attr("width", xAxisBBox.width)
      .attr("height", xAxisBBox.height)
      .attr("fill", "rgba(0,0,0,0)")
      .style("cursor", "pointer")
      .on("click", function () {
        timeline.pluginSetOrGetState("trimClinicalTimeline", true);
      })
      .append("svg:title")
      .text("Click to trim the timeline");
  }
29650
def on_mouse_wheel(self, event):
        """"""
        # NOTE: not called on OS X because of touchpad
        if event.modifiers:
            return
        dx = np.sign(event.delta[1]) * self._wheel_coeff
        # Zoom toward the mouse pointer.
        x0, y0 = self._normalize(event.pos)
        self.zoom_delta((dx, dx), (x0, y0))
225667
function _onMouseOver(d) {
  var event = d3.event,
      node = event.target,
      tooltipData = {}; // Will be populated with {title/text/kvList}.

  node = node.correspondingUseElement || node;

  switch(_getType(node)) {
    case "vertex":
      var list  = {},
          vertex = d.get('data');

      _component.get('vertexProperties').forEach(function (property) {
        var value = {};

        if(vertex && property.getCellContent) {
          value = property.getCellContent(vertex);
          if(value && value.text !== undefined) {
            value = value.text;
          }
        }
        else if(property.contentPath) {
          value = d.get('data.' + property.contentPath);
        }

        if(property.cellComponentName === "date-formatter") {
          value = moment(value).format("DD MMM YYYY HH:mm:ss:SSS");
        }

        if(property.get("id") === "progress" && value) {
          value = Math.round(value * 100) + "%";
        }
        else if(property.get("id") === "duration" && value) {
          value = value + " ms";
        }

        if(typeof value !== 'object') {
          list[property.get('headerTitle')] = value;
        }
      });

      tooltipData = {
        title: d.get("vertexName"),
        kvList: list
      };
    break;
    case "input":
      list = {
        "Class": _getEndName(d.get("class")),
        "Initializer": _getEndName(d.get("initializer")),
        "Configurations": d.get("configs.length") || 0
      };
      tooltipData = {
        title: d.get("name"),
        kvList: list
      };
    break;
    case "output":
      list = {
        "Class": _getEndName(d.get("class")),
        "Configurations": d.get("configs.length") || 0
      };
      tooltipData = {
        title: d.get("name"),
        kvList: list
      };
    break;
    case "task":
      var totalTasks = d.get('data.totalTasks') || 0;
      tooltipData.title = totalTasks > 1 ? `${totalTasks} Tasks` : `${totalTasks} Task`;

      if(!isIE) {
        node = d3.event.target;
      }
    break;
    case "io":
      var inputs = d.get('inputs.length'),
          outputs = d.get('outputs.length'),
          title = "";
      title += inputs > 1 ? `${inputs} Sources` : `${inputs} Source`;
      title += " & ";
      title += outputs > 1 ? `${outputs} Sinks` : `${outputs} Sink`;
      tooltipData.title = title;

      if(!isIE) {
        node = d3.event.target;
      }
    break;
    case "group":
      tooltipData = {
        title: d.get("vertexGroup.groupName"),
        text: d.get("vertexGroup.groupMembers").join(", ")
      };
    break;
    case "path":
      let sourceName = d.get('source.name') || d.get('source.vertexName'),
          targetName = d.get('target.name') || d.get('target.vertexName');

      tooltipData = {
        position: {
          x: event.clientX,
          y: event.clientY
        },
        title: `${sourceName} - ${targetName}`
      };
      if(d.get("edgeId")) {
        tooltipData.kvList = {
          "Edge Id": d.get("edgeId"),
          "Data Movement Type": d.get("dataMovementType"),
          "Data Source Type": d.get("dataSourceType"),
          "Scheduling Type": d.get("schedulingType"),
          "Edge Source Class": _getEndName(d.get("edgeSourceClass")),
          "Edge Destination Class": _getEndName(d.get("edgeDestinationClass"))
        };
      }
      else {
        tooltipData.text = d.get('source.type') === "input" ? "Source link" : "Sink link";
      }
    break;
  }

  if(tooltipData.kvList) {
    let kvList = tooltipData.kvList,
        newKVList = {};

    Object.keys(kvList).forEach(function (key) {
      if(kvList[key]) {
        newKVList[key] = kvList[key];
      }
    });

    tooltipData.kvList = newKVList;
  }

  _tip.show(node, tooltipData, event);
}
523519
function onWheel(event) {
    var prevScale = scale,

        offset = container.offset(),
        mouseX = event.pageX - offset.left,
        mouseY = event.pageY - offset.top,
        factor = 0;

    scale += event.deltaY * SCALE_TUNER;
    if(scale < MIN_SCALE) {
      scale = MIN_SCALE;
    }
    else if(scale > MAX_SCALE) {
      scale = MAX_SCALE;
    }

    factor = 1 - scale / prevScale;
    panX += (mouseX - panX) * factor;
    panY += (mouseY - panY) * factor;

    transform();
    scheduleVisibilityCheck();

    _tip.reposition();
    event.preventDefault();
  }
1126696
function addMouseEvents() {
            if (shouldShowTooltip()) {
                svg
                    .on('mouseover', function(d) {
                        handleMouseOver(this, d);
                    })
                    .on('mouseout', function(d) {
                        handleMouseOut(this, d);
                    })
                    .on('mousemove',  function(d) {
                        handleMouseMove(this, d);
                    })
                    .on('click',  function(d) {
                        handleCustomClick(this, d);
                    });;
            }

            svg.selectAll('.bar')
                .on('mouseover', function(d) {
                    handleBarsMouseOver(this, d);
                })
                .on('mouseout', function(d) {
                    handleBarsMouseOut(this, d);
                });
        }
1116747
function(event) {
          var e = event || window.event;
          JSEvents.fillMouseEventData(JSEvents.wheelEvent, e, target);
          HEAPF64[(((JSEvents.wheelEvent)+(72))>>3)]=e["deltaX"];
          HEAPF64[(((JSEvents.wheelEvent)+(80))>>3)]=e["deltaY"];
          HEAPF64[(((JSEvents.wheelEvent)+(88))>>3)]=e["deltaZ"];
          HEAP32[(((JSEvents.wheelEvent)+(96))>>2)]=e["deltaMode"];
          var shouldCancel = Module['dynCall_iiii'](callbackfunc, eventTypeId, JSEvents.wheelEvent, userData);
          if (shouldCancel) {
            e.preventDefault();
          }
        }
347365
function mouseEnterHandler(e) {
        e = e || window.event;

        if (checkMouse(element, e)) {
            eventHandler(e);
        }
    }
122469
function createCallback(element,callback) {

    var fn = function(originalEvent) {

      !originalEvent && ( originalEvent = window.event );

      // create a normalized event object
      var event = {
        // keep a ref to the original event object
        originalEvent: originalEvent,
        target: originalEvent.target || originalEvent.srcElement,
        type: "wheel",
        deltaMode: originalEvent.type == "MozMousePixelScroll" ? 0 : 1,
        deltaX: 0,
        delatZ: 0,
        preventDefault: function() {
          originalEvent.preventDefault ?
            originalEvent.preventDefault() :
            originalEvent.returnValue = false;
        }
      };

      // calculate deltaY (and deltaX) according to the event
      if ( support == "mousewheel" ) {
        event.deltaY = - 1/40 * originalEvent.wheelDelta;
        // Webkit also support wheelDeltaX
        originalEvent.wheelDeltaX && ( event.deltaX = - 1/40 * originalEvent.wheelDeltaX );
      } else {
        event.deltaY = originalEvent.detail;
      }

      // it's time to fire the callback
      return callback( event );

    };

    fns.push({
      element: element,
      fn: fn,
    });

    return fn;
  }
538151
function scrollHandler() {
  for (let i = 0; i < scrollElements.length; i++) {
    animationBus.applyStyles(scrollElements[i])
  }
  isTicking = false
}