Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MarkerBase

Base class for all available and custom marker types.

All markers used with marker.js 2 should be descendants of this class.

Hierarchy

Index

Constructors

constructor

  • new MarkerBase(container: SVGGElement, overlayContainer: HTMLDivElement, settings: Settings): MarkerBase
  • Creates a new marker.

    Parameters

    • container: SVGGElement

      SVG container to hold marker's visual.

    • overlayContainer: HTMLDivElement

      overlay HTML container to hold additional overlay elements while editing.

    • settings: Settings

      settings object containing default markers settings.

    Returns MarkerBase

Properties

Protected _container

_container: SVGGElement

Protected _isSelected

_isSelected: boolean = false

Is this marker selected?

since

2.16.0

Protected _overlayContainer

_overlayContainer: HTMLDivElement

Protected _state

_state: MarkerState = "new"

Protected globalSettings

globalSettings: Settings

Protected Optional manipulationStartState

manipulationStartState: MarkerBaseState

Marker's state when it is selected

since

2.23.0

Optional notes

notes: string

Additional information about the marker

Optional onColorChanged

onColorChanged: (color: string) => void

Method to call when foreground color changes.

Type declaration

    • (color: string): void
    • Parameters

      • color: string

      Returns void

Optional onFillColorChanged

onFillColorChanged: (color: string) => void

Method to call when background/fill color changes.

Type declaration

    • (color: string): void
    • Parameters

      • color: string

      Returns void

onMarkerCreated

onMarkerCreated: (marker: MarkerBase) => void

Method called when marker creation is finished.

Type declaration

Optional onStateChanged

onStateChanged: (marker: MarkerBase) => void

Method to call when marker state changes.

since

2.23.0

Type declaration

Static icon

icon: string

SVG icon markup displayed on toolbar buttons.

Static title

title: string

Marker type title (display name) used for accessibility and other attributes.

Static typeName

typeName: string = "MarkerBase"

String type name of the marker type.

Used when adding MarkerArea.availableMarkerTypes via a string and to save and restore state.

Accessors

container

  • get container(): SVGGElement
  • SVG container object holding the marker's visual.

    Returns SVGGElement

isSelected

  • get isSelected(): boolean
  • Returns true if the marker is currently selected

    since

    2.16.0

    Returns boolean

overlayContainer

  • get overlayContainer(): HTMLDivElement
  • HTML container that can be used to render overlay objects while the marker is active.

    For example, this is used for the text editing layer while editing text in the {@see TextMarker}.

    Returns HTMLDivElement

state

  • Current marker state.

    Both MarkerArea and the marker itself can react differently to different events based on what state the marker is in.

    Returns MarkerState

toolboxPanels

  • Returns the list of toolbox panels for this marker type.

    Returns ToolboxPanel[]

typeName

  • get typeName(): string
  • Instance property returning marker's type name.

    since

    2.16.0

    Returns string

Methods

Protected addMarkerVisualToContainer

  • addMarkerVisualToContainer(element: SVGElement): void
  • Parameters

    • element: SVGElement

    Returns void

Protected colorChanged

  • colorChanged(color: string): void
  • Called by a marker when its foreground color changes.

    Parameters

    • color: string

    Returns void

dblClick

  • dblClick(point: IPoint, target?: EventTarget): void
  • Handles pointer (mouse, touch, stylus, etc.) double click event.

    Parameters

    • point: IPoint

      event coordinates.

    • Optional target: EventTarget

      direct event target element.

    Returns void

deselect

  • deselect(): void
  • Deselects this marker and hides selected marker UI.

    Returns void

dispose

  • dispose(): void
  • Disposes the marker and clean's up.

    Returns void

Protected fillColorChanged

  • fillColorChanged(color: string): void
  • Called by a marker when its background/fill color changes.

    Parameters

    • color: string

    Returns void

getState

  • Returns current marker state that can be restored in the future.

    Returns MarkerBaseState

manipulate

  • manipulate(point: IPoint): void
  • Handles marker manipulation (move, resize, rotate, etc.).

    Parameters

    • point: IPoint

      event coordinates.

    Returns void

ownsTarget

  • ownsTarget(el: EventTarget): boolean
  • Returns true if passed SVG element belongs to the marker. False otherwise.

    Parameters

    • el: EventTarget

      target element.

    Returns boolean

pointerDown

  • pointerDown(point: IPoint, target?: EventTarget): void
  • Handles pointer (mouse, touch, stylus, etc.) down event.

    Parameters

    • point: IPoint

      event coordinates.

    • Optional target: EventTarget

      direct event target element.

    Returns void

pointerUp

  • pointerUp(point: IPoint): void
  • Handles pointer (mouse, touch, stylus, etc.) up event.

    Parameters

    • point: IPoint

      event coordinates.

    Returns void

restoreState

  • Restores previously saved marker state.

    Parameters

    Returns void

scale

  • scale(scaleX: number, scaleY: number): void
  • Scales marker. Used after the image resize.

    Parameters

    • scaleX: number

      horizontal scale

    • scaleY: number

      vertical scale

    Returns void

select

  • select(): void
  • Selects this marker and displays appropriate selected marker UI.

    Returns void

Protected stateChanged

  • stateChanged(): void
  • Called by a marker when its state could have changed. Does a check if the state has indeed changed before firing the handler.

    since

    2.23.0

    Returns void

Generated using TypeDoc