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:
+4
-3
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user