scroll board by dragging
Signed-off-by: Simon Hötten <s+git@hoetten.org>
This commit is contained in:
@@ -54,7 +54,11 @@
|
|||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
</NcEmptyContent>
|
</NcEmptyContent>
|
||||||
<div v-else-if="!isEmpty && !loading" key="board" class="board">
|
<div v-else-if="!isEmpty && !loading"
|
||||||
|
key="board"
|
||||||
|
ref="board"
|
||||||
|
class="board"
|
||||||
|
@mousedown="onMouseDown">
|
||||||
<Container lock-axix="y"
|
<Container lock-axix="y"
|
||||||
orientation="horizontal"
|
orientation="horizontal"
|
||||||
:drag-handle-selector="dragHandleSelector"
|
:drag-handle-selector="dragHandleSelector"
|
||||||
@@ -65,6 +69,7 @@
|
|||||||
<Draggable v-for="stack in stacksByBoard"
|
<Draggable v-for="stack in stacksByBoard"
|
||||||
:key="stack.id"
|
:key="stack.id"
|
||||||
data-click-closes-sidebar="true"
|
data-click-closes-sidebar="true"
|
||||||
|
data-dragscroll-enabled
|
||||||
class="stack-draggable-wrapper">
|
class="stack-draggable-wrapper">
|
||||||
<Stack :stack="stack" :dragging="draggingStack" data-click-closes-sidebar="true" />
|
<Stack :stack="stack" :dragging="draggingStack" data-click-closes-sidebar="true" />
|
||||||
</Draggable>
|
</Draggable>
|
||||||
@@ -117,6 +122,8 @@ export default {
|
|||||||
draggingStack: false,
|
draggingStack: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
newStackTitle: '',
|
newStackTitle: '',
|
||||||
|
currentScrollPosX: null,
|
||||||
|
currentMousePosX: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -184,12 +191,40 @@ export default {
|
|||||||
this.$store.dispatch('createStack', newStack)
|
this.$store.dispatch('createStack', newStack)
|
||||||
this.newStackTitle = ''
|
this.newStackTitle = ''
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onMouseDown(event) {
|
||||||
|
this.startMouseDrag(event)
|
||||||
|
},
|
||||||
|
|
||||||
|
startMouseDrag(event) {
|
||||||
|
if (!('dragscrollEnabled' in event.target.dataset)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault()
|
||||||
|
this.currentMousePosX = event.clientX
|
||||||
|
this.currentScrollPosX = this.$refs.board.scrollLeft
|
||||||
|
window.addEventListener('mousemove', this.handleMouseDrag)
|
||||||
|
window.addEventListener('mouseup', this.stopMouseDrag)
|
||||||
|
window.addEventListener('mouseleave', this.stopMouseDrag)
|
||||||
|
},
|
||||||
|
|
||||||
|
handleMouseDrag(event) {
|
||||||
|
event.preventDefault()
|
||||||
|
const deltaX = event.clientX - this.currentMousePosX
|
||||||
|
this.$refs.board.scrollLeft = this.currentScrollPosX - deltaX
|
||||||
|
},
|
||||||
|
|
||||||
|
stopMouseDrag(event) {
|
||||||
|
window.removeEventListener('mousemove', this.handleMouseDrag)
|
||||||
|
window.removeEventListener('mouseup', this.stopMouseDrag)
|
||||||
|
window.removeEventListener('mouseleave', this.stopMouseDrag)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
@import '../../css/animations';
|
@import '../../css/animations';
|
||||||
@import '../../css/variables';
|
@import '../../css/variables';
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,7 @@
|
|||||||
data-click-closes-sidebar="true"
|
data-click-closes-sidebar="true"
|
||||||
non-drag-area-selector=".dragDisabled"
|
non-drag-area-selector=".dragDisabled"
|
||||||
:drag-handle-selector="dragHandleSelector"
|
:drag-handle-selector="dragHandleSelector"
|
||||||
|
data-dragscroll-enabled
|
||||||
@should-accept-drop="canEdit"
|
@should-accept-drop="canEdit"
|
||||||
@drag-start="draggingCard = true"
|
@drag-start="draggingCard = true"
|
||||||
@drag-end="draggingCard = false"
|
@drag-end="draggingCard = false"
|
||||||
|
|||||||
Reference in New Issue
Block a user