Skip to content

Commit 59c9630

Browse files
authored
Release 0.18.2 (namespace-ee#389)
1 parent a1d31c4 commit 59c9630

File tree

5 files changed

+38
-25
lines changed

5 files changed

+38
-25
lines changed

CHANGELOG.md

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

88
## Unreleased
99

10+
11+
### 0.18.2
12+
13+
### Fixed
14+
15+
* `onCanvasClick` not fired - #383
16+
* cursor marker disappear while hovering over item - #378
17+
1018
### 0.18.1
1119

1220
### Fixed

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.18.1",
3+
"version": "0.18.2",
44
"description": "react calendar timeline",
55
"main": "lib/index.js",
66
"scripts": {

src/lib/Timeline.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import {
2020
nostack,
2121
calculateDimensions,
2222
getGroupOrders,
23-
getVisibleItems
23+
getVisibleItems,
24+
calculateTimeForXPosition
2425
} from './utility/calendar'
25-
import { getParentPosition } from './utility/dom-helpers'
2626
import { _get, _length } from './utility/generic'
2727
import {
2828
defaultKeys,
@@ -632,16 +632,25 @@ export default class ReactCalendarTimeline extends Component {
632632
// as well as generalizing how we get time from click on the canvas
633633
getTimeFromRowClickEvent = e => {
634634
const { dragSnap } = this.props
635-
const { width, visibleTimeStart, visibleTimeEnd } = this.state
636-
637-
// get coordinates relative to the component
638-
const parentPosition = getParentPosition(e.currentTarget)
635+
const {
636+
width,
637+
canvasTimeStart,
638+
visibleTimeStart,
639+
visibleTimeEnd
640+
} = this.state
641+
// this gives us distance from left of row element, so event is in
642+
// context of the row element, not client or page
643+
const { offsetX } = e.nativeEvent
639644

640-
const x = e.clientX - parentPosition.x
645+
// FIXME: DRY up way to calculate canvasTimeEnd
646+
const zoom = visibleTimeEnd - visibleTimeStart
647+
const canvasTimeEnd = zoom * 3 + canvasTimeStart
641648

642-
// calculate the x (time) coordinate taking the dragSnap into account
643-
let time = Math.round(
644-
visibleTimeStart + x / width * (visibleTimeEnd - visibleTimeStart)
649+
let time = calculateTimeForXPosition(
650+
canvasTimeStart,
651+
canvasTimeEnd,
652+
width * 3,
653+
offsetX
645654
)
646655
time = Math.floor(time / dragSnap) * dragSnap
647656

@@ -1153,12 +1162,6 @@ export default class ReactCalendarTimeline extends Component {
11531162
height: `${height}px`
11541163
}
11551164

1156-
const canvasComponentStyle = {
1157-
width: `${canvasWidth}px`,
1158-
height: `${height}px`,
1159-
position: 'relative'
1160-
}
1161-
11621165
return (
11631166
<TimelineStateProvider
11641167
visibleTimeStart={visibleTimeStart}
@@ -1199,11 +1202,7 @@ export default class ReactCalendarTimeline extends Component {
11991202
onMouseMove={this.handleScrollMouseMove}
12001203
onContextMenu={this.handleScrollContextMenu}
12011204
>
1202-
<div
1203-
ref={el => (this.canvasComponent = el)}
1204-
style={canvasComponentStyle}
1205-
>
1206-
<MarkerCanvas />
1205+
<MarkerCanvas>
12071206
{this.items(
12081207
canvasTimeStart,
12091208
zoom,
@@ -1239,7 +1238,7 @@ export default class ReactCalendarTimeline extends Component {
12391238
minUnit,
12401239
timeSteps
12411240
)}
1242-
</div>
1241+
</MarkerCanvas>
12431242
</ScrollElement>
12441243
{rightSidebarWidth > 0
12451244
? this.rightSidebar(height, groupHeights)

src/lib/markers/MarkerCanvas.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const staticStyles = {
1919
*/
2020
class MarkerCanvas extends React.Component {
2121
static propTypes = {
22-
getDateFromLeftOffsetPosition: PropTypes.func.isRequired
22+
getDateFromLeftOffsetPosition: PropTypes.func.isRequired,
23+
children: PropTypes.node
2324
}
2425

2526
handleMouseMove = evt => {
@@ -71,6 +72,7 @@ class MarkerCanvas extends React.Component {
7172
ref={el => (this.containerEl = el)}
7273
>
7374
<TimelineMarkersRenderer />
75+
{this.props.children}
7476
</div>
7577
</MarkerCanvasProvider>
7678
)

src/lib/markers/implementations/shared.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ const criticalStyles = {
88
top: 0,
99
bottom: 0,
1010
width: '2px',
11-
backgroundColor: 'black'
11+
backgroundColor: 'black',
12+
// by default, pointer events (specifically click) will
13+
// "pass through". This is added so that CursorMarker
14+
// will not get in the way of canvas click
15+
pointerEvents: 'none'
1216
}
1317

1418
// FIXME: this creates a new object each time in render

0 commit comments

Comments
 (0)