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


TypeScript is.element函數代碼示例

本文整理匯總了TypeScript中@interactjs/utils/is.element函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript element函數的具體用法?TypeScript element怎麽用?TypeScript element使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了element函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

  scope.autoStart.signals.on('before-start',  ({ interaction, eventTarget, dx, dy }) => {
    if (interaction.prepared.name !== 'drag') { return }

    // check if a drag is in the correct axis
    const absX = Math.abs(dx)
    const absY = Math.abs(dy)
    const targetOptions = interaction.interactable.options.drag
    const startAxis = targetOptions.startAxis
    const currentAxis = (absX > absY ? 'x' : absX < absY ? 'y' : 'xy')

    interaction.prepared.axis = targetOptions.lockAxis === 'start'
      ? currentAxis[0]  as 'x' | 'y' // always lock to one axis even if currentAxis === 'xy'
      : targetOptions.lockAxis

    // if the movement isn't in the startAxis of the interactable
    if (currentAxis !== 'xy' && startAxis !== 'xy' && startAxis !== currentAxis) {
      // cancel the prepared action
      interaction.prepared.name = null

      // then try to get a drag from another ineractable
      let element = eventTarget

      const getDraggable = function (interactable) {
        if (interactable === interaction.interactable) { return }

        const options = interaction.interactable.options.drag

        if (!options.manualStart &&
            interactable.testIgnoreAllow(options, element, eventTarget)) {
          const action = interactable.getAction(
            interaction.downPointer, interaction.downEvent, interaction, element)

          if (action &&
              action.name === ActionName.Drag &&
              checkStartAxis(currentAxis, interactable) &&
              autoStart.validateAction(action, interactable, element, eventTarget, scope)) {
            return interactable
          }
        }
      }

      // check all interactables
      while (is.element(element)) {
        const interactable = scope.interactables.forEachMatch(element, getDraggable)

        if (interactable) {
          interaction.prepared.name = ActionName.Drag
          interaction.interactable = interactable
          interaction.element = element
          break
        }

        element = parentNode(element)
      }
    }
  })
開發者ID:taye,項目名稱:interact.js,代碼行數:56,代碼來源:dragAxis.ts

示例2: parentHasStyle

function parentHasStyle (element: Element, prop: keyof CSSStyleDeclaration, styleRe: RegExp) {
  let parent = element as HTMLElement

  while (is.element(parent)) {
    if (hasStyle(parent, prop, styleRe)) {
      return true
    }

    parent = parentNode(parent)
  }

  return false
}
開發者ID:taye,項目名稱:interact.js,代碼行數:13,代碼來源:index.ts

示例3:

    scope.interactables.forEachMatch(element, (interactable: Interactable) => {
      const eventable = interactable.events
      const options = eventable.options

      if (
        eventable.types[type] &&
        eventable.types[type].length &&
        is.element(element) &&
        interactable.testIgnoreAllow(options, element, eventTarget)) {
        targets.push({
          element,
          eventable,
          props: { interactable },
        })
      }
    })
開發者ID:taye,項目名稱:interact.js,代碼行數:16,代碼來源:interactableTargets.ts

示例4: checkAndPreventDefault

function checkAndPreventDefault (interactable, scope, event) {
  const setting = interactable.options.preventDefault

  if (setting === 'never') { return }

  if (setting === 'always') {
    event.preventDefault()
    return
  }

  // setting === 'auto'

  // if the browser supports passive event listeners and isn't running on iOS,
  // don't preventDefault of touch{start,move} events. CSS touch-action and
  // user-select should be used instead of calling event.preventDefault().
  if (events.supportsPassive && /^touch(start|move)$/.test(event.type)) {
    const doc = getWindow(event.target).document
    const docOptions = scope.getDocOptions(doc)

    if (!(docOptions && docOptions.events) || docOptions.events.passive !== false) {
      return
    }
  }

  // don't preventDefault of pointerdown events
  if (/^(mouse|pointer|touch)*(down|start)/i.test(event.type)) {
    return
  }

  // don't preventDefault on editable elements
  if (is.element(event.target) &&
      matchesSelector(event.target, 'input,select,textarea,[contenteditable=true],[contenteditable=true] *')) {
    return
  }

  event.preventDefault()
}
開發者ID:taye,項目名稱:interact.js,代碼行數:37,代碼來源:interactablePreventDefault.ts


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