當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。