Skip to content

Commit e25e706

Browse files
authored
1 parent f773d83 commit e25e706

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres (more or less) to [Semantic Versioning](http://semver.o
77

88
## Unreleased
99

10+
### 0.17,1
11+
12+
### Added
13+
14+
* pass canvasTimeStart/End via timelineContext to the itemRenderer prop
15+
1016
### 0.17.0
1117

1218
### Breaking

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,10 @@ This component will also be passed a `timelineContext` object:
458458

459459
```typescript
460460
{
461-
visibleTimeStart: number, // denotes the start time in ms of the timeline
462-
visibleTimeEnd: number, // denotes the end time in ms of the timeline
461+
visibleTimeStart: number, // denotes the start time in ms of the visible timeline
462+
visibleTimeEnd: number, // denotes the end time in ms of the visible timeline
463+
canvasTimeStart: number, // denotes the start time in ms of the canvas timeline
464+
canvasTimeEnd: number, // denotes the end time in ms of the canvas timeline
463465
timelineWidth: number, // denotes the width in pixels of the timeline
464466
}
465467
```

src/lib/Timeline.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,24 @@ export default class ReactCalendarTimeline extends Component {
251251
}
252252

253253
getTimelineContext = () => {
254-
const { width, visibleTimeStart, visibleTimeEnd } = this.state
254+
const {
255+
width,
256+
visibleTimeStart,
257+
visibleTimeEnd,
258+
canvasTimeStart
259+
} = this.state
260+
const zoom = visibleTimeEnd - visibleTimeStart
261+
const canvasTimeEnd = canvasTimeStart + zoom * 3
255262

256263
//TODO: Performance
257264
//prob wanna memoize this so we ensure that if no items changed,
258265
//we return same context reference
259266
return {
260267
timelineWidth: width,
261268
visibleTimeStart,
262-
visibleTimeEnd
269+
visibleTimeEnd,
270+
canvasTimeStart,
271+
canvasTimeEnd
263272
}
264273
}
265274

0 commit comments

Comments
 (0)