Skip to content

Commit 5a261bf

Browse files
authored
0.26.6 (#671)
0.26.6
2 parents 954b207 + be32100 commit 5a261bf

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

CHANGELOG.md

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

88
## Unreleased
99

10+
## 0.26.6
11+
12+
* fix `visibleTimeStart`, `visibleTimeEnd` and `onTimeChange` not working as expected in controlled mode @ilaiwi
13+
14+
### examples
15+
16+
two new examples
17+
18+
#### Controlled scroll
19+
20+
Controlled visible port of the calendar using `visibleTimeStart` and `visibleTimeEnd`. This also limits scrolling by mouse and adds two buttons to change the visible port of the calendar
21+
22+
[Example Codesandbox](https://codesandbox.io/s/timeline-demo-controlled-visible-time-no-scroll-659jb)
23+
24+
#### Programmatically Scrolling
25+
26+
Using controlled scroll and react-spring to trigger scrolling and create an animation.
27+
28+
[Example Codesandbox](https://codesandbox.io/s/confident-waterfall-3kq2503y8p)
29+
1030
## 0.26.5
1131

1232
* improve performance by:

examples/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,17 @@ Through group manipulation, you can achieve tree group views.
6060

6161
Note that this is the user code manipulating groups to achieve tree group functionality. This example is an illustration of how you can achieve this functionality. This is not a feature that is directly supported by the library.
6262

63+
## Controlled scroll
64+
65+
Controlled visible port of the calendar using `visibleTimeStart` and `visibleTimeEnd`. This also limits scrolling by mouse and adds two buttons to change the visible port of the calendar
66+
67+
[Example Codesandbox](https://codesandbox.io/s/timeline-demo-controlled-visible-time-no-scroll-659jb)
68+
6369
## Programmatically Scrolling
6470

65-
Using `scrollRef` you can trigger scrolling and create an animation. This is an alternative to setting `visibleStartTime` and `visibleEndTime`.
71+
Using controlled scroll and react-spring to trigger scrolling and create an animation.
6672

67-
[Example Codesandbox](https://codesandbox.io/s/3kq2503y8p)
73+
[Example Codesandbox](https://codesandbox.io/s/confident-waterfall-3kq2503y8p)
6874

6975
## Sticky header
7076

@@ -76,4 +82,5 @@ Using `Timeline Header` you can make the header stick to the top of the page whi
7682

7783
Native info label was removed with 0.26.0 and now the responsibility to render to render the Info Label is on the user. The example bellow has InfoLabel that matches exactly the removed label
7884

79-
[Example Codesandbox](https://codesandbox.io/s/timeline-demo-info-label-neec9)
85+
[Example Codesandbox](https://codesandbox.io/s/timeline-demo-info-label-neec9)
86+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-calendar-timeline",
3-
"version": "0.26.5",
3+
"version": "0.26.6",
44
"description": "react calendar timeline",
55
"main": "lib/index.js",
66
"scripts": {

src/lib/Timeline.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export default class ReactCalendarTimeline extends Component {
409409
)
410410
)
411411
}
412-
412+
413413
return derivedState
414414
}
415415

@@ -495,18 +495,6 @@ export default class ReactCalendarTimeline extends Component {
495495

496496
onScroll = scrollX => {
497497
const width = this.state.width
498-
let newScrollX = scrollX
499-
// move the virtual canvas if needed
500-
// if scrollX is less...i dont know how to explain the logic here
501-
if (newScrollX < width * 0.5) {
502-
newScrollX += width
503-
}
504-
if (newScrollX > width * 1.5) {
505-
newScrollX -= width
506-
}
507-
508-
this.scrollHeaderRef.scrollLeft = newScrollX
509-
this.scrollComponent.scrollLeft = newScrollX
510498

511499
const canvasTimeStart = this.state.canvasTimeStart
512500

src/lib/scroll/ScrollElement.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ class ScrollElement extends Component {
2222
}
2323
}
2424

25+
26+
2527
refHandler = el => {
2628
this.scrollComponent = el
2729
this.props.scrollRef(el)
2830
if(el){
2931
el.addEventListener('wheel', this.handleWheel, {passive: false});
3032
}
3133
}
32-
33-
handleScroll = () => {
34-
const scrollX = this.scrollComponent.scrollLeft
35-
this.props.onScroll(scrollX)
36-
}
34+
3735

3836
handleWheel = e => {
3937
const { traditionalZoom } = this.props
@@ -53,8 +51,7 @@ class ScrollElement extends Component {
5351
} else if (e.shiftKey) {
5452
e.preventDefault()
5553
// shift+scroll event from a touchpad has deltaY property populated; shift+scroll event from a mouse has deltaX
56-
this.scrollComponent.scrollLeft += e.deltaY || e.deltaX
57-
54+
this.props.onScroll(this.scrollComponent.scrollLeft + (e.deltaY || e.deltaX))
5855
// no modifier pressed? we prevented the default event, so scroll or zoom as needed
5956
}
6057
}
@@ -73,7 +70,7 @@ class ScrollElement extends Component {
7370
// this.props.onMouseMove(e)
7471
//why is interacting with item important?
7572
if (this.state.isDragging && !this.props.isInteractingWithItem) {
76-
this.scrollComponent.scrollLeft += this.dragLastPosition - e.pageX
73+
this.props.onScroll(this.scrollComponent.scrollLeft + this.dragLastPosition - e.pageX)
7774
this.dragLastPosition = e.pageX
7875
}
7976
}
@@ -144,7 +141,7 @@ class ScrollElement extends Component {
144141
let moveX = Math.abs(deltaX0) * 3 > Math.abs(deltaY0)
145142
let moveY = Math.abs(deltaY0) * 3 > Math.abs(deltaX0)
146143
if (deltaX !== 0 && moveX) {
147-
this.scrollComponent.scrollLeft -= deltaX
144+
this.props.onScroll(this.scrollComponent.scrollLeft - deltaX)
148145
}
149146
if (moveY) {
150147
window.scrollTo(
@@ -188,7 +185,6 @@ class ScrollElement extends Component {
188185
data-testid="scroll-element"
189186
className="rct-scroll"
190187
style={scrollComponentStyle}
191-
onScroll={this.handleScroll}
192188
onMouseDown={this.handleMouseDown}
193189
onMouseMove={this.handleMouseMove}
194190
onMouseUp={this.handleMouseUp}

0 commit comments

Comments
 (0)