本文整理汇总了TypeScript中@interactjs/utils.arr.merge方法的典型用法代码示例。如果您正苦于以下问题:TypeScript arr.merge方法的具体用法?TypeScript arr.merge怎么用?TypeScript arr.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@interactjs/utils.arr
的用法示例。
在下文中一共展示了arr.merge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: install
function install (scope: Scope) {
const {
actions,
Interactable,
interactions,
defaults,
} = scope
/**
* ```js
* interact(element).gesturable({
* onstart: function (event) {},
* onmove : function (event) {},
* onend : function (event) {},
*
* // limit multiple gestures.
* // See the explanation in {@link Interactable.draggable} example
* max: Infinity,
* maxPerElement: 1,
* })
*
* var isGestureable = interact(element).gesturable()
* ```
*
* Gets or sets whether multitouch gestures can be performed on the target
*
* @param {boolean | object} [options] true/false or An object with event
* listeners to be fired on gesture events (makes the Interactable gesturable)
* @return {boolean | Interactable} A boolean indicating if this can be the
* target of gesture events, or this Interactable
*/
Interactable.prototype.gesturable = function (this: Interact.Interactable, options: Interact.GesturableOptions | boolean) {
if (utils.is.object(options)) {
this.options.gesture.enabled = options.enabled !== false
this.setPerAction('gesture', options)
this.setOnEvents('gesture', options)
return this
}
if (utils.is.bool(options)) {
this.options.gesture.enabled = options
return this
}
return this.options.gesture as Interact.Options
} as GesturableMethod
interactions.signals.on('action-start', updateGestureProps)
interactions.signals.on('action-move', updateGestureProps)
interactions.signals.on('action-end', updateGestureProps)
interactions.signals.on('new', ({ interaction }) => {
interaction.gesture = {
angle: 0,
distance: 0,
scale: 1,
startAngle: 0,
startDistance: 0,
}
})
actions[ActionName.Gesture] = gesture
actions.names.push(ActionName.Gesture)
utils.arr.merge(actions.eventTypes, [
'gesturestart',
'gesturemove',
'gestureend',
])
actions.methodDict.gesture = 'gesturable'
defaults.actions.gesture = gesture.defaults
}
示例2: install
//.........这里部分代码省略.........
})
/**
*
* ```js
* interact('.drop').dropzone({
* accept: '.can-drop' || document.getElementById('single-drop'),
* overlap: 'pointer' || 'center' || zeroToOne
* }
* ```
*
* Returns or sets whether draggables can be dropped onto this target to
* trigger drop events
*
* Dropzones can receive the following events:
* - `dropactivate` and `dropdeactivate` when an acceptable drag starts and ends
* - `dragenter` and `dragleave` when a draggable enters and leaves the dropzone
* - `dragmove` when a draggable that has entered the dropzone is moved
* - `drop` when a draggable is dropped into this dropzone
*
* Use the `accept` option to allow only elements that match the given CSS
* selector or element. The value can be:
*
* - **an Element** - only that element can be dropped into this dropzone.
* - **a string**, - the element being dragged must match it as a CSS selector.
* - **`null`** - accept options is cleared - it accepts any element.
*
* Use the `overlap` option to set how drops are checked for. The allowed
* values are:
*
* - `'pointer'`, the pointer must be over the dropzone (default)
* - `'center'`, the draggable element's center must be over the dropzone
* - a number from 0-1 which is the `(intersection area) / (draggable area)`.
* e.g. `0.5` for drop to happen when half of the area of the draggable is
* over the dropzone
*
* Use the `checker` option to specify a function to check if a dragged element
* is over this Interactable.
*
* @param {boolean | object | null} [options] The new options to be set.
* @return {boolean | Interactable} The current setting or this Interactable
*/
Interactable.prototype.dropzone = function (this: Interact.Interactable, options?: Interact.DropzoneOptions | boolean) {
return dropzoneMethod(this, options)
}
/**
* ```js
* interact(target)
* .dropChecker(function(dragEvent, // related dragmove or dragend event
* event, // TouchEvent/PointerEvent/MouseEvent
* dropped, // bool result of the default checker
* dropzone, // dropzone Interactable
* dropElement, // dropzone elemnt
* draggable, // draggable Interactable
* draggableElement) {// draggable element
*
* return dropped && event.target.hasAttribute('allow-drop')
* }
* ```
*/
Interactable.prototype.dropCheck = function (this: Interact.Interactable, dragEvent, event, draggable, draggableElement, dropElement, rect) {
return dropCheckMethod(this, dragEvent, event, draggable, draggableElement, dropElement, rect)
}
/**
* Returns or sets whether the dimensions of dropzone elements are calculated
* on every dragmove or only on dragstart for the default dropChecker
*
* @param {boolean} [newValue] True to check on each move. False to check only
* before start
* @return {boolean | interact} The current setting or interact
*/
interact.dynamicDrop = function (newValue?: boolean) {
if (utils.is.bool(newValue)) {
// if (dragging && scope.dynamicDrop !== newValue && !newValue) {
// calcRects(dropzones)
// }
scope.dynamicDrop = newValue
return interact
}
return scope.dynamicDrop
}
utils.arr.merge(actions.eventTypes, [
'dragenter',
'dragleave',
'dropactivate',
'dropdeactivate',
'dropmove',
'drop',
])
actions.methodDict.drop = 'dropzone'
scope.dynamicDrop = false
defaults.actions.drop = drop.defaults
}
示例3: install
function install (scope: Scope) {
const {
actions,
browser,
/** @lends Interactable */
Interactable, // tslint:disable-line no-shadowed-variable
interactions,
defaults,
} = scope
// Less Precision with touch input
interactions.signals.on('new', (interaction) => {
interaction.resizeAxes = 'xy'
})
interactions.signals.on('action-start', start)
interactions.signals.on('action-move', move)
interactions.signals.on('action-start', updateEventAxes)
interactions.signals.on('action-move', updateEventAxes)
resize.cursors = initCursors(browser)
resize.defaultMargin = browser.supportsTouch || browser.supportsPointerEvent ? 20 : 10
/**
* ```js
* interact(element).resizable({
* onstart: function (event) {},
* onmove : function (event) {},
* onend : function (event) {},
*
* edges: {
* top : true, // Use pointer coords to check for resize.
* left : false, // Disable resizing from left edge.
* bottom: '.resize-s',// Resize if pointer target matches selector
* right : handleEl // Resize if pointer target is the given Element
* },
*
* // Width and height can be adjusted independently. When `true`, width and
* // height are adjusted at a 1:1 ratio.
* square: false,
*
* // Width and height can be adjusted independently. When `true`, width and
* // height maintain the aspect ratio they had when resizing started.
* preserveAspectRatio: false,
*
* // a value of 'none' will limit the resize rect to a minimum of 0x0
* // 'negate' will allow the rect to have negative width/height
* // 'reposition' will keep the width/height positive by swapping
* // the top and bottom edges and/or swapping the left and right edges
* invert: 'none' || 'negate' || 'reposition'
*
* // limit multiple resizes.
* // See the explanation in the {@link Interactable.draggable} example
* max: Infinity,
* maxPerElement: 1,
* })
*
* var isResizeable = interact(element).resizable()
* ```
*
* Gets or sets whether resize actions can be performed on the target
*
* @param {boolean | object} [options] true/false or An object with event
* listeners to be fired on resize events (object makes the Interactable
* resizable)
* @return {boolean | Interactable} A boolean indicating if this can be the
* target of resize elements, or this Interactable
*/
Interactable.prototype.resizable = function (this: Interact.Interactable, options: Interact.ResizableOptions | boolean) {
return resizable(this, options, scope)
} as ResizableMethod
actions[ActionName.Resize] = resize
actions.names.push(ActionName.Resize)
utils.arr.merge(actions.eventTypes, [
'resizestart',
'resizemove',
'resizeinertiastart',
'resizeresume',
'resizeend',
])
actions.methodDict.resize = 'resizable'
defaults.actions.resize = resize.defaults
}