@kteneyck/cesium-timeline-react 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/dist/cesium-timeline-react.js +833 -796
- package/dist/cesium-timeline-react.umd.cjs +4 -4
- package/dist/index.d.ts +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -133,6 +133,7 @@ Angular components use standalone imports — no NgModule required. Selectors: `
|
|
|
133
133
|
- **Clickable datetime** — pass `onDateTimeClick` to open your own date picker; pass the result back via `jumpToTime` to pan the canvas and set the time.
|
|
134
134
|
- **Token-based datetime format** — built-in presets plus custom format strings with 17 supported tokens.
|
|
135
135
|
- **Max tick limit** — `maxTicks` prop prevents the canvas from becoming overloaded at wide zoom levels by coarsening the tick scale automatically.
|
|
136
|
+
- **Zoom to selection** — drag in the tick area (away from the needle) to draw a time-range highlight with a crosshair cursor; on release the visible window zooms to exactly the selected span and fires `onRangeSelect` (React) / `rangeSelect` (Angular) with the resulting start and end times.
|
|
136
137
|
- **Swim lanes** — display time intervals and instants as horizontal rows inside the canvas. Supports customizable styling, click/hover/double-click event hooks, drag-to-reorder, and vertical scrolling when lanes overflow.
|
|
137
138
|
- **Fully themeable** — 16 theme properties cover every color, size, and font setting, including swim lane item border defaults.
|
|
138
139
|
- **Localizable labels** — every control-bar label and tooltip is overridable via the `labels` prop; dynamic tooltips accept a `(multiplier: number) => string` callback. See [Labels & i18n](#labels--i18n).
|
|
@@ -174,6 +175,7 @@ Angular components use standalone imports — no NgModule required. Selectors: `
|
|
|
174
175
|
| `onSwimLaneItemHover` | `(info: SwimLaneEventInfo \| null) => void` | — | Fires when mouse enters/leaves a swim lane item |
|
|
175
176
|
| `onSwimLaneItemDoubleClick` | `(info: SwimLaneEventInfo) => void` | — | Fires when a swim lane item is double-clicked |
|
|
176
177
|
| `onSwimLaneReorder` | `(orderedIds: string[]) => void` | — | Fires when swim lanes are reordered via drag. Receives the new lane id order. |
|
|
178
|
+
| `onRangeSelect` | `(start: JulianDate, end: JulianDate) => void` | — | Fires when the user completes a click-and-drag in the tick area. The visible window zooms to the selected span; receives the resulting start and end times. |
|
|
177
179
|
| `labels` | `Partial<TimelineLabels>` | English defaults | Override any control-bar label or tooltip string. See [Labels & i18n](#labels--i18n). |
|
|
178
180
|
|
|
179
181
|
---
|
|
@@ -596,6 +598,12 @@ const CesiumWithTimeline = () => {
|
|
|
596
598
|
onTimeChange={(t) => { clock.currentTime = t; }}
|
|
597
599
|
onPlayPause={(playing) => { clock.shouldAnimate = playing; }}
|
|
598
600
|
onMultiplierChange={(m) => { clock.multiplier = m; }}
|
|
601
|
+
onRangeSelect={(start, end) => {
|
|
602
|
+
// Zoom the Cesium clock range to match the selected span
|
|
603
|
+
clock.startTime = start;
|
|
604
|
+
clock.stopTime = end;
|
|
605
|
+
clock.currentTime = start;
|
|
606
|
+
}}
|
|
599
607
|
/>
|
|
600
608
|
)}
|
|
601
609
|
</div>
|
|
@@ -695,6 +703,60 @@ const StandaloneTimeline = () => {
|
|
|
695
703
|
};
|
|
696
704
|
```
|
|
697
705
|
|
|
706
|
+
### Zoom to Selection
|
|
707
|
+
|
|
708
|
+
Click-and-drag in the tick area (the bottom strip, away from the needle) to draw a time-range highlight. The cursor becomes a crosshair while dragging. On mouse-up the **visible window zooms to exactly the selected span** and `onRangeSelect` fires with the start and end `JulianDate`.
|
|
709
|
+
|
|
710
|
+
A short click (no drag) in the tick area still moves the needle normally.
|
|
711
|
+
|
|
712
|
+
```tsx
|
|
713
|
+
import { useState } from 'react';
|
|
714
|
+
import * as Cesium from 'cesium';
|
|
715
|
+
import { Timeline } from '@kteneyck/cesium-timeline-react';
|
|
716
|
+
|
|
717
|
+
const ZoomableTimeline = () => {
|
|
718
|
+
const [selectedRange, setSelectedRange] = useState<{ start: Date; end: Date } | null>(null);
|
|
719
|
+
|
|
720
|
+
return (
|
|
721
|
+
<>
|
|
722
|
+
{selectedRange && (
|
|
723
|
+
<p>
|
|
724
|
+
Selected: {selectedRange.start.toISOString()} → {selectedRange.end.toISOString()}
|
|
725
|
+
</p>
|
|
726
|
+
)}
|
|
727
|
+
<Timeline
|
|
728
|
+
clock={viewer.clock}
|
|
729
|
+
height={120}
|
|
730
|
+
onRangeSelect={(start, end) => {
|
|
731
|
+
setSelectedRange({
|
|
732
|
+
start: Cesium.JulianDate.toDate(start),
|
|
733
|
+
end: Cesium.JulianDate.toDate(end),
|
|
734
|
+
});
|
|
735
|
+
}}
|
|
736
|
+
/>
|
|
737
|
+
</>
|
|
738
|
+
);
|
|
739
|
+
};
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
In Angular, listen to the `(rangeSelect)` output — the event payload is `{ start: Cesium.JulianDate, end: Cesium.JulianDate }`:
|
|
743
|
+
|
|
744
|
+
```html
|
|
745
|
+
<ct-timeline
|
|
746
|
+
[clock]="viewer.clock"
|
|
747
|
+
[height]="120"
|
|
748
|
+
(rangeSelect)="onRangeSelect($event)"
|
|
749
|
+
/>
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
```typescript
|
|
753
|
+
onRangeSelect(range: { start: Cesium.JulianDate; end: Cesium.JulianDate }) {
|
|
754
|
+
this.viewer.clock.startTime = range.start;
|
|
755
|
+
this.viewer.clock.stopTime = range.end;
|
|
756
|
+
this.viewer.clock.currentTime = range.start;
|
|
757
|
+
}
|
|
758
|
+
```
|
|
759
|
+
|
|
698
760
|
---
|
|
699
761
|
|
|
700
762
|
## Swim Lanes
|