PiDraw API
    Preparing search index...

    Class Zoom

    Zooms and moves the part of the plane that a graph shows: the drawing keeps its size, the units get longer or shorter and the origin moves. It is made with the graph, new Zoom(graph), and attaches itself to it; a graph has one. It is independent from the other controllers.

    What it may do is allow (both, zoom or move). The units never go below a hundredth or above a hundred times the ones at the start: a zoom that would go beyond stops there. The points that were dragged or animated keep their place in the plane (see Graph.updateLayout).

    With gestures: true it may also listen to the mouse and the fingers: Ctrl and the wheel always zoom around the cursor, and in the mode of navigation (navigating) a drag moves the drawing, the wheel zooms, and two fingers pinch to zoom and move. In that mode the points of the drawing cannot be dragged: a layer over the drawing takes the mouse and the fingers.

    The events are change (the window that is shown, whoever changed the layout) and navigation (the mode was entered or left).

    Hierarchy

    • EventTarget
      • Zoom

    Implements

    Index
    allow: ZoomAllow

    What the zoom may do.

    gestures: boolean

    Whether the zoom may listen to the mouse and the fingers.

    • get canMove(): boolean

      Whether the zoom may move the origin.

      Returns boolean

    • get canZoom(): boolean

      Whether the zoom may change the length of a unit.

      Returns boolean

    • Whether the mode of navigation is on: see gestures.

      Returns boolean

    • Enters or leaves the mode of navigation. In it a layer over the drawing takes the mouse and the fingers: a drag moves the drawing (if the zoom may move), the wheel zooms (if it may zoom), and two fingers pinch to zoom and move. The points cannot be dragged meanwhile.

      Parameters

      • value: boolean

      Returns void

      UnsupportedOperationError if the zoom was made without gestures.

    • get scale(): XY

      The length of a unit compared with the one at the start: 2 when it is twice as long.

      Returns XY

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Moves the origin by (dx, dy) pixels: the plane slides under the drawing.

      Parameters

      • dx: number
      • dy: number

      Returns void

      UnsupportedOperationError if the zoom may not move (allow: 'zoom').

      InvalidArgumentError if dx or dy is not finite.

    • Call handler when the zoom sends event. The same handler given twice is called once.

      Type Parameters

      Parameters

      Returns this

      the zoom, to chain.

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Comes back to the layout at the start (or the last one that someone else gave to the graph). It is always allowed.

      Returns void

    • Makes the units factor times longer. The point of the drawing under center (in pixels, the middle of the drawing by default) stays under it; with allow: 'zoom' the origin is the one that stays, and center is not used. Stops at the limits of the zoom.

      Parameters

      • factor: number = ZOOM_STEP
      • Optionalcenter: XY

      Returns void

      UnsupportedOperationError if the zoom may not zoom (allow: 'move').

      InvalidArgumentError if factor is not a finite number greater than 0.

    • Makes the units factor times shorter: the opposite of zoomIn.

      Parameters

      • factor: number = ZOOM_STEP
      • Optionalcenter: XY

      Returns void

      UnsupportedOperationError if the zoom may not zoom (allow: 'move').

      InvalidArgumentError if factor is not a finite number greater than 0.

    • Shows exactly this part of the plane, each axis with its own length of unit.

      Parameters

      Returns void

      UnsupportedOperationError unless the zoom may both zoom and move (allow: 'both').

      InvalidArgumentError if the window is not valid, the axes are not the usual ones, or the units it asks for go beyond the limits.