All files / lib/event MouseEvent.ts

57.14% Statements 16/28
100% Branches 1/1
50% Functions 1/2
57.14% Lines 16/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107                              1x 1x                             1x 1x 1x   1x 1x 1x 1x 1x 1x 1x                                                                                             1x                           1x 1x   1x  
/*
 * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
 * http://paperjs.org/
 *
 * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
 * http://juerglehni.com/ & https://puckey.studio/
 *
 * Distributed under the MIT license. See LICENSE file for details.
 *
 * All rights reserved.
 */
 
// TODO: remove eslint-disable comment and deal with errors over time
/* eslint-disable */
 
import { ref } from '~/globals';
import { Event } from './Event';
 
/**
 * @name MouseEvent
 *
 * @class The MouseEvent object is received by the {@link Item}'s mouse event
 * handlers {@link Item#onMouseDown}, {@link Item#onMouseDrag},
 * {@link Item#onMouseMove}, {@link Item#onMouseUp}, {@link Item#onClick},
 * {@link Item#onDoubleClick}, {@link Item#onMouseEnter} and
 * {@link Item#onMouseLeave}. The MouseEvent object is the only parameter passed
 * to these functions and contains information about the mouse event.
 *
 * @extends Event
 */
/* global MouseEvent: true */
export const MouseEvent = Event.extend(
  /** @lends MouseEvent# */ {
    _class: 'MouseEvent',
 
    initialize: function MouseEvent(type, event, point, target, delta) {
      this.type = type;
      this.event = event;
      this.point = point;
      this.target = target;
      this.delta = delta;
    },
 
    /**
     * The type of mouse event.
     *
     * @name MouseEvent#type
     * @type String
     * @values 'mousedown', 'mouseup', 'mousedrag', 'click', 'doubleclick',
     *     'mousemove', 'mouseenter', 'mouseleave'
     */
 
    /**
     * The position of the mouse in project coordinates when the event was
     * fired.
     *
     * @name MouseEvent#point
     * @type Point
     */
 
    /**
     * The item that dispatched the event. It is different from
     * {@link #currentTarget} when the event handler is called during
     * the bubbling phase of the event.
     *
     * @name MouseEvent#target
     * @type Item
     */
 
    /**
     * The current target for the event, as the event traverses the scene graph.
     * It always refers to the element the event handler has been attached to as
     * opposed to {@link #target} which identifies the element on
     * which the event occurred.
     *
     * @name MouseEvent#currentTarget
     * @type Item
     */
 
    // DOCS: document MouseEvent#delta
    /**
     * @name MouseEvent#delta
     * @type Point
     */
 
    /**
     * @return {String} a string representation of the mouse event
     */
    toString: function () {
      return (
        "{ type: '" +
        this.type +
        "', point: " +
        this.point +
        ', target: ' +
        this.target +
        (this.delta ? ', delta: ' + this.delta : '') +
        ', modifiers: ' +
        this.getModifiers() +
        ' }'
      );
    },
  }
);
 
ref.MouseEvent = MouseEvent;