当前位置: 首页>>代码示例>>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;未经允许,请勿转载。