@telerik/kendo-draggable
Advanced tools
Comparing version 1.5.1 to 1.6.0-dev.201711241149
@@ -7,4 +7,10 @@ var proxy = function (a, b) { return function (e) { return b(a(e)); }; }; | ||
var noop = function () { /* empty */ }; | ||
var touchRegExp = /touch/; | ||
// 300ms is the usual mouse interval; | ||
// // However, an underpowered mobile device under a heavy load may queue mouse events for a longer period. | ||
var IGNORE_MOUSE_TIMEOUT = 2000; | ||
function normalizeEvent(e) { | ||
@@ -23,2 +29,4 @@ if (e.type.match(touchRegExp)) { | ||
pageY: e.pageY, | ||
offsetX: e.offsetX, | ||
offsetY: e.offsetY, | ||
type: e.type, | ||
@@ -32,9 +40,3 @@ ctrlKey: e.ctrlKey, | ||
var noop = function() { }; | ||
// 300ms is the usual mouse interval; | ||
// However, an underpowered mobile device under a heavy load may queue mouse events for a longer period. | ||
var IGNORE_MOUSE_TIMEOUT = 2000; | ||
var Draggable = function Draggable(ref) { | ||
export var Draggable = function Draggable(ref) { | ||
var this$1 = this; | ||
@@ -48,4 +50,4 @@ var press = ref.press; if ( press === void 0 ) press = noop; | ||
this._releaseHandler = proxy(normalizeEvent, release); | ||
this._ignoreMouse = false; | ||
this._touchAction; | ||
@@ -99,4 +101,30 @@ this._touchstart = function (e) { | ||
}; | ||
this._pointerdown = function (e) { | ||
if (e.isPrimary) { | ||
this$1._touchAction = e.target.style.touchAction; | ||
e.target.style.touchAction = "none"; | ||
e.target.setPointerCapture(e.pointerId); | ||
this$1._pressHandler(e); | ||
} | ||
}; | ||
this._pointermove = function (e) { | ||
if (e.isPrimary) { | ||
this$1._dragHandler(e); | ||
} | ||
}; | ||
this._pointerup = function (e) { | ||
if (e.isPrimary) { | ||
e.target.style.touchAction = this$1._touchAction; | ||
this$1._releaseHandler(e); | ||
} | ||
}; | ||
}; | ||
Draggable.supportPointerEvent = function supportPointerEvent () { | ||
return window.PointerEvent; | ||
}; | ||
Draggable.prototype.bindTo = function bindTo (element) { | ||
@@ -113,13 +141,25 @@ if (element === this._element) { | ||
bind(element, "mousedown", this._mousedown); | ||
bind(element, "touchstart", this._touchstart); | ||
bind(element, "touchmove", this._touchmove); | ||
bind(element, "touchend", this._touchend); | ||
if (Draggable.supportPointerEvent()) { | ||
bind(element, "pointerdown", this._pointerdown); | ||
bind(element, "pointermove", this._pointermove); | ||
bind(element, "pointerup", this._pointerup); | ||
} else { | ||
bind(element, "mousedown", this._mousedown); | ||
bind(element, "touchstart", this._touchstart); | ||
bind(element, "touchmove", this._touchmove); | ||
bind(element, "touchend", this._touchend); | ||
} | ||
}; | ||
Draggable.prototype._unbindFromCurrent = function _unbindFromCurrent () { | ||
unbind(this._element, "mousedown", this._mousedown); | ||
unbind(this._element, "touchstart", this._touchstart); | ||
unbind(this._element, "touchmove", this._touchmove); | ||
unbind(this._element, "touchend", this._touchend); | ||
if (Draggable.supportPointerEvent()) { | ||
unbind(this._element, "pointerdown", this._pointerdown); | ||
unbind(this._element, "pointermove", this._pointermove); | ||
unbind(this._element, "pointerup", this._pointerup); | ||
} else { | ||
unbind(this._element, "mousedown", this._mousedown); | ||
unbind(this._element, "touchstart", this._touchstart); | ||
unbind(this._element, "touchmove", this._touchmove); | ||
unbind(this._element, "touchend", this._touchend); | ||
} | ||
}; | ||
@@ -132,4 +172,6 @@ | ||
export { Draggable };export default Draggable; | ||
// Rollup won't output exports['default'] otherwise | ||
export default Draggable; | ||
//# sourceMappingURL=main.js.map |
@@ -11,4 +11,10 @@ 'use strict'; | ||
var noop = function () { /* empty */ }; | ||
var touchRegExp = /touch/; | ||
// 300ms is the usual mouse interval; | ||
// // However, an underpowered mobile device under a heavy load may queue mouse events for a longer period. | ||
var IGNORE_MOUSE_TIMEOUT = 2000; | ||
function normalizeEvent(e) { | ||
@@ -27,2 +33,4 @@ if (e.type.match(touchRegExp)) { | ||
pageY: e.pageY, | ||
offsetX: e.offsetX, | ||
offsetY: e.offsetY, | ||
type: e.type, | ||
@@ -36,8 +44,2 @@ ctrlKey: e.ctrlKey, | ||
var noop = function() { }; | ||
// 300ms is the usual mouse interval; | ||
// However, an underpowered mobile device under a heavy load may queue mouse events for a longer period. | ||
var IGNORE_MOUSE_TIMEOUT = 2000; | ||
var Draggable = function Draggable(ref) { | ||
@@ -52,4 +54,4 @@ var this$1 = this; | ||
this._releaseHandler = proxy(normalizeEvent, release); | ||
this._ignoreMouse = false; | ||
this._touchAction; | ||
@@ -103,4 +105,30 @@ this._touchstart = function (e) { | ||
}; | ||
this._pointerdown = function (e) { | ||
if (e.isPrimary) { | ||
this$1._touchAction = e.target.style.touchAction; | ||
e.target.style.touchAction = "none"; | ||
e.target.setPointerCapture(e.pointerId); | ||
this$1._pressHandler(e); | ||
} | ||
}; | ||
this._pointermove = function (e) { | ||
if (e.isPrimary) { | ||
this$1._dragHandler(e); | ||
} | ||
}; | ||
this._pointerup = function (e) { | ||
if (e.isPrimary) { | ||
e.target.style.touchAction = this$1._touchAction; | ||
this$1._releaseHandler(e); | ||
} | ||
}; | ||
}; | ||
Draggable.supportPointerEvent = function supportPointerEvent () { | ||
return window.PointerEvent; | ||
}; | ||
Draggable.prototype.bindTo = function bindTo (element) { | ||
@@ -117,13 +145,25 @@ if (element === this._element) { | ||
bind(element, "mousedown", this._mousedown); | ||
bind(element, "touchstart", this._touchstart); | ||
bind(element, "touchmove", this._touchmove); | ||
bind(element, "touchend", this._touchend); | ||
if (Draggable.supportPointerEvent()) { | ||
bind(element, "pointerdown", this._pointerdown); | ||
bind(element, "pointermove", this._pointermove); | ||
bind(element, "pointerup", this._pointerup); | ||
} else { | ||
bind(element, "mousedown", this._mousedown); | ||
bind(element, "touchstart", this._touchstart); | ||
bind(element, "touchmove", this._touchmove); | ||
bind(element, "touchend", this._touchend); | ||
} | ||
}; | ||
Draggable.prototype._unbindFromCurrent = function _unbindFromCurrent () { | ||
unbind(this._element, "mousedown", this._mousedown); | ||
unbind(this._element, "touchstart", this._touchstart); | ||
unbind(this._element, "touchmove", this._touchmove); | ||
unbind(this._element, "touchend", this._touchend); | ||
if (Draggable.supportPointerEvent()) { | ||
unbind(this._element, "pointerdown", this._pointerdown); | ||
unbind(this._element, "pointermove", this._pointermove); | ||
unbind(this._element, "pointerup", this._pointerup); | ||
} else { | ||
unbind(this._element, "mousedown", this._mousedown); | ||
unbind(this._element, "touchstart", this._touchstart); | ||
unbind(this._element, "touchmove", this._touchmove); | ||
unbind(this._element, "touchend", this._touchend); | ||
} | ||
}; | ||
@@ -130,0 +170,0 @@ |
{ | ||
"name": "@telerik/kendo-draggable", | ||
"description": "A cross-browser/event abstraction that handles mouse and touch drag sequences", | ||
"version": "1.5.1", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/telerik/kendo-draggable.git" | ||
}, | ||
"version": "1.6.0-dev.201711241149", | ||
"main": "dist/npm/main.js", | ||
@@ -17,3 +13,3 @@ "module": "dist/es/main.js", | ||
"lint": "gulp lint", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
"semantic-release": "semantic-release pre && semantic-prerelease publish && semantic-release post" | ||
}, | ||
@@ -26,3 +22,4 @@ "keywords": [ | ||
"@telerik/eslint-config": "^1.0.0", | ||
"@telerik/kendo-package-tasks": "^1.6.0", | ||
"@telerik/kendo-package-tasks": "^1.6.1", | ||
"@telerik/semantic-prerelease": "^1.0.0", | ||
"cz-conventional-changelog": "^1.1.5", | ||
@@ -32,5 +29,5 @@ "ghooks": "^1.0.3", | ||
"validate-commit-msg": "^1.1.1", | ||
"semantic-release": "^4.3.5" | ||
"semantic-release": "^6.3.6" | ||
}, | ||
"author": "Telerik", | ||
"author": "Progress", | ||
"license": "Apache-2.0", | ||
@@ -61,3 +58,24 @@ "config": { | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/telerik/kendo-draggable.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/telerik/kendo-draggable/issues" | ||
}, | ||
"release": { | ||
"debug": false, | ||
"branchTags": { | ||
"develop": "dev" | ||
}, | ||
"fallbackTags": { | ||
"dev": "latest" | ||
}, | ||
"analyzeCommits": "@telerik/semantic-prerelease/analyzeCommits", | ||
"generateNotes": "@telerik/semantic-prerelease/generateNotes", | ||
"getLastRelease": "@telerik/semantic-prerelease/getLastRelease", | ||
"verifyConditions": "@telerik/semantic-prerelease/verifyConditions", | ||
"verifyRelease": "@telerik/semantic-prerelease/verifyRelease" | ||
} | ||
} |
@@ -5,12 +5,25 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
A cross-platform abstraction for drag sequences. Handles mouse drags and touch sequences on mobile devices. | ||
A repository for the cross-platform abstraction for drag sequences. | ||
Drag sequence means: | ||
* [Overview](#overview) | ||
* [Installation](#installation) | ||
* [Basic Usage](#basic-usage) | ||
* [Features](#features) | ||
* [What's Next](#whats-next) | ||
* [Dragging on iOS/Android](#dragging-on-iosandroid) | ||
* [Preventing Selection](#preventing-selection) | ||
* [Browser Support](#browser-support) | ||
- mouse press, drag, release for desktop devices | ||
- touch press, drag, release for mobile devices | ||
## Overview | ||
The Kendo UI Draggable component handles mouse drags and touch sequences on mobile devices. | ||
A drag sequence means: | ||
- Mouse click, drag, release for desktop devices. | ||
- Touch press, drag, release for mobile devices. | ||
## Installation | ||
The library is published as [scoped NPM package](https://docs.npmjs.com/misc/scope) in the [NPMJS Telerik account](https://www.npmjs.com/~telerik). | ||
The library is published as a [scoped NPM package](https://docs.npmjs.com/misc/scope) in the [NPMJS Telerik account](https://www.npmjs.com/~telerik). | ||
@@ -21,5 +34,5 @@ ```bash | ||
## Basic usage | ||
## Basic Usage | ||
The draggable class constructor accepts an object with three optional event handler callbacks - `press`, `drag`, and `release`. | ||
The `draggable` class constructor accepts an object with three optional event handler callbacks—`press`, `drag`, and `release`. | ||
@@ -44,3 +57,3 @@ ```javascript | ||
The draggable may be re-bound to another element - the event handlers will be automatically unbound from the previous one. | ||
The Draggable may be re-bound to another element—the event handlers will be automatically unbound from the previous one. | ||
@@ -51,3 +64,3 @@ ```javascript | ||
Since the draggable object persists a reference to the currently bound element, it should be destroyed when/if the corresponding element is removed from the document. | ||
The `draggable` object persists a reference to the currently bound element. That is why it should be destroyed when or if the corresponding element is removed from the document. | ||
@@ -60,18 +73,18 @@ ```javascript | ||
- mouse events support | ||
- touch events support | ||
- Handle multiple touches. Rather, don't get confused by them. | ||
The Kendo UI Draggable supports: | ||
## What's next | ||
- Pointer events support, necessary for the Windows Phone platform. | ||
- Mouse events | ||
- Touch events | ||
- Handling of multiple touches. Rather, not getting confused by them. | ||
### Dragging on iOS/Android | ||
## What's Next | ||
Handling the drag sequence on mobile devices may require disabling of the touch based scrolling. | ||
The draggable will not do that out of the box. The recommended way to handle this is by setting a [`touch-action`](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS property. | ||
Depending on the type of drags handled, you may need `touch-action: none`, `touch-action: pan-y` or `touch-action: pan-x`. | ||
Support for Pointer events support, necessary for the Windows Phone platform. | ||
**Notice**: `touch-action` does not work for iOS (yet). Limited support should be available in iOS 9.3, which just got released. However, `pan-x` and `pan-y` don't work. | ||
The simplest means to disable the scrolling in iOS is by preventing the `touchstart` event: | ||
## Dragging on iOS/Android | ||
Handling the drag sequence on mobile devices may require the disabling of the touch-based scrolling. The Draggable will not do that out of the box. The recommended way to handle this issue is by setting a [`touch-action`](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS property. Depending on the type of drags that are handled, you may need `touch-action: none`, `touch-action: pan-y`, or `touch-action: pan-x`. | ||
> The `touch-action` setting does not work for iOS yet. While the iOS 9.3 version, which has been released recently, provides limited support, `pan-x` and `pan-y` do not work. To disable the touch-based scrolling in iOS, prevent the `touchstart` event: | ||
```html | ||
@@ -83,10 +96,8 @@ <div ontouchstart="return false"> | ||
### Preventing Selection | ||
## Preventing Selection | ||
Dragging elements with text in them will activate the browser text selection, which, in most cases, is not desirable. | ||
The dragging of elements that contain text activates the browser text selection, which, in most cases, is not desirable. To avoid this behavior, use the [`user-select: none`](https://developer.mozilla.org/en-US/docs/Web/CSS/user-select) CSS property with its respective browser prefixes. | ||
To avoid this, use [`user-select: none`](https://developer.mozilla.org/en-US/docs/Web/CSS/user-select) CSS property with its respective browser prefixes. | ||
## Browser Support | ||
### Browser Support | ||
- Google Chrome | ||
@@ -93,0 +104,0 @@ - Firefox |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
42704
10
290
0
103
8
2