Show:

Q.Pointer Class

Methods for working with pointer and touchscreen events

Item Index

Methods

Properties

Events

Methods

boundingRect

(
  • [container=document.body]
  • [omitClasses]
  • [omitOverflow=false]
)
Object static

Get the rectangle enclosing all the children of the container element and – for their children with overflow: visible – their overflowed contents.

Parameters:

  • [container=document.body] HTMLElement optional

    The container element

  • [omitClasses] Array optional

    Put CSS classes of any elements to omit from calculations

  • [omitOverflow=false] Boolean optional

    If true, doesn't use overflowed content in calculations

Returns:

Object:

with properties left, right, top, bottom, width, height

cancel

() static

Intelligent pointer cancel event that also works on touchscreens

cancelClick

(
  • [event]
  • [extraInfo]
  • [skipMask=false]
)
Boolean static

Cancels a click that may be in progress, setting Q.Pointer.canceledClick to true. This is to tell other handlers in the document, which know about Q, not to react to the click in a standard way. To really stop propagation of this event, also call stopPropagation. However, this canceling itself can be canceled by a handler returning false.

Parameters:

  • [event] Q.Event optional

    Some mouse or touch event from the DOM

  • [extraInfo] Object optional

    Extra info to pass to onCancelClick

  • [skipMask=false] Boolean optional

    Pass true here to skip showing the Q.click.mask for 300 milliseconds, which blocks any stray clicks on mouseup or touchend, which occurs on some browsers. You will want to skip the mask if you want to allow scrolling, for instance.

Returns:

click

() static

Normalized mouse wheel event that works with various browsers

click

() static

Intelligent click event that also works on touchscreens, and respects Q.Pointer.canceledClick

elementFromPoint

(
  • e
)
Number static

Consistently obtains the element under pageX and pageY relative to document

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

end

() static

Intelligent pointer end event that also works on touchscreens

ended

() static

Removes event listeners that are activated when the pointer has started. This method is called automatically when the mouse or fingers are released on the window. However, in the code that stops propagation of the Q.Pointer.end event (mouseup or touchend), you'd have to call this method manually.

enter

() static

Intelligent pointer enter event that also works on touchscreens

fastclick

() static

Like click event but fires much sooner on touchscreens, and respects Q.Pointer.canceledClick

focusin

() static

Intelligent focusin event that fires only once per focusin

focusout

() static

Intelligent focusout event that fires only once per focusout

getX

(
  • e
)
Number static

Returns the x coordinate of an event relative to the document

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

getY

(
  • e
)
Number static

Returns the y coordinate of an event relative to the document

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

hint

(
  • targets
  • [options]
  • [option.dontStopBeforeShown=false]
)
static

Places a hint to click or tap on the screen

Parameters:

  • targets Element | Object | String | Array

    Indicates where to display the hint. A point should contain properties "x" and "y". Can also be a String selector referring to one or more elements after the show.delay, or an array of points, elements, or string css selectors to use with document.querySelector.

  • [options] Object optional

    possible options, which can include:

    • [src] String optional

      the url of the hint pointer image

    • [hotspot={x:0.5,y:0.3}] Point optional

      "x" and "y" represent the location of the hotspot within the image, using fractions between 0 and 1

    • [width="200px"] String optional
    • [height="200px"] String optional
    • [zIndex=99999] Integer optional
    • [dontRemove=false] Boolean optional

      Pass true to keep current hints displayed

    • [audio.src] String optional

      Can be used to play an audio file.

    • [audio.from=0] String optional

      Number of seconds inside the audio to start playing the audio from. Make sure audio is longer than this.

    • [audio.until] String optional

      Number of seconds inside the audio to play the audio until. Make sure audio is longer than this.

    • [audio.removeAfterPlaying] String optional

      Whether to remove the audio object after playing

    • [show.delay=500] Integer optional

      How long to wait after the function call (or after audio file has loaded and starts playing, if one was specified) before showing the hint animation

    • [show.initialScale=10] Integer optional

      The initial scale of the hint pointer image in the show animation

    • [show.duration=500] Integer optional

      The duration of the hint show animation

    • [show.ease=Q.Animation.ease.smooth] Function optional
    • [hide.duration=500] Integer optional

      The duration of the hint hide animation

    • [hide.ease=Q.Animation.ease.smooth] Function optional
  • [option.dontStopBeforeShown=false] Boolean optional

    Don't let Q.Pointer.stopHints stop this hint before it's shown.

leave

() static

Intelligent pointer leave event that also works on touchscreens

move

() static

Intelligent pointer move event that also works on touchscreens

offset

(
  • element
)
Object static

Computes the offset of an element relative to the browser

Parameters:

Returns:

Object:

An object with "left" and "top" properties.

preventDefault

(
  • e
)
Boolean static

Consistently prevents the default behavior of an event across browsers

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

Boolean:

Whether the preventDefault succeeded

preventRubberBand

(
  • [options]
)

Call this function to prevent the rubber band effect on iOS devices, making the app feel more native there.

Parameters:

  • [options] Object optional

    possible options, which can include:

    • [direction='both'] String optional

      can be 'vertical', 'horizontal', or 'both'

relatedTarget

(
  • e
)
Number static

Consistently returns the related target of an event across browsers

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

restoreRubberBand

()

Can restore touch scrolling after preventRubberBand() was called

scrollLeft

() Number static

Returns the document's scroll left in pixels, consistently across browsers

Returns:

scrollTop

() Number static

Returns the document's scroll top in pixels, consistently across browsers

Returns:

scrollTop

() Number static

Returns the window's inner width, in pixels, consistently across browsers

Returns:

start

() static

Intelligent pointer start event that also works on touchscreens

startBlurringOnTouch

()

Call this function to begin blurring active elements when touching outside them

startBlurringOnTouch

()

Call this function to begin blurring active elements when touching outside them

startCancelingClicksOnScroll

(
  • {
)

Call this function to begin canceling clicks on the element or its scrolling parent. This is to good for preventing stray clicks from happening after an accidental scroll, for instance if content changed after a tab was selected, and scrollTop became 0.

Parameters:

startCancelingClicksOnScroll

(
  • {
)

Call this function to stop canceling clicks on the element or its scrolling parent. This is to good for preventing stray clicks from happening after an accidental scroll, for instance if content changed after a tab was selected, and scrollTop became 0.

Parameters:

stopHints

(
  • [container]
)
static

Stops any hints that are currently being displayed

Parameters:

  • [container] HTMLElement optional

    If provided, only hints for elements in this container are stopped.

target

(
  • e
)
HTMLElement static

Consistently returns the target of an event across browsers

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

touchclick

() static

Like click event but works on touchscreens even if the viewport moves during click, such as when the on-screen keyboard disappears or a scrolling parent gets scrollTop = 0 because content changed. Respects Q.Pointer.canceledClick

touchCount

(
  • e
)
Number static

Returns the number of touch points of an event

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

which

(
  • e
)
Number static

Returns which button was pressed - Q.Pointer.which.{LEFT|MIDDLE|RIGHT}

Parameters:

  • e Q.Event

    Some mouse or touch event from the DOM

Returns:

windowHeight

() Number static

Returns the window's inner height, in pixels, consistently across browsers

Returns:

Properties

canceledClick

Boolean static

Whether the click was canceled by Q.Pointer.cancelClick()

options.cancelClickDistance

Unknown static

The distance that a finger or mouse has to move for the click to be canceled

Events

onCancelClick

static

This event occurs when a click has been canceled, for one of several possible reasons.

onEnded

static

This event occurs when touching or mouse pressing should have ended

onStarted

static

This event occurs when touching or mouse pressing should have started