feat: add single click mode (#1139)

This commit is contained in:
Julien Loir
2020-11-23 19:06:37 +01:00
committed by GitHub
parent 10e399b3c3
commit e8b4e9af46
10 changed files with 40 additions and 15 deletions

View File

@@ -6,8 +6,8 @@
@dragstart="dragStart"
@dragover="dragOver"
@drop="drop"
@click="click"
@dblclick="open"
@click="itemClick"
@dblclick="dblclick"
@touchstart="touchstart"
:data-dir="isDir"
:aria-label="name"
@@ -47,7 +47,7 @@ export default {
},
props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'],
computed: {
...mapState(['selected', 'req', 'user', 'jwt']),
...mapState(['user', 'selected', 'req', 'user', 'jwt']),
...mapGetters(['selectedCount']),
isSelected () {
return (this.selected.indexOf(this.index) !== -1)
@@ -170,8 +170,12 @@ export default {
action(overwrite, rename)
},
itemClick: function(event) {
if (this.user.singleClick && !this.$store.state.multiple) this.open()
else this.click(event)
},
click: function (event) {
if (this.selectedCount !== 0) event.preventDefault()
if (!this.user.singleClick && this.selectedCount !== 0) event.preventDefault()
if (this.$store.state.selected.indexOf(this.index) !== -1) {
this.removeSelected(this.index)
return
@@ -198,9 +202,12 @@ export default {
return
}
if (!event.ctrlKey && !this.$store.state.multiple) this.resetSelected()
if (!this.user.singleClick && !event.ctrlKey && !this.$store.state.multiple) this.resetSelected()
this.addSelected(this.index)
},
dblclick: function () {
if (!this.user.singleClick) this.open()
},
touchstart () {
setTimeout(() => {
this.touches = 0