Remove unnecessary overrides of selectstart dragstart on view.

And simplify DomEvent.add() / remove(), as we don't need support for multiple types in one entry anymore.
This commit is contained in:
Jürg Lehni 2016-01-13 18:04:54 +01:00
parent 8b0340e6df
commit 0780a87429
2 changed files with 29 additions and 45 deletions

View file

@ -17,21 +17,13 @@
*/ */
var DomEvent = /** @lends DomEvent */{ var DomEvent = /** @lends DomEvent */{
add: function(el, events) { add: function(el, events) {
for (var type in events) { for (var type in events)
var func = events[type], el.addEventListener(type, events[type], false);
parts = type.split(/[\s,]+/g);
for (var i = 0, l = parts.length; i < l; i++)
el.addEventListener(parts[i], func, false);
}
}, },
remove: function(el, events) { remove: function(el, events) {
for (var type in events) { for (var type in events)
var func = events[type], el.removeEventListener(type, events[type], false);
parts = type.split(/[\s,]+/g);
for (var i = 0, l = parts.length; i < l; i++)
el.removeEventListener(parts[i], func, false);
}
}, },
getPoint: function(event) { getPoint: function(event) {

View file

@ -43,10 +43,10 @@ var View = Base.extend(Emitter, /** @lends View# */{
// Borrowed from Hammer.js: // Borrowed from Hammer.js:
var none = 'none'; var none = 'none';
DomElement.setPrefixed(element.style, { DomElement.setPrefixed(element.style, {
userDrag: none,
userSelect: none, userSelect: none,
touchCallout: none, touchCallout: none,
contentZooming: none, contentZooming: none,
userDrag: none,
tapHighlightColor: 'rgba(0,0,0,0)' tapHighlightColor: 'rgba(0,0,0,0)'
}); });
@ -786,16 +786,8 @@ new function() { // Injection scope for mouse events on the browser
} }
} }
var viewEvents = { var viewEvents = {},
'selectstart dragstart': function(event) { docEvents = {
// Only stop this even if we're mouseDown already, since otherwise
// no text whatsoever can be selected on the page.
if (mouseDown)
event.preventDefault();
}
};
var docEvents = {
// NOTE: mouseleave does not seem to work on document in IE: // NOTE: mouseleave does not seem to work on document in IE:
mouseout: function(event) { mouseout: function(event) {
// When the moues leaves the document, fire one last mousemove // When the moues leaves the document, fire one last mousemove
@ -803,9 +795,9 @@ new function() { // Injection scope for mouse events on the browser
var view = View._focused, var view = View._focused,
target = DomEvent.getRelatedTarget(event); target = DomEvent.getRelatedTarget(event);
if (view && (!target || target.nodeName === 'HTML')) { if (view && (!target || target.nodeName === 'HTML')) {
// See #800 for this bizarre workaround for an issue of Chrome // See #800 for this bizarre workaround for an issue of
// on Windows: // Chrome on Windows:
// TODO: Remove again after Dec 2016 once it is fixed in Chrome. // TODO: Remove again after Dec 2016, once fixed in Chrome.
var offset = DomEvent.getOffset(event, view._element), var offset = DomEvent.getOffset(event, view._element),
x = offset.x, x = offset.x,
abs = Math.abs, abs = Math.abs,