fix(label-editing): use new isTouch detection for conditional activation

Chrome and other modern desktop browsers
ship with touch features out of the box.

Because of that, it is not possible to use
the check

```
'ontouchstart' in document.documentElement
```
This commit is contained in:
Nico Rehwaldt 2017-12-08 19:32:13 +01:00
parent 2b37cebeb6
commit 7e928ec709
1 changed files with 24 additions and 16 deletions

View File

@ -40,16 +40,26 @@ function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, res
directEditing.cancel();
});
if ('ontouchstart' in document.documentElement) {
// we deactivate automatic label editing on mobile devices
eventBus.on('directEditing.activate', function(event) {
resizeHandles.removeResizers();
});
eventBus.on('create.end', 500, function(event) {
var element = event.shape,
canExecute = event.context.canExecute,
isTouch;
// TODO(nikku): we need to find a way to support the direct editing
// on mobile devices; right now this will break for desworkflowediting on mobile devices
// as it breaks the user interaction workflow
// TODO(nre): we should temporarily focus the edited element here
// and release the focused viewport after the direct edit operation is finished
} else {
eventBus.on('create.end', 500, function(event) {
var element = event.shape,
canExecute = event.context.canExecute;
if (isTouch) {
return;
}
if (!canExecute) {
return;
@ -58,11 +68,9 @@ function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, res
if (is(element, 'bpmn:Task') || is(element, 'bpmn:TextAnnotation') ||
(is(element, 'bpmn:SubProcess') && !isExpanded(element))) {
directEditing.activate(element);
resizeHandles.removeResizers();
}
});
}
}
LabelEditingProvider.$inject = [ 'eventBus', 'canvas', 'directEditing', 'commandStack', 'resizeHandles' ];