本文整理汇总了TypeScript中@interactjs/utils.is.array方法的典型用法代码示例。如果您正苦于以下问题:TypeScript is.array方法的具体用法?TypeScript is.array怎么用?TypeScript is.array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@interactjs/utils.is
的用法示例。
在下文中一共展示了is.array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: off
function off (type, listener, options) {
if (utils.is.string(type) && type.search(' ') !== -1) {
type = type.trim().split(/ +/)
}
if (utils.is.array(type)) {
for (const eventType of type) {
interact.off(eventType, listener, options)
}
return interact
}
if (utils.is.object(type)) {
for (const prop in type) {
interact.off(prop, type[prop], listener)
}
return interact
}
if (!utils.arr.contains(scope.actions.eventTypes, type)) {
events.remove(scope.document, type, listener, options)
}
else {
let index
if (type in globalEvents &&
(index = globalEvents[type].indexOf(listener)) !== -1) {
globalEvents[type].splice(index, 1)
}
}
return interact
}
示例2: collectDrops
function collectDrops ({ interactables }, draggableElement) {
const drops = []
// collect all dropzones and their elements which qualify for a drop
for (const dropzone of interactables.list) {
if (!dropzone.options.drop.enabled) { continue }
const accept = dropzone.options.drop.accept
// test the draggable draggableElement against the dropzone's accept setting
if ((utils.is.element(accept) && accept !== draggableElement) ||
(utils.is.string(accept) &&
!utils.dom.matchesSelector(draggableElement, accept)) ||
(utils.is.func(accept) && !accept({ dropzone, draggableElement }))) {
continue
}
// query for new elements if necessary
const dropElements = utils.is.string(dropzone.target)
? dropzone._context.querySelectorAll(dropzone.target)
: utils.is.array(dropzone.target) ? dropzone.target : [dropzone.target]
for (const dropzoneElement of dropElements) {
if (dropzoneElement !== draggableElement) {
drops.push({
dropzone,
element: dropzoneElement,
})
}
}
}
return drops
}
示例3: on
function on (type: string | Interact.EventTypes, listener: Interact.ListenersArg, options?) {
if (utils.is.string(type) && type.search(' ') !== -1) {
type = type.trim().split(/ +/)
}
if (utils.is.array(type)) {
for (const eventType of (type as any[])) {
interact.on(eventType, listener, options)
}
return interact
}
if (utils.is.object(type)) {
for (const prop in type) {
interact.on(prop, (type as Interact.EventTypes)[prop], listener)
}
return interact
}
// if it is an InteractEvent type, add listener to globalEvents
if (utils.arr.contains(scope.actions.eventTypes, type)) {
// if this type of event was never bound
if (!globalEvents[type]) {
globalEvents[type] = [listener]
}
else {
globalEvents[type].push(listener)
}
}
// If non InteractEvent type, addEventListener to document
else {
events.add(scope.document, type, listener as Interact.Listener, { options })
}
return interact
}