Skip to content

Commit 1b29e99

Browse files
committed
feat(timeline): display 1ms grid near max zoom
1 parent 3d7d8a3 commit 1b29e99

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

packages/app-frontend/src/features/timeline/TimelineView.vue

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { dimColor, boostColor } from '@front/util/color'
2929
3030
const LAYER_SIZE = 16
3131
const GROUP_SIZE = 6
32+
const MIN_CAMERA_SIZE = 10
3233
3334
installUnsafeEval(PIXI)
3435
@@ -733,13 +734,20 @@ export default defineComponent({
733734
function drawTimeGrid () {
734735
if (!timeGrid.visible || !app.view.width) return
735736
736-
const ratio = (endTime.value - startTime.value) / app.view.width
737+
const size = endTime.value - startTime.value
738+
const ratio = size / app.view.width
737739
let timeInterval = 10
738740
let width = timeInterval / ratio
739741
740-
while (width < 20) {
741-
timeInterval *= 10
742-
width *= 10
742+
if (size <= MIN_CAMERA_SIZE * 3) {
743+
// Every ms
744+
timeInterval = 1
745+
width = timeInterval / ratio
746+
} else {
747+
while (width < 20) {
748+
timeInterval *= 10
749+
width *= 10
750+
}
743751
}
744752
745753
const offset = startTime.value % timeInterval / ratio
@@ -798,8 +806,8 @@ export default defineComponent({
798806
const center = size * centerRatio + startTime.value
799807
800808
let newSize = size + event.deltaY / viewWidth * size * 2
801-
if (newSize < 10) {
802-
newSize = 10
809+
if (newSize < MIN_CAMERA_SIZE) {
810+
newSize = MIN_CAMERA_SIZE
803811
}
804812
805813
let start = center - newSize * centerRatio

0 commit comments

Comments
 (0)