Defines an area where the user can drag the content around relative to the boundaries of a reference view area.

The reference view area is created inside and relative to the component. The reference view area has the class "hylo-drag-area-view" and the content is placed inside an element with the class "hylo-drag-area-content".

The content needs to have dimensions -> root element or ".hylo-drag-area-content" should have "display: inline-block" or "display: inline-flex".

Listens to the event "hyloDragAreaUpdate" and "resize" on the window element to update itself.

Gets the class "active" when the component is active. The component is active when dragging is possible or in progress.

Give the hylo-drag-area a tabIndex of 0 or higher and use scrollbars (scrollX / scrollY) to have the area be scrollable by arrow keys.

Properties

bounceBack: boolean

If set, the content bounces back to its original position after the dragging stopped.

contentClass: string = ''

Classes added to the content element.

contentTable: boolean

Sets the display type of the content element to "table". Forces the content to set its height to its inner content height. The inner content should be wrapped by a "div".

disableHorizontal: boolean

Disables horizontal dragging.

disableVertical: boolean

Disables vertical dragging.

height: string = null

The height style of the reference view area. Can also be set by adding the style to "hylo-drag-area .hylo-drag-area-view".

heightReference: string | HTMLElement

A reference element from which the height value is taken. Alternative to the "height" property.

Can be provided as css query or as HTMLElement object.

horizontalScrollbarClass: string = ''

Classes added to the horizontal hylo-scrollbar component.

left: string

The left style of the reference view area. Its relative to the hylo-drag-area component. It can also be set by adding the style to "hylo-drag-area .hylo-drag-area-view" if scrollX is not used.

restrictToComponentBoundary: boolean

Stops dragging when the mouse leaves the component boundary.

restrictToViewBoundary: boolean

Starts only dragging when the mouse is in the reference view area boundary. Otherwise the content area reacts to drag start.

scrollToFocus: boolean

Scrolls the focused element into view. The focused element has to be completely outside the view to trigger scrolling.

If "scrollToKeyFocus" is set as well, the element has only to be partially outside the view.

scrollToFocusOffset: number = 25

An inner offset in px of the dimensions of the view an element has to be pass to trigger "scrollToFocus" or "scrollToKeyFocus".

scrollToKeyFocus: boolean

Scrolls the focused element into view. The focused element has only to be partially outside the view to trigger scrolling. Triggers only when focus was gained through the "tab" key.

scrollX: boolean

Instead of positioning the dragged area by using the left/right css style, the horizontal browser scrollbar is used but the scrollbar is hidden. Fixes the unwanted view shift of the browser when an element gets the focus which is not in the browser view but clips the content to the scroll area.

scrollY: boolean

Instead of positioning the dragged area by using the top/bottom css style, the vertical browser scrollbar is used but the scrollbar is hidden. Fixes the unwanted view shift of the browser when an element gets the focus which is not in the browser view but clips the content to the scroll area.

scrollbarTouch: string | boolean

Defines whether the scrollbar listens to touch events. Can be set as boolean or as a comma separated string of breakpoints (hylo-breakpoint-listener needed).

scrollbarWrapperClass: string = ''

Classes added to the element which wraps the hylo-scrollbar and hylo-drag-area component. Add padding to adjust the scrollbars' positions.

showScrollbar: boolean

Shows the scrollbar when "scrollX" or "scrollY" is set. Hides the scrollbar if nothing is to scroll.

Wraps this component together with hylo-scrollbar components in a div with the class "hylo-drag-area-wrapper".

showScrollbarAlways: boolean

If "showScrollbar" is set, it shows the scrollbar even if nothing is to scroll.

snapPointX: number = 0

Initial horizontal snap index.

Is not being updated. Use getSnapX() instead.

Can be used to jump immediately to the snap point. For a smooth animation use snapTo() instead.

snapPointY: number = 0

Initial vertical snap index.

Is not being updated. Use getSnapY() instead.

Can be used to jump immediately to the snap point. For a smooth animation use snapTo() instead.

snapPointsX: string

A comma separated list of x values (numbers) to which the area is gonna snap when released.

snapPointsY: string

A comma separated list of y values (numbers) to which the area is gonna snap when released.

top: string

The top style of the reference view area. Its relative to the hylo-drag-area component. It can also be set by adding the style to "hylo-drag-area .hylo-drag-area-view" if scrollY is not used..

touchAction: "none" | "auto" | "pan-x" | "pan-y" | "pinch-zoom" | "manipulation" = null

Overwrites the default value of the css property "touch-action" of the component.

Default values:

  • disableHorizontal set: 'pan-x'
  • disableVertical set: 'pan-y'
  • none of the above: 'none'
useBottom: boolean

By default the vertical relative position of the content element is changed by setting the style property "top". By setting this property, "bottom" is used instead.

useRight: boolean

By default the horizontal relative position of the content element is changed by setting the style property "left". By setting this property, "right" is used instead.

verticalScrollbarClass: string = ''

Classes added to the vertical hylo-scrollbar component.

width: string = null

The width style of the reference view area. Can also be set by adding the style to "hylo-drag-area .hylo-drag-area-view".

widthReference: string | HTMLElement

A reference element from which the width value is taken. Alternative to the "width" property.

Can be provided as css query or as HTMLElement object.

Methods

  • Returns a comma separated string of horizontal snap points of all elements matching the query.

    The query is applied onto this component. The elements need to be children of this component.

    To be used with snapPointsX property.

    Parameters

    • query: string

      a css query string defining the snap point elements (starting with this component)

    Returns Promise<string>

  • Returns a comma separated string of vertical snap points of all elements matching the query.

    The query is applied onto this component. The elements need to be children of this component.

    To be used with snapPointsY property.

    Parameters

    • query: string

      a css query string defining the snap point elements (starting with this component)

    Returns Promise<string>

  • Returns the content element.

    Returns Promise<HTMLElement>

  • Returns how far the content got dragged/moved horizontally. Is equal to the css variable "--hylo-drag-x".

    Returns Promise<number>

  • Returns how far the content got dragged/moved vertically. Is equal to the css variable "--hylo-drag-y".

    Returns Promise<number>

  • Returns the current x snap index.

    Returns Promise<number>

  • Returns the current y snap index.

    Returns Promise<number>

  • Returns the current status (Is it active?) of the component.

    The component is active when dragging is possible or in progress.

    Returns Promise<boolean>

  • Jumps immediately to the given index of the values of "snapPointsX" and "snapPointsY".

    Values "null" and < 0 are ignored.

    Parameters

    • x: number = null
    • y: number = null

    Returns Promise<void>

  • Snaps the dragable area to the given index of the values of "snapPointsX" and "snapPointsY".

    Values "null" and < 0 are ignored.

    Parameters

    • x: number = null
    • y: number = null

    Returns Promise<void>

  • Updates itself.

    Returns Promise<void>

  • Updates/refreshes the scrollbars' postions.

    Returns Promise<void>

Events

hyloDragAreaSnapped: EventEmitter<{
    axis: "x" | "y";
    index: number;
}>

The drag area snaped to a snap point. Emits the snap index and axis.

Type declaration

  • axis: "x" | "y"
  • index: number
hyloDragAreaStatusChanged: EventEmitter<boolean>

The drag area status toggled between active and inactive.

Emits if "active".

hyloDragChanged: EventEmitter<{
    x: number;
    y: number;
}>

Fires whenever the "dragX" and/or the "dragY" value changed. Emits the values in an object {x: number, y:number}.

Type declaration

  • x: number
  • y: number
hyloDragStarted: EventEmitter<any>

The drag started.

hyloDragStopped: EventEmitter<number>

The drag stopped.

Emits the timespan the component got dragged in milliseconds. Can be used to determine whether it counts as drag and if subsequent click events should be "preventDefault" or if it was simply to short and actually just a click event in progress.

Generated using TypeDoc