first commit
This commit is contained in:
commit
eb2f504652
32490 changed files with 5731109 additions and 0 deletions
49
node_modules/panzoom/lib/createTextSelectionInterceptor.js
generated
vendored
Normal file
49
node_modules/panzoom/lib/createTextSelectionInterceptor.js
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Disallows selecting text.
|
||||
*/
|
||||
module.exports = createTextSelectionInterceptor;
|
||||
|
||||
function createTextSelectionInterceptor(useFake) {
|
||||
if (useFake) {
|
||||
return {
|
||||
capture: noop,
|
||||
release: noop
|
||||
};
|
||||
}
|
||||
|
||||
var dragObject;
|
||||
var prevSelectStart;
|
||||
var prevDragStart;
|
||||
var wasCaptured = false;
|
||||
|
||||
return {
|
||||
capture: capture,
|
||||
release: release
|
||||
};
|
||||
|
||||
function capture(domObject) {
|
||||
wasCaptured = true;
|
||||
prevSelectStart = window.document.onselectstart;
|
||||
prevDragStart = window.document.ondragstart;
|
||||
|
||||
window.document.onselectstart = disabled;
|
||||
|
||||
dragObject = domObject;
|
||||
dragObject.ondragstart = disabled;
|
||||
}
|
||||
|
||||
function release() {
|
||||
if (!wasCaptured) return;
|
||||
|
||||
wasCaptured = false;
|
||||
window.document.onselectstart = prevSelectStart;
|
||||
if (dragObject) dragObject.ondragstart = prevDragStart;
|
||||
}
|
||||
}
|
||||
|
||||
function disabled(e) {
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue