2
0
mirror of https://github.com/tenrok/vue-ganttastic.git synced 2026-06-24 18:50:34 +03:00

Added new "click-bar" event.

Minor bug fix: if no mousemove event happened between a mousedown and a mouseup, bar would still be dragged
This commit is contained in:
Marko Zunic
2020-05-23 20:15:50 +02:00
parent b29066c177
commit c1be46fd8e
4 changed files with 774 additions and 493 deletions
+755 -485
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "vue-ganttastic", "name": "vue-ganttastic",
"version": "0.9.5", "version": "0.9.6",
"description": "A simple and customizable Gantt chart component for Vue.js", "description": "A simple and customizable Gantt chart component for Vue.js",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -26,11 +26,11 @@
"author": "Marko Zunic", "author": "Marko Zunic",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"bili": "^4.8.1", "bili": "^4.10.0",
"rollup-plugin-vue": "^5.1.6", "rollup-plugin-vue": "^5.1.9",
"vue-template-compiler": "^2.6.11" "vue-template-compiler": "^2.6.11"
}, },
"dependencies": { "dependencies": {
"moment": "^2.24.0" "moment": "^2.26.0"
} }
} }
+14
View File
@@ -7,6 +7,7 @@
@mouseenter.stop="onMouseenter($event)" @mouseenter.stop="onMouseenter($event)"
@mouseleave.stop ="onMouseleave($event)" @mouseleave.stop ="onMouseleave($event)"
@mousedown.stop="onMousedown($event)" @mousedown.stop="onMousedown($event)"
@click.stop="onClick($event)"
@dblclick="onDblclick($event)" @dblclick="onDblclick($event)"
@contextmenu="onContextmenu($event)" @contextmenu="onContextmenu($event)"
> >
@@ -157,6 +158,14 @@ export default {
this.onBarEvent(e, this) this.onBarEvent(e, this)
}, },
onClick(e){
this.onBarEvent(e, this)
},
onDblclick(e) {
this.onBarEvent(e, this)
},
onMousedown(e){ onMousedown(e){
e.preventDefault() e.preventDefault()
if(e.button === 2 || this.barConfig.immobile){ if(e.button === 2 || this.barConfig.immobile){
@@ -165,6 +174,11 @@ export default {
this.setDragLimitsOfGanttBar(this) this.setDragLimitsOfGanttBar(this)
// initialize the dragging on next mousemove event: // initialize the dragging on next mousemove event:
window.addEventListener("mousemove", this.onFirstMousemove, {once: true}) window.addEventListener("mousemove", this.onFirstMousemove, {once: true})
// if next mousemove happens after mouse up (if user just presses mouse button down, then up, without moving):
window.addEventListener("mouseup",
() => window.removeEventListener("mousemove", this.onFirstMousemove),
{once: true}
)
this.onBarEvent(e, this) this.onBarEvent(e, this)
}, },
+1 -4
View File
@@ -6,7 +6,7 @@
:chart-end="chartEnd" :chart-end="chartEnd"
:grid="grid" :grid="grid"
:hide-timeaxis="hideTimeaxis" :hide-timeaxis="hideTimeaxis"
:push-on-overlap="false" :push-on-overlap="true"
snap-back-on-overlap snap-back-on-overlap
:highlighted-hours="highlightedHours" :highlighted-hours="highlightedHours"
:row-label-width="`${rowLabelWidth}%`" :row-label-width="`${rowLabelWidth}%`"
@@ -14,9 +14,6 @@
:theme="selectedTheme" :theme="selectedTheme"
> >
<template v-for="row in rowList"> <template v-for="row in rowList">
<div style="width: 100%; padding: 5px; background: white;" :key="`div${row.label}`">
test
</div>
<g-gantt-row <g-gantt-row
:key="row.label" :key="row.label"
:label="row.label" :label="row.label"