From 6c4ab268b546fed6c96527be95dfad92d2191750 Mon Sep 17 00:00:00 2001 From: Sergey Solodyagin Date: Thu, 7 Oct 2021 16:48:54 +0300 Subject: [PATCH] feat: scrolling --- src/GGanttBar.vue | 7 ++++++- src/GGanttChart.vue | 31 +++++++++++++++++-------------- src/GGanttGrid.vue | 8 ++++---- src/GGanttRow.vue | 11 ++++++++--- src/GGanttTimeaxis.vue | 42 ++++++++++++++++++++++++------------------ src/Playground.vue | 12 ++++++------ 6 files changed, 65 insertions(+), 46 deletions(-) diff --git a/src/GGanttBar.vue b/src/GGanttBar.vue index 395bf2a..3c7c74f 100644 --- a/src/GGanttBar.vue +++ b/src/GGanttBar.vue @@ -273,8 +273,13 @@ export default { }, drag(e) { + const chart = document.querySelector('#g-gantt-chart') let barWidth = this.$refs['g-gantt-bar'].getBoundingClientRect().width - let newXStart = e.clientX - this.barContainer.left - this.cursorOffsetX + let newXStart = + chart.scrollLeft + + e.clientX - + this.barContainer.left - + this.cursorOffsetX let newXEnd = newXStart + barWidth if (this.isPosOutOfDragRange(newXStart, newXEnd)) { return diff --git a/src/GGanttChart.vue b/src/GGanttChart.vue index 00bb0a5..7ea7d1c 100644 --- a/src/GGanttChart.vue +++ b/src/GGanttChart.vue @@ -21,7 +21,14 @@ :highlighted-hours="highlightedHours" /> -
+
@@ -48,7 +55,7 @@ export default { chartStart: { type: String }, chartEnd: { type: String }, hideTimeaxis: Boolean, - rowLabelWidth: { type: String, default: '10%' }, + rowLabelWidth: { type: String, default: '200px' }, rowHeight: { type: Number, default: 40 }, locale: { type: String, default: 'en' }, theme: { type: String }, @@ -188,7 +195,7 @@ export default { let movedBars = didSnapBack ? new Set() : this.movedBarsInDrag // Magnetic suction if (movedBars.size && this.isMagnetic) { - let { left, right/*, move*/ } = action + let { left, right /*, move*/ } = action movedBars.forEach((bar) => { if (this.timeaxisMode === 'month_days') { @@ -286,10 +293,8 @@ export default { return } for (let side of ['left', 'right']) { - let [ - totalGapDistance, - bundleBarsOnPath, - ] = this.countGapDistanceToNextImmobileBar(bar, null, side, false) + let [totalGapDistance, bundleBarsOnPath] = + this.countGapDistanceToNextImmobileBar(bar, null, side, false) for (let i = 0; i < bundleBarsOnPath.length; i++) { let barFromBundle = bundleBarsOnPath[i].bar let gapDist = bundleBarsOnPath[i].gapDistance @@ -297,10 +302,8 @@ export default { barFromBundle.barConfig.bundle ).filter((otherBar) => otherBar !== barFromBundle) otherBarsFromBundle.forEach((otherBar) => { - let [ - newGapDistance, - newBundleBars, - ] = this.countGapDistanceToNextImmobileBar(otherBar, gapDist, side) + let [newGapDistance, newBundleBars] = + this.countGapDistanceToNextImmobileBar(otherBar, gapDist, side) if ( newGapDistance !== null && (newGapDistance < totalGapDistance || !totalGapDistance) @@ -479,9 +482,9 @@ export default { \ No newline at end of file diff --git a/src/GGanttTimeaxis.vue b/src/GGanttTimeaxis.vue index b058bf9..313900f 100644 --- a/src/GGanttTimeaxis.vue +++ b/src/GGanttTimeaxis.vue @@ -1,25 +1,28 @@