Capítulo 224 de 411

Chapter 224: Draggable.hitTest()

Core Idea

Static helper that tests whether one object overlaps another (or the pointer), by a configurable overlap threshold.

Reference Tables

ParameterTypeDescription
testObjectObjectelement, mouse/touch event (with pageX/pageY), selector string, or {top,left,right,bottom} rect
thresholdNumber | Stringdefault 0 (any overlap); a pixel count, or a percentage string like "50%" of overlapping area

Returns: Boolean.

Code Examples

if (Draggable.hitTest("#dropzone", "50%")) {
  // dragged element overlaps the dropzone by at least 50%
}
  • What it demonstrates: the common drag-and-drop pattern of checking overlap against a target zone inside onDragEnd.

Connects To

  • Draggable (onDragEnd callback): typical place to call hitTest() to decide whether a drop was successful.