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 */{
add: function(el, events) {
for (var type in events) {
var func = events[type],
parts = type.split(/[\s,]+/g);
for (var i = 0, l = parts.length; i < l; i++)
el.addEventListener(parts[i], func, false);
}
for (var type in events)
el.addEventListener(type, events[type], false);
},
remove: function(el, events) {
for (var type in events) {
var func = events[type],
parts = type.split(/[\s,]+/g);
for (var i = 0, l = parts.length; i < l; i++)
el.removeEventListener(parts[i], func, false);
}
for (var type in events)
el.removeEventListener(type, events[type], false);
},
getPoint: function(event) {

View file

@ -43,10 +43,10 @@ var View = Base.extend(Emitter, /** @lends View# */{
// Borrowed from Hammer.js:
var none = 'none';
DomElement.setPrefixed(element.style, {
userDrag: none,
userSelect: none,
touchCallout: none,
contentZooming: none,
userDrag: none,
tapHighlightColor: 'rgba(0,0,0,0)'
});
@ -786,16 +786,8 @@ new function() { // Injection scope for mouse events on the browser
}
}
var viewEvents = {
'selectstart dragstart': function(event) {
// 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 = {
var viewEvents = {},
docEvents = {
// NOTE: mouseleave does not seem to work on document in IE:
mouseout: function(event) {
// 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,
target = DomEvent.getRelatedTarget(event);
if (view && (!target || target.nodeName === 'HTML')) {
// See #800 for this bizarre workaround for an issue of Chrome
// on Windows:
// TODO: Remove again after Dec 2016 once it is fixed in Chrome.
// See #800 for this bizarre workaround for an issue of
// Chrome on Windows:
// TODO: Remove again after Dec 2016, once fixed in Chrome.
var offset = DomEvent.getOffset(event, view._element),
x = offset.x,
abs = Math.abs,