Port user-select suppression to iD.behavior.Drag

Fixes #1585
This commit is contained in:
John Firebaugh
2013-06-20 14:38:22 -07:00
parent d63f9c8381
commit a039f576e9
2 changed files with 21 additions and 2 deletions
+20 -1
View File
@@ -39,6 +39,23 @@ iD.behavior.drag = function() {
};
};
var d3_event_userSelectProperty = iD.util.prefixCSSProperty("UserSelect"),
d3_event_userSelectSuppress = d3_event_userSelectProperty ?
function () {
var selection = d3.selection(),
select = selection.style(d3_event_userSelectProperty);
selection.style(d3_event_userSelectProperty, 'none');
return function () {
selection.style(d3_event_userSelectProperty, select);
};
} :
function (type) {
var w = d3.select(window).on("selectstart." + type, d3_eventCancel);
return function () {
w.on("selectstart." + type, null);
};
};
function mousedown() {
target = this;
event_ = event.of(target, arguments);
@@ -46,7 +63,8 @@ iD.behavior.drag = function() {
touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null,
offset,
origin_ = point(),
moved = 0;
moved = 0,
selectEnable = d3_event_userSelectSuppress(touchId != null ? "drag-" + touchId : "drag");
var w = d3.select(window)
.on(touchId !== null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove)
@@ -103,6 +121,7 @@ iD.behavior.drag = function() {
w.on(touchId !== null ? "touchmove.drag-" + touchId : "mousemove.drag", null)
.on(touchId !== null ? "touchend.drag-" + touchId : "mouseup.drag", null);
selectEnable();
}
function click() {
+1 -1
View File
@@ -77,7 +77,7 @@ iD.util.prefixCSSProperty = function(property) {
while (++i < n)
if (prefixes[i] + property in s)
return '-' + prefixes[i].toLowerCase() + '-' + property.toLowerCase();
return '-' + prefixes[i].toLowerCase() + property.replace(/([A-Z])/g, '-$1').toLowerCase();
return false;
};