當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript is.array方法代碼示例

本文整理匯總了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
}
開發者ID:taye,項目名稱:interact.js,代碼行數:35,代碼來源:interact.ts

示例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
}
開發者ID:taye,項目名稱:interact.js,代碼行數:34,代碼來源:index.ts

示例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
}
開發者ID:taye,項目名稱:interact.js,代碼行數:38,代碼來源:interact.ts


注:本文中的@interactjs/utils.is.array方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。