2
0
mirror of https://github.com/tenrok/vue-ganttastic.git synced 2026-06-20 06:20:33 +03:00

fix: the position of new bar

This commit is contained in:
yicone
2021-02-23 14:59:48 +08:00
parent 6152b08088
commit e17b44a506
+4 -3
View File
@@ -130,14 +130,15 @@ export default {
onDoubleClick(e) {
let barContainer = this.$refs.barContainer.getBoundingClientRect()
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(
timeDiffFromStart,
this.timeUnit
)
let bar = {}
bar[this.barStart] = time
bar[this.barEnd] = time.add(this.getDefaultBarLength(), this.timeUnit)
bar[this.ganttChartProps.barStartKey] = time.format()
bar[this.ganttChartProps.barEndKey] = time.add(this.getDefaultBarLength(), this.timeUnit).format()
bar.ganttBarConfig = { handles: true }
this.bars.push(bar)