mirror of
https://github.com/tenrok/vue-ganttastic.git
synced 2026-06-24 00:40:34 +03:00
fix: the position of new bar
This commit is contained in:
+4
-3
@@ -130,14 +130,15 @@ export default {
|
|||||||
onDoubleClick(e) {
|
onDoubleClick(e) {
|
||||||
let barContainer = this.$refs.barContainer.getBoundingClientRect()
|
let barContainer = this.$refs.barContainer.getBoundingClientRect()
|
||||||
let xPos = e.clientX - barContainer.left
|
let xPos = e.clientX - barContainer.left
|
||||||
let timeDiffFromStart = (xPos / barContainer.width) * this.getTimeCount()
|
let timeDiffFromStart =
|
||||||
|
Math.round(xPos / barContainer.width * this.getTimeCount())
|
||||||
let time = moment(this.getChartStart()).add(
|
let time = moment(this.getChartStart()).add(
|
||||||
timeDiffFromStart,
|
timeDiffFromStart,
|
||||||
this.timeUnit
|
this.timeUnit
|
||||||
)
|
)
|
||||||
let bar = {}
|
let bar = {}
|
||||||
bar[this.barStart] = time
|
bar[this.ganttChartProps.barStartKey] = time.format()
|
||||||
bar[this.barEnd] = time.add(this.getDefaultBarLength(), this.timeUnit)
|
bar[this.ganttChartProps.barEndKey] = time.add(this.getDefaultBarLength(), this.timeUnit).format()
|
||||||
|
|
||||||
bar.ganttBarConfig = { handles: true }
|
bar.ganttBarConfig = { handles: true }
|
||||||
this.bars.push(bar)
|
this.bars.push(bar)
|
||||||
|
|||||||
Reference in New Issue
Block a user