uiik

Classes

Type Aliases

CollisionData

Ƭ CollisionData: Object

Type declaration

NameType
el?HTMLElement
x1number
x2number
y1number
y2number

CollisionDetectorOptions

Ƭ CollisionDetectorOptions: Object

Type declaration

NameType
container?Element

DraggableOptions

Ƭ DraggableOptions: Object

Type declaration

NameTypeDescription
classes?string拖动时应用的class样式,多个使用空格分开
container?boolean限制活动范围,默认false
cursor?{ active?: string ; default?: string ; over?: string }可定义拖动时不同状态下的指针,默认move
cursor.active?string-
cursor.default?string-
cursor.over?string-
cursorAt?{ left: number | string ; top: number | string }拖动时元素左上角距离指针的距离,支持百分比及负数
cursorAt.leftnumber | string-
cursorAt.topnumber | string-
direction?"v" | "h"传递v/h可实现单向拖动。默认''
droppable?() => NodeList | HTMLCollection | HTMLElement | string | HTMLElement | HTMLElement拖动目标,dom/selector数组,用于拖动交互事件
filter?string禁止触发元素的css选择器
ghost?(el: HTMLElement) => HTMLElement | boolean开启ghost模式后,拖动元素时会自动创建元素副本并拖动副本,当拖动结束后,副本销毁并且元素移动到最后位置。默认false,支持函数返回副本元素
ghostClass?string-
grid?number | number网格拖动模式,每次移动指定的网格大小。数字或数字数组
group?string可将不同的拖动元素编为一组,拖动时会自动管理zIndex
handle?string实际响应拖动的元素选择器,字符串
onClone?(cloneDom: HTMLElement, ev: MouseEvent) => void-
onDrag?(dragDom: HTMLElement, ev: MouseEvent, offsetX: number, offsetY: number, x: number, y: number) => boolean | void拖动中调用,返回false阻止dom移动
onEnd?(dragDom: HTMLElement, ev: MouseEvent) => boolean | void拖动结束后调用,返回false阻止ghost模式下的dom移动
onSnap?(el: HTMLElement, targetH: HTMLElement, targetV: HTMLElement, hDir: string, vDir: string) => void-
onStart?(dragDom: HTMLElement, ev: MouseEvent) => void-
scroll?boolean是否在鼠标到达容器边缘时自动滚动,默认true
scrollSpeed?number滚动速度,默认10
snap?string拖动元素可自动吸附的目标元素选择器。字符串
snapOptions?{ tolerance: number }-
snapOptions.tolerancenumber吸附元素的移动误差,默认10
threshold?number拖动起始阈值,默认0
type?string拖动类型标识,用于droppable识别交互类型
zIndex?number拖动时元素的zIndex

DroppableOptions

Ƭ DroppableOptions: Object

Type declaration

NameTypeDescription
accepts?(ele: HTMLElement, draggable: HTMLElement) => boolean | string定义哪些draggable元素进行交互。如果是字符串,支持不同Draggable对象进行编组
activeClass?string当accepts的draggable对象开始拖动时,自动设置该样式。多个样式使用空格分隔
hoverClass?string当accepts的draggable对象拖动到droppable元素上时,自动设置该样式。多个样式使用空格分隔
onActive?(draggable: HTMLElement, ele: HTMLElement) => void当accepts的draggable对象开始拖动时触发
onDeactive?(draggable: HTMLElement, ele: HTMLElement) => void当accepts的draggable对象结束拖动时触发
onDrop?(el: HTMLElement, ev: MouseEvent) => void-
onEnter?(el: HTMLElement, ev: MouseEvent) => void-
onLeave?(el: HTMLElement, ev: MouseEvent) => void-
onOver?(el: HTMLElement, ev: MouseEvent) => void-

ResizableOptions

Ƭ ResizableOptions: Object

Type declaration

NameTypeDescription
aspectRatio?number宽高比,小数
dir?stringresizable方向,默认n,s,e,w,ne,nw,se,sw
ghost?boolean | Function开启ghost模式后,拖动元素时会自动创建元素副本并拖动副本,当拖动结束后,副本销毁并且元素移动到最后位置。默认false
ghostClass?string-
handleSize?numberhandle的宽高,默认8
maxSize?number | number拖动元素的最大size,如果是数组,表示 width,height
minSize?number | number拖动元素的最小size,如果是数组,表示 width,height
offset?numberhandle所在元素的位置偏移,负数向内,正数向外。默认0
onClone?(cloneDom: HTMLElement, ev: MouseEvent) => void-
onEnd?(w: number, h: number) => void-
onResize?(w: number, h: number) => void-
onStart?(w: number, h: number) => void-

RotatableOptions

Ƭ RotatableOptions: Object

Type declaration

NameTypeDescription
cursor?{ active?: string ; default?: string }可定义拖动时不同状态下的指针,默认crosshair
cursor.active?string-
cursor.default?string-
onEnd?(deg: number) => {}-
onRotate?(deg: number) => {}-
onStart?(deg: number) => {}-

SelectableOptions

Ƭ SelectableOptions: Object

Type declaration

NameTypeDescription
class?string选择器样式字符串,多个使用空格分隔
filter?(el: HTMLElement) => boolean | string禁止触发元素的css选择器或校验函数,函数返回true表示需要过滤
mode?"overlap" | "inclusion"选择模式,默认overlap
onEnd?(selection: HTMLElement) => void-
onSelect?(selection: HTMLElement) => void-
onStart?(target: HTMLElement) => void-
scroll?boolean是否在鼠标到达容器边缘时自动滚动,默认true
scrollSpeed?number滚动速度,默认10
selectedClass?string选择器拖动结束后,被选中元素应用的样式字符串,多个使用空格分隔
selectingClass?string选择器拖动进行中,被选中元素应用的样式字符串,多个使用空格分隔
targets?() => NodeList | HTMLCollection | HTMLElement | string容器中可选择的元素。可以是选择器字符串或返回元素数组的函数

SplittableOptions

Ƭ SplittableOptions: Object

Type declaration

NameTypeDescription
ghost?boolean开启ghost模式后,拖动元素时会自动创建元素副本并拖动副本,当拖动结束后,副本销毁且元素移动到最后位置。默认false
ghostClass?string-
handle?string自定义handle选择器,多个使用空格分隔。handle元素可以是与分割元素平级或在分割元素内
handleSize?numberhandle宽/高,默认10
inside?boolean自动创建的handle是否在元素内部插入,默认false
minSize?number | number最小区域,如果是数组可以按顺序定义分割区域,默认0
onClone?(cloneDom: HTMLElement, ev: MouseEvent) => void-
onEnd?(size1: number, size2: number) => void-
onSplit?(size1: number, size2: number) => void-
onStart?(size1: number, size2: number) => void-
onSticky?(size1: number, size2: number, position: "start" | "end" | "none") => void-
oneSideMode?"start" | "end"单边模式,只修改单侧元素size,用于flex布局。可选值为 start/end
sticky?boolean | boolean粘性吸附,如果是数组可以按顺序定义分割区域。设置minSize后生效

Variables

VERSION

Const VERSION: string = packageInfo.version


default

default: Object

Type declaration

NameType
VERSIONstring
newDraggable(els: string | HTMLElement | (string | HTMLElement), opts?: DraggableOptions) => Draggable
newDroppable(els: string | HTMLElement | (string | HTMLElement), opts?: DroppableOptions) => Droppable
newResizable(els: string | HTMLElement, opts?: ResizableOptions) => Resizable
newRotatable(els: string | HTMLElement, opts?: RotatableOptions) => Rotatable
newSelectable(container: string | HTMLElement, opts?: SelectableOptions) => Selectable
newSplittable(container: string | HTMLElement, opts?: SplittableOptions) => Splittable

Functions

newCollisionDetector

newCollisionDetector(el, targets, opts?): CollisionDetector

create a detector for the el and return

Parameters

NameTypeDescription
elstring | HTMLElementelement to be detected
targetsstring | HTMLElement | HTMLElement | NodeList | HTMLCollection | () => HTMLElement
opts?CollisionDetectorOptionsCollisionDetectorOptions

Returns

CollisionDetector


newDraggable

newDraggable(els, opts?): Draggable

create a draggable pattern for one or more elements with opts

Parameters

NameTypeDescription
elsstring | HTMLElement | (string | HTMLElement)selector string / html element
opts?DraggableOptions

Returns

Draggable

Draggable instance


newDroppable

newDroppable(els, opts?): Droppable

Enable els to response to draggable objects

Parameters

NameTypeDescription
elsstring | HTMLElement | (string | HTMLElement)selector string / html element
opts?DroppableOptions

Returns

Droppable


newResizable

newResizable(els, opts?): Resizable

Make els resizable

Parameters

NameTypeDescription
elsstring | HTMLElementselector string / html element
opts?ResizableOptions

Returns

Resizable


newRotatable

newRotatable(els, opts?): Rotatable

Make els rotatable

Parameters

NameTypeDescription
elsstring | HTMLElementselector string / html element
opts?RotatableOptions

Returns

Rotatable


newSelectable

newSelectable(container, opts?): Selectable

Add a selector into the container

Parameters

NameTypeDescription
containerstring | HTMLElementcss selector or html element
opts?SelectableOptions

Returns

Selectable


newSplittable

newSplittable(container, opts?): Splittable

Add one or more splittors into the container

Parameters

NameTypeDescription
containerstring | HTMLElementcss selector or html element
opts?SplittableOptionsSplittableOptions

Returns

Splittable