You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be able to deselect a single element on click or touch. This is my current config:
this.selection = new SelectionArea({
class: "selection-area",
container: 'body',
overlap: 'keep',
singleTap: {
// Enable single-click selection (Also disables range-selection via shift + ctrl).
allow: true,
// 'native' (element was mouse-event target) or 'touch' (element visually touched).
intersect: 'touch'
},
selectables: "[data-box-id='" + self.box.id + "']",
startareas: [`.cell-matrix-${self.box.id}`],
boundaries: [`.cell-matrix-${self.box.id}`]
})
.on("start", ({ event: evt, store: { changed: { added, removed } } }) => {
if (!(added.length || removed.length) && evt.type == 'mouseup') {
// TODO: same thing for touch
if (this.selection.getSelection().includes(evt.target)) {
console.debug('Deselecting cell ', evt.target)
this.selection.deselect(evt.target, true)
this.selection.resolveSelectables()
}
}
})
.on("move", ({ store: { changed: { added, removed } } }) => {
// Add a custom class to the elements that were selected.
for (const el of added) {
el.classList.add("selected");
// this.selectedCells.push(this.convertMatrixIndexToArrayIndex(el.dataset.index))
// this.selectedCells = uniq(this.selectedCells)
}
// Remove the class from elements that where removed
// since the last selection
for (const el of removed) {
el.classList.remove("selected");
}
})
.on("stop", () => {
this.selection.keepSelection();
console.debug(this.selection.getSelection())
})
(I'm using this inside a Vue.js created function, hence the this.selection.)
The element is added on click, but it is not removed from .getSelection() when clicking on it again (although the "Deselecting cell" message appears in my console log).
The text was updated successfully, but these errors were encountered:
I see what's happening, this is indeed an issue but please stick to the Issue Template the next time. Create a JSFiddle and describe what you've done as detailed as possible and break your issue down to a minimum. This will help me to resolve it as fast as possible. The next time your issue will be closed without further notice.
I'm using 2.0.0beta4
I would like to be able to deselect a single element on click or touch. This is my current config:
(I'm using this inside a Vue.js
created
function, hence thethis.selection
.)The element is added on click, but it is not removed from .getSelection() when clicking on it again (although the "Deselecting cell" message appears in my console log).
The text was updated successfully, but these errors were encountered: