本文整理匯總了TypeScript中@interactjs/utils.arr.contains方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript arr.contains方法的具體用法?TypeScript arr.contains怎麽用?TypeScript arr.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@interactjs/utils.arr
的用法示例。
在下文中一共展示了arr.contains方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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
}