+28
-0
@@ -569,2 +569,5 @@ import { h } from "../h"; | ||
| event.preventDefault(); | ||
| const old_time = this.getTimeByPx(this.x); | ||
| this.zoomLevel -= event.deltaY * 0.001; | ||
@@ -576,2 +579,8 @@ | ||
| this.isSelecting = false; | ||
| const x = this.getPxByTime(old_time); | ||
| this.offset -= x - this.x; | ||
| this.x = x; | ||
| console.log(x, this.x, this.offset); | ||
| this.drawTimeline(); | ||
@@ -625,2 +634,7 @@ } | ||
| } | ||
| /** | ||
| * 像素点转时间点 | ||
| * @param x | ||
| * @returns | ||
| */ | ||
| private getTimeByPx(x) { | ||
@@ -636,4 +650,18 @@ let timelineWidth = this.timeline.clientWidth * this.zoomLevel; | ||
| } | ||
| /** | ||
| * 时间点转像素点 | ||
| * @param date | ||
| * @returns | ||
| */ | ||
| private getPxByTime(date: Date) { | ||
| let timelineWidth = this.timeline.clientWidth * this.zoomLevel; | ||
| let range = this.endDate.getTime() - this.startDate.getTime(); | ||
| let pixelsPerMs = timelineWidth / range; | ||
| let offsetTime = date.getTime() - this.startDate.getTime(); | ||
| let x = offsetTime * pixelsPerMs + this.lineOptions.textWidth!; | ||
| return x; | ||
| } | ||
| } | ||
| export default Timeline; |
+1
-1
| { | ||
| "name": "glibline", | ||
| "version": "0.0.6", | ||
| "version": "0.0.7", | ||
| "description": "时间轴(timeline),用于实现根据时间对数据事件操作。", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
-10
| @echo off | ||
| REM 设置npm版本补丁 | ||
| npm version patch | ||
| REM 发布到npm | ||
| npm publish | ||
| REM 等待用户输入 | ||
| echo 完成发布。按任意键退出... | ||
| pause >nul |
32787
1.77%861
2.74%15
-6.25%