Skip to content

Commit c739d1c

Browse files
committed
docs(Timeline): update the documentation
1 parent 6090a46 commit c739d1c

File tree

3 files changed

+103
-10
lines changed

3 files changed

+103
-10
lines changed

docs/Timeline.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const timeline = new Timeline({
2121
axes?: AxesViewOptions;
2222
events?: EventsViewOptions;
2323
markers?: MarkerViewOptions;
24+
camera?: CameraViewOptions;
2425
hideRuler?: boolean;
2526
}
2627
});
@@ -73,6 +74,7 @@ const timeline = new Timeline({
7374
axes?: AxesViewOptions;
7475
events?: EventsViewOptions;
7576
markers?: MarkerViewOptions;
77+
camera?: CameraViewOptions;
7678
hideRuler?: boolean;
7779
};
7880
};
@@ -152,6 +154,28 @@ timeline.emit('eventClick', { eventId: '123', time: Date.now() });
152154
**Returns:**
153155
- The created CustomEvent instance
154156

157+
## Configuration Options
158+
159+
### Camera Configuration
160+
161+
The `camera` configuration controls timeline interaction behaviors, particularly zooming and panning:
162+
163+
```typescript
164+
viewConfiguration: {
165+
camera: {
166+
zoom: ZoomMode.DEFAULT // or ZoomMode.NONE or ZoomMode.HORIZONTAL
167+
}
168+
}
169+
```
170+
171+
**Zoom Modes:**
172+
173+
| Mode | Value | Behavior |
174+
|------|-------|----------|
175+
| `DEFAULT` | `"default"` | Standard zoom and pan behavior (mouse wheel zooms, Shift+wheel pans vertically) |
176+
| `HORIZONTAL` | `"horizontal"` | Mouse wheel pans horizontally without requiring Shift key |
177+
| `NONE` | `"none"` | Disables all zoom and pan interactions |
178+
155179
## Events
156180

157181
The timeline emits the following events:
@@ -210,7 +234,7 @@ Fired when mouse leaves timeline elements.
210234
### Basic Timeline Setup
211235

212236
```typescript
213-
import { Timeline } from '@gravity-ui/timeline';
237+
import { Timeline, ZoomMode } from '@gravity-ui/timeline';
214238

215239
// Create timeline instance
216240
const timeline = new Timeline({
@@ -231,6 +255,11 @@ const timeline = new Timeline({
231255
axisId: 'main',
232256
trackIndex: 0
233257
}]
258+
},
259+
viewConfiguration: {
260+
camera: {
261+
zoom: ZoomMode.DEFAULT
262+
}
234263
}
235264
});
236265

docs/TimelineController.md

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,38 @@ The TimelineController provides the following interaction capabilities:
6060

6161
### Zoom
6262

63-
- **Mouse Wheel**: Zoom in/out centered on cursor position
64-
- **Zoom Limits**:
65-
- Minimum zoom: 5 seconds
66-
- Maximum zoom: 2 months
67-
- **Zoom Speed**: Controlled by wheel delta
63+
The zoom behavior is controlled by the camera configuration's zoom mode:
64+
65+
- **DEFAULT Mode**:
66+
- **Mouse Wheel**: Zoom in/out centered on cursor position
67+
- **Zoom Limits**:
68+
- Minimum zoom: 5 seconds
69+
- Maximum zoom: 2 months
70+
- **Zoom Speed**: Controlled by wheel delta
71+
72+
- **HORIZONTAL Mode**:
73+
- **Mouse Wheel**: Horizontal panning instead of zooming
74+
- **No Zoom**: Zoom functionality is disabled in this mode
75+
76+
- **NONE Mode**:
77+
- **Disabled**: All zoom and pan interactions are disabled
6878

6979
### Pan
7080

71-
- **Shift + Wheel**: Vertical panning
72-
- **Wheel Delta X**: Horizontal panning
73-
- **Pan Speed**: Controlled by `WHEEL_PAN_SPEED` constant (0.00025)
81+
The pan behavior also depends on the zoom mode:
82+
83+
- **DEFAULT Mode**:
84+
- **Shift + Wheel**: Vertical panning
85+
- **Wheel Delta X**: Horizontal panning
86+
- **Pan Speed**: Controlled by `WHEEL_PAN_SPEED` constant (0.00025)
87+
88+
- **HORIZONTAL Mode**:
89+
- **Mouse Wheel**: Horizontal panning (no Shift key required)
90+
- **Wheel Delta X**: Horizontal panning
91+
- **Pan Speed**: Controlled by `WHEEL_PAN_SPEED` constant (0.00025)
92+
93+
- **NONE Mode**:
94+
- **Disabled**: All panning interactions are disabled
7495

7596
### Canvas Resizing
7697

@@ -109,6 +130,44 @@ if (canvas instanceof HTMLCanvasElement) {
109130
timeline.destroy(); // This will also destroy the TimelineController
110131
```
111132

133+
### Configuring Interaction Modes
134+
135+
You can control zoom and pan behavior by setting the camera configuration:
136+
137+
```typescript
138+
import { Timeline, ZoomMode } from '@gravity-ui/timeline';
139+
140+
// Default zoom behavior
141+
const timelineDefault = new Timeline({
142+
settings: { /* settings */ },
143+
viewConfiguration: {
144+
camera: {
145+
zoom: ZoomMode.DEFAULT
146+
}
147+
}
148+
});
149+
150+
// Horizontal pan only (no zoom)
151+
const timelineHorizontal = new Timeline({
152+
settings: { /* settings */ },
153+
viewConfiguration: {
154+
camera: {
155+
zoom: ZoomMode.HORIZONTAL
156+
}
157+
}
158+
});
159+
160+
// Disable all interactions
161+
const timelineStatic = new Timeline({
162+
settings: { /* settings */ },
163+
viewConfiguration: {
164+
camera: {
165+
zoom: ZoomMode.NONE
166+
}
167+
}
168+
});
169+
```
170+
112171
### Custom Interaction Handling
113172

114173
While the TimelineController handles basic interactions automatically, you can extend its functionality by listening to timeline events:

docs/docs.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ The library consists of several core components that work together to create the
1414
The main class that orchestrates the timeline visualization. It manages the canvas, components, and user interactions.
1515

1616
```typescript
17-
import { Timeline } from '@gravity-ui/timeline';
17+
import { Timeline, ZoomMode } from '@gravity-ui/timeline';
1818

1919
const timeline = new Timeline({
2020
settings: {
2121
start: Date.now(),
2222
end: Date.now() + 3600000,
2323
axes: [],
2424
events: []
25+
},
26+
viewConfiguration: {
27+
camera: {
28+
zoom: ZoomMode.DEFAULT
29+
}
2530
}
2631
});
2732
```

0 commit comments

Comments
 (0)