complex-data
Advanced tools
+4
-0
@@ -24,2 +24,6 @@ | ||
| ### 4.9.3 | ||
| - feat:TrackData添加pushData方法 | ||
| - fix:修正TrackData.$setIndex在未传递currentIndex时,在结束时错误将this.$index.next.data设置为溢出index的BUG | ||
| ### 4.9.2 | ||
@@ -26,0 +30,0 @@ - feat:优化TrackData轨迹数据 |
+1
-1
| { | ||
| "name": "complex-data", | ||
| "version": "4.9.2", | ||
| "version": "4.9.3", | ||
| "description": "a complex data", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+39
-30
@@ -199,14 +199,24 @@ import { getNum } from "complex-utils" | ||
| } | ||
| // pushData(value: VALUE, target: 'last' | 'create' = 'last') { | ||
| // if (this.hasPoint(value)) { | ||
| // this.data.list.push(value) | ||
| // this.data.lnglat.push(this.createLnglat(value)) | ||
| // const lastSize = this.data.dict[this.data.dict.length - 1] | ||
| // if (target === 'last') { | ||
| // this.data.dict[this.data.dict.length - 1] = lastSize + 1 | ||
| // } else { | ||
| // this.data.dict.push(lastSize + 1) | ||
| // } | ||
| // } | ||
| // } | ||
| pushData(value: VALUE, target: 'last' | 'create' = 'last') { | ||
| if (this.hasPoint(value)) { | ||
| this.data.list.push(value) | ||
| this.data.lnglat.push(this.createLnglat(value)) | ||
| const lastSize = this.data.dict[this.data.dict.length - 1] | ||
| if (target === 'last') { | ||
| this.data.dict[this.data.dict.length - 1] = lastSize + 1 | ||
| if (this.$map) { | ||
| const lineList = this.getLineList(this.data.dict.length - 1, lastSize + 1) | ||
| const lastLine = this.$marker.line.data[this.$marker.line.data.length - 1] | ||
| this.moveLine('forward', lastLine, lineList) | ||
| } | ||
| } else { | ||
| this.data.dict.push(lastSize + 1) | ||
| if (this.$map) { | ||
| const lineList = this.getLineList(this.data.dict.length - 1, lastSize + 1) | ||
| const line = this.createLine('total', this.$map, lineList) | ||
| this.$marker.line.data.push(line) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| resetData() { | ||
@@ -412,2 +422,15 @@ this.status.data = false | ||
| } | ||
| protected _setIndex(currentIndex: number, currentLine?: number) { | ||
| this.$index.current.data = currentIndex | ||
| this.$index.current.line = currentLine !== undefined ? currentLine : this._getLineIndex(currentIndex) | ||
| if (!this.$isEnd(currentIndex)) { | ||
| this.$index.next.data = currentIndex + 1 | ||
| this.$index.next.line = this._getLineIndex(this.$index.next.data) | ||
| } else if (currentLine !== undefined) { | ||
| // 结束状态 存在currentLine时不需要进行赋值,因为currentLine的来源就是next的值 | ||
| this.$index.next.data = currentIndex | ||
| this.$index.next.line = this.$index.current.line | ||
| } | ||
| return currentIndex | ||
| } | ||
| protected $setIndex(currentIndex?: number) { | ||
@@ -418,24 +441,10 @@ const lastIndex = this.$index.current.data | ||
| // 未传递时直接获取下一步数据 | ||
| this.$index.current.data = this.$index.next.data | ||
| this.$index.current.line = this.$index.next.line | ||
| this.$index.next.data = this.$index.current.data + 1 | ||
| this.$index.next.line = this._getLineIndex(this.$index.next.data) | ||
| currentIndex = this.$index.current.data | ||
| } else if (this.$isEnd(currentIndex)) { | ||
| // 当前index值超过或为结束值时,直接进行结束赋值操作 | ||
| currentIndex = this.data.maxIndex | ||
| this.$index.current.data = currentIndex | ||
| this.$index.current.line = this._getLineIndex(currentIndex) | ||
| // 结束后的下一个点同最后点避免BUG | ||
| this.$index.next.data = currentIndex | ||
| this.$index.next.line = this.$index.current.line | ||
| currentIndex = this._setIndex(this.$index.next.data, this.$index.next.line) | ||
| } else { | ||
| if (currentIndex < 0) { | ||
| currentIndex = 0 | ||
| } else if (this.$isEnd(currentIndex)) { | ||
| currentIndex = this.data.maxIndex | ||
| } | ||
| // 存在index且未结束时 | ||
| this.$index.current.data = currentIndex | ||
| this.$index.current.line = this._getLineIndex(this.$index.current.data) | ||
| this.$index.next.data = currentIndex + 1 | ||
| this.$index.next.line = this._getLineIndex(this.$index.next.data) | ||
| currentIndex = this._setIndex(currentIndex) | ||
| } | ||
@@ -442,0 +451,0 @@ this.$onIndexChange(currentIndex, lastIndex, lastLineIndex) |
268833
0.2%6852
0.13%