editor: add lasso selection (WIP)

This commit is contained in:
jean-emmanuel 2018-10-10 17:54:03 +02:00
parent 46a2ed387e
commit b43c13079f
5 changed files with 54 additions and 8 deletions

View file

@ -12,6 +12,8 @@
- added keyboard shortcut `mod + s` for saving the session
- use `backspace` instead of `delete` for deleting widgets on MacOs
- added keyboard shortcut `mod + e` for enabling / disabling the editor
- added keyboard shortcuts `mod + arrows` for selecting widgets
- added multi widget selection with mouse
## 0.37.4

View file

@ -234,6 +234,30 @@ var Editor = class Editor {
document.body.addEventListener('mousemove', this.mouveMoveHandler)
var tmpSelection = []
$('#container').selectable({
filter: '.widget:not(.not-editable)',
appendTo: '#container',
autoRefresh: false,
tolerance: 'touch',
distance:1,
start: ()=>{
tmpSelection = []
},
selected: (ev, ui)=>{
var widget = widgetManager.getWidgetByElement(ui.selected)
if (widget) tmpSelection.unshift(widget)
},
stop: ()=>{
for (var i in tmpSelection) {
this.select(tmpSelection[i], {multi:true, fromLasso:true})
}
this.select(this.selectedWidgets)
}
})
}
disable() {
@ -262,6 +286,8 @@ var Editor = class Editor {
document.body.removeEventListener('mousemove', this.mouveMoveHandler)
$('#container').selectable('destroy')
}
unselect() {
@ -304,7 +330,7 @@ var Editor = class Editor {
this.selectedWidgets.push(widget)
} else if (sameLevel){
} else if (sameLevel && !options.fromLasso){
this.selectedWidgets.splice(this.selectedWidgets.indexOf(widget), 1)
@ -319,13 +345,15 @@ var Editor = class Editor {
}
if (this.selectedWidgets.length > 0) {
if (this.selectedWidgets.length > 0 && !options.fromLasso) {
this.createEditForm()
this.createSelectionBlock()
}
$('#container').selectable('refresh')
}

View file

@ -30,7 +30,7 @@ function touchToFastClick(event) {
DOM.dispatchEvent(e.target, 'fast-click', e)
if (e.preventDefault) event.preventDefault()
if (e.preventOriginalEvent) event.preventDefault()
longTouchTimer = setTimeout(()=>{

File diff suppressed because one or more lines are too long

View file

@ -512,3 +512,19 @@
.editor-help-title {
text-transform: none;
}
// selectable
.ui-selectable-helper {
position:absolute;
z-index:999999;
border: 1rem solid var(--color-accent);
&:after {
content:"";
position: absolute;
top:0;left:0;
right:0;bottom:0;
background: var(--color-accent);
opacity: 0.2;
}
}