当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript extend.default函数代码示例

本文整理汇总了TypeScript中@interactjs/utils/extend.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: extend

 interactables.signals.on('set', ({ interactable, options }) => {
   extend(interactable.events.options, pointerEvents.defaults)
   extend(interactable.events.options, options.pointerEvents || {})
 })
开发者ID:taye,项目名称:interact.js,代码行数:4,代码来源:interactableTargets.ts

示例2: start

import clone from '@interactjs/utils/clone'
import extend from '@interactjs/utils/extend'
import snapSize from './size'

function start (arg) {
  const edges = arg.interaction.prepared.edges

  if (!edges) { return null }

  arg.state.targetFields = arg.state.targetFields || [
    [edges.left ? 'left' : 'right', edges.top ? 'top' : 'bottom'],
  ]

  return snapSize.start(arg)
}

function set (arg) {
  return snapSize.set(arg)
}

const snapEdges = {
  start,
  set,
  defaults: extend(clone(snapSize.defaults), {
    offset: { x: 0, y: 0 },
  }),
}

export default snapEdges
开发者ID:taye,项目名称:interact.js,代码行数:29,代码来源:edges.ts

示例3: set

function set ({ coords, interaction, state }: {
  coords: Interact.Point,
  interaction: Interaction,
  state: any
}) {
  const { offset, options } = state
  const edges = interaction.prepared._linkedEdges || interaction.prepared.edges

  if (!edges) {
    return
  }

  const page = extend({}, coords)
  const inner = getRestrictionRect(options.inner, interaction, page) || {}
  const outer = getRestrictionRect(options.outer, interaction, page) || {}

  fixRect(inner, noInner)
  fixRect(outer, noOuter)

  if (edges.top) {
    coords.y = Math.min(Math.max(outer.top    + offset.top,    page.y), inner.top    + offset.top)
  }
  else if (edges.bottom) {
    coords.y = Math.max(Math.min(outer.bottom + offset.bottom, page.y), inner.bottom + offset.bottom)
  }
  if (edges.left) {
    coords.x = Math.min(Math.max(outer.left   + offset.left,   page.x), inner.left   + offset.left)
  }
  else if (edges.right) {
    coords.x = Math.max(Math.min(outer.right  + offset.right,  page.x), inner.right  + offset.right)
  }
}
开发者ID:taye,项目名称:interact.js,代码行数:32,代码来源:edges.ts

示例4: setCoords

function setCoords (arg) {
  const { interaction, phase } = arg
  const curCoords = arg.curCoords || interaction.coords.cur
  const startCoords = arg.startCoords || interaction.coords.start
  const { result, startDelta } = interaction.modifiers
  const curDelta = result.delta

  if (phase === 'start') {
    extend(interaction.modifiers.startDelta, result.delta)
  }

  for (const [coordsSet, delta] of [[startCoords, startDelta], [curCoords, curDelta]]) {
    coordsSet.page.x   += delta.x
    coordsSet.page.y   += delta.y
    coordsSet.client.x += delta.x
    coordsSet.client.y += delta.y
  }

  const { rectDelta } = interaction.modifiers.result
  const rect = arg.rect || interaction.rect

  rect.left   += rectDelta.left
  rect.right  += rectDelta.right
  rect.top    += rectDelta.top
  rect.bottom += rectDelta.bottom

  rect.width = rect.right - rect.left
  rect.height = rect.bottom - rect.top
}
开发者ID:taye,项目名称:interact.js,代码行数:29,代码来源:base.ts

示例5: set

function set (arg) {
  const { interaction, state } = arg
  const { options } = state
  const edges = interaction.prepared.linkedEdges || interaction.prepared.edges

  if (!edges) {
    return
  }

  const rect = rectUtils.xywhToTlbr(interaction.resizeRects.inverted)

  const minSize = rectUtils.tlbrToXywh(restrictEdges.getRestrictionRect(options.min, interaction)) || noMin
  const maxSize = rectUtils.tlbrToXywh(restrictEdges.getRestrictionRect(options.max, interaction)) || noMax

  state.options = {
    enabled: options.enabled,
    endOnly: options.endOnly,
    inner: extend({}, restrictEdges.noInner),
    outer: extend({}, restrictEdges.noOuter),
  }

  if (edges.top) {
    state.options.inner.top = rect.bottom - minSize.height
    state.options.outer.top = rect.bottom - maxSize.height
  }
  else if (edges.bottom) {
    state.options.inner.bottom = rect.top + minSize.height
    state.options.outer.bottom = rect.top + maxSize.height
  }
  if (edges.left) {
    state.options.inner.left = rect.right - minSize.width
    state.options.outer.left = rect.right - maxSize.width
  }
  else if (edges.right) {
    state.options.inner.right = rect.left + minSize.width
    state.options.outer.right = rect.left + maxSize.width
  }

  restrictEdges.set(arg)

  state.options = options
}
开发者ID:taye,项目名称:interact.js,代码行数:42,代码来源:size.ts

示例6: start

function start (
  { interaction, phase }: Interact.SignalArg,
  pageCoords: Interact.Point,
  registeredModifiers,
) {
  const { interactable, element } = interaction
  const modifierList = getModifierList(interaction, registeredModifiers)
  const states = prepareStates(modifierList)

  const rect = extend({}, interaction.rect)

  if (!('width'  in rect)) { rect.width  = rect.right  - rect.left }
  if (!('height' in rect)) { rect.height = rect.bottom - rect.top  }

  const startOffset = getRectOffset(rect, pageCoords)

  interaction.modifiers.startOffset = startOffset
  interaction.modifiers.startDelta = { x: 0, y: 0 }

  const arg: Partial<Interact.SignalArg> = {
    interaction,
    interactable,
    element,
    pageCoords,
    phase,
    rect,
    startOffset,
    states,
    preEnd: false,
    requireEndOnly: false,
  }

  interaction.modifiers.states = states
  interaction.modifiers.result = null
  startAll(arg)

  arg.pageCoords = extend({}, interaction.coords.start.page)

  const result = interaction.modifiers.result = setAll(arg)

  return result
}
开发者ID:taye,项目名称:interact.js,代码行数:42,代码来源:base.ts

示例7: init

export function init (win: Window) {
  initInteract(win)

  return interact.use({
    id: 'interactjs',
    install (scope) {
      interact.modifiers = extend(scope.modifiers, modifiers)
      interact.snappers = snappers
      interact.createSnapGrid = interact.snappers.grid
    },
  })
}
开发者ID:taye,项目名称:interact.js,代码行数:12,代码来源:index.ts

示例8: stop

function stop (arg) {
  const { interaction } = arg
  const states = interaction.modifiers.states

  if (!states || !states.length) {
    return
  }

  const modifierArg = extend({
    states,
    interactable: interaction.interactable,
    element: interaction.element,
  }, arg)

  restoreCoords(arg)

  for (const state of states) {
    modifierArg.state = state

    if (state.methods.stop) { state.methods.stop(modifierArg) }
  }

  arg.interaction.modifiers.states = null
}
开发者ID:taye,项目名称:interact.js,代码行数:24,代码来源:base.ts

示例9: pointerEventsMethod

function pointerEventsMethod (this: Interactable, options: any) {
  extend(this.events.options, options)

  return this
}
开发者ID:taye,项目名称:interact.js,代码行数:5,代码来源:interactableTargets.ts


注:本文中的@interactjs/utils/extend.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。