本文整理匯總了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)
}
}
})
示例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
}
示例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 },
})
}
})
示例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()
}