src/eventListeners/mouseEventListeners.js
function onMouseUp(e) {
    // Cancel the timeout preventing the click event from triggering
    clearTimeout(preventClickTimeout);

    let eventType = EVENTS.MOUSE_UP;

    if (isClickEvent) {
      eventType = EVENTS.MOUSE_CLICK;
    }

    // Calculate our current points in page and image coordinates
    const currentPoints = {
      page: external.cornerstoneMath.point.pageToPoint(e),
      image: external.cornerstone.pageToPixel(element, e.pageX, e.pageY),
      client: {
        x: e.clientX,
        y: e.clientY,
      },
    };

    currentPoints.canvas = external.cornerstone.pixelToCanvas(
      element,
      currentPoints.image
    );

    // Calculate delta values in page and image coordinates
    const deltaPoints = {
      page: external.cornerstoneMath.point.subtract(
        currentPoints.page,
        lastPoints.page
      ),
      image: external.cornerstoneMath.point.subtract(
        currentPoints.image,
        lastPoints.image
      ),
      client: external.cornerstoneMath.point.subtract(
        currentPoints.client,
        lastPoints.client
      ),
      canvas: external.cornerstoneMath.point.subtract(
        currentPoints.canvas,
        lastPoints.canvas
      ),
    };

    logger.log('mouseup: %o', getEventButtons(e));
    const eventData = {
      event: e,
      buttons: getEventButtons(e),
      viewport: external.cornerstone.getViewport(element),
      image: enabledElement.image,
      element,
      startPoints,
      lastPoints,
      currentPoints,
      deltaPoints,
      type: eventType,
    };

    triggerEvent(eventData.element, eventType, eventData);

    document.removeEventListener('mousemove', onMouseMove);
    document.removeEventListener('mouseup', onMouseUp);

    element.addEventListener('mousemove', mouseMove);

    isClickEvent = true;
  }
function onMouseUp(e) {
    // Cancel the timeout preventing the click event from triggering
    clearTimeout(preventClickTimeout);

    let eventType = EVENTS.MOUSE_UP;

    if (isClickEvent) {
      eventType = EVENTS.MOUSE_CLICK;
    }

    // Calculate our current points in page and image coordinates
    const currentPoints = {
      page: external.cornerstoneMath.point.pageToPoint(e),
      image: external.cornerstone.pageToPixel(element, e.pageX, e.pageY),
      client: {
        x: e.clientX,
        y: e.clientY,
      },
    };

    currentPoints.canvas = external.cornerstone.pixelToCanvas(
      element,
      currentPoints.image
    );

    // Calculate delta values in page and image coordinates
    const deltaPoints = {
      page: external.cornerstoneMath.point.subtract(
        currentPoints.page,
        lastPoints.page
      ),
      image: external.cornerstoneMath.point.subtract(
        currentPoints.image,
        lastPoints.image
      ),
      client: external.cornerstoneMath.point.subtract(
        currentPoints.client,
        lastPoints.client
      ),
      canvas: external.cornerstoneMath.point.subtract(
        currentPoints.canvas,
        lastPoints.canvas
      ),
    };

    logger.log('mouseup: %o', getEventButtons(e));
    const eventData = {
      event: e,
      buttons: getEventButtons(e),
      viewport: external.cornerstone.getViewport(element),
      image: enabledElement.image,
      element,
      startPoints,
      lastPoints,
      currentPoints,
      deltaPoints,
      type: eventType,
    };

    triggerEvent(eventData.element, eventType, eventData);

    document.removeEventListener('mousemove', onMouseMove);
    document.removeEventListener('mouseup', onMouseUp);

    element.addEventListener('mousemove', mouseMove);

    isClickEvent = true;
  }
function onMouseUp ( e ) { // Cancel the timeout preventing the click event from triggering clearTimeout ( preventClickTimeout ) ; let eventType = EVENTS . MOUSE_UP ; if ( isClickEvent ) { eventType = EVENTS . MOUSE_CLICK ; } // Calculate our current points in page and image coordinates const currentPoints = { page : external . cornerstoneMath . point . pageToPoint ( e ) , image : external . cornerstone . pageToPixel ( element , e . pageX , e . pageY ) , client : { x : e . clientX , y : e . clientY , } , } ; currentPoints . canvas = external . cornerstone . pixelToCanvas ( element , currentPoints . image ) ; // Calculate delta values in page and image coordinates const deltaPoints = { page : external . cornerstoneMath . point . subtract ( currentPoints . page , lastPoints . page ) , image : external . cornerstoneMath . point . subtract ( currentPoints . image , lastPoints . image ) , client : external . cornerstoneMath . point . subtract ( currentPoints . client , lastPoints . client ) , canvas : external . cornerstoneMath . point . subtract ( currentPoints . canvas , lastPoints . canvas ) , } ; logger . log ( 'mouseup: %o' , getEventButtons ( e ) ) ; const eventData = { event : e , buttons : getEventButtons ( e ) , viewport : external . cornerstone . getViewport ( element ) , image : enabledElement . image , element , startPoints , lastPoints , currentPoints , deltaPoints , type : eventType , } ; triggerEvent ( eventData . element , eventType , eventData ) ; document . removeEventListener ( 'mousemove' , onMouseMove ) ; document . removeEventListener ( 'mouseup' , onMouseUp ) ; element . addEventListener ( 'mousemove' , mouseMove ) ; isClickEvent = true ; }
Hook mouseup so we can unbind our event listeners When they stop dragging
Hook mouseup so we can unbind our event listeners When they stop dragging