本文整理汇总了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 || {})
})
示例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
示例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)
}
}
示例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
}
示例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
}
示例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
}
示例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
},
})
}
示例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
}
示例9: pointerEventsMethod
function pointerEventsMethod (this: Interactable, options: any) {
extend(this.events.options, options)
return this
}