Merge branch 'iframe-drag'
* iframe-drag: fix jshint errors Refine existing methods for disabling text selection Add iframe debug html Suppress text selection behavior during drag Continue to preventDefault on touch Remove preventDefault and mousedown workaround
This commit is contained in:
commit
95d6d27cb0
11
debug/map/iframe.html
Normal file
11
debug/map/iframe.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<style>
|
||||||
|
iframe {
|
||||||
|
position: absolute;
|
||||||
|
top: 50px;
|
||||||
|
left: 50px;
|
||||||
|
width: 500px;
|
||||||
|
height: 500px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<iframe src="map.html">
|
||||||
|
</iframe>
|
@ -117,23 +117,6 @@ L.DomUtil = {
|
|||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
disableTextSelection: function () {
|
|
||||||
if (document.selection && document.selection.empty) {
|
|
||||||
document.selection.empty();
|
|
||||||
}
|
|
||||||
if (!this._onselectstart) {
|
|
||||||
this._onselectstart = document.onselectstart || null;
|
|
||||||
document.onselectstart = L.Util.falseFn;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
enableTextSelection: function () {
|
|
||||||
if (document.onselectstart === L.Util.falseFn) {
|
|
||||||
document.onselectstart = this._onselectstart;
|
|
||||||
this._onselectstart = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
hasClass: function (el, name) {
|
hasClass: function (el, name) {
|
||||||
return (el.className.length > 0) &&
|
return (el.className.length > 0) &&
|
||||||
new RegExp('(^|\\s)' + name + '(\\s|$)').test(el.className);
|
new RegExp('(^|\\s)' + name + '(\\s|$)').test(el.className);
|
||||||
@ -253,3 +236,27 @@ L.DomUtil.TRANSITION = L.DomUtil.testProp(
|
|||||||
L.DomUtil.TRANSITION_END =
|
L.DomUtil.TRANSITION_END =
|
||||||
L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?
|
L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?
|
||||||
L.DomUtil.TRANSITION + 'End' : 'transitionend';
|
L.DomUtil.TRANSITION + 'End' : 'transitionend';
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var userSelectProperty = L.DomUtil.testProp(
|
||||||
|
['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);
|
||||||
|
|
||||||
|
L.DomUtil.disableTextSelection = function () {
|
||||||
|
if (userSelectProperty) {
|
||||||
|
var style = document.documentElement.style;
|
||||||
|
this._userSelect = style[userSelectProperty];
|
||||||
|
style[userSelectProperty] = 'none';
|
||||||
|
} else {
|
||||||
|
L.DomEvent.on(window, 'selectstart', L.DomEvent.stop);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
L.DomUtil.enableTextSelection = function () {
|
||||||
|
if (userSelectProperty) {
|
||||||
|
document.documentElement.style[userSelectProperty] = this._userSelect;
|
||||||
|
delete this._userSelect;
|
||||||
|
} else {
|
||||||
|
L.DomEvent.off(window, 'selectstart', L.DomEvent.stop);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
@ -51,6 +51,10 @@ L.Draggable = L.Class.extend({
|
|||||||
L.DomEvent
|
L.DomEvent
|
||||||
.stopPropagation(e);
|
.stopPropagation(e);
|
||||||
|
|
||||||
|
if (e.type === 'touchstart') {
|
||||||
|
L.DomEvent.preventDefault(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (L.Draggable._disabled) { return; }
|
if (L.Draggable._disabled) { return; }
|
||||||
|
|
||||||
var first = e.touches ? e.touches[0] : e,
|
var first = e.touches ? e.touches[0] : e,
|
||||||
@ -71,10 +75,6 @@ L.Draggable = L.Class.extend({
|
|||||||
L.DomEvent
|
L.DomEvent
|
||||||
.on(document, L.Draggable.MOVE[e.type], this._onMove, this)
|
.on(document, L.Draggable.MOVE[e.type], this._onMove, this)
|
||||||
.on(document, L.Draggable.END[e.type], this._onUp, this);
|
.on(document, L.Draggable.END[e.type], this._onUp, this);
|
||||||
|
|
||||||
if (e.type === 'mousedown') {
|
|
||||||
L.DomEvent.on(document, 'mouseout', this._onUp, this);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMove: function (e) {
|
_onMove: function (e) {
|
||||||
@ -125,8 +125,6 @@ L.Draggable = L.Class.extend({
|
|||||||
.off(document, L.Draggable.END[i], this._onUp);
|
.off(document, L.Draggable.END[i], this._onUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
L.DomEvent.off(document, 'mouseout', this._onUp);
|
|
||||||
|
|
||||||
if (this._moved) {
|
if (this._moved) {
|
||||||
// ensure drag is not fired after dragend
|
// ensure drag is not fired after dragend
|
||||||
L.Util.cancelAnimFrame(this._animRequest);
|
L.Util.cancelAnimFrame(this._animRequest);
|
||||||
|
Loading…
Reference in New Issue
Block a user