Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres (more or less) to [Semantic Versioning](http://semver.o

## Unreleased

* Add option to continue scrolling when mouse leaves timeline div.

## 0.30.0 (beta.18)

* Migrate test suite from Jest/Enzyme to Vitest + React Testing Library.
Expand Down
5 changes: 5 additions & 0 deletions src/lib/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export type ReactCalendarTimelineProps<
itemTouchSendsClick?: boolean | undefined;
timeSteps: TimelineTimeSteps;
scrollRef?: (el: HTMLDivElement) => void;
/**
* Continue dragging items when the mouse leaves the scrollRef element.
*/
continueDragOnMouseLeave?: boolean | undefined;
onItemDrag?(itemDragObject: OnItemDragObjectMove | OnItemDragObjectResize): void;
onItemMove?(itemId: Id, dragTime: number, newGroupOrder: number): void;
onItemResize?(itemId: Id, endTimeOrStartTime: number, edge: ResizeEdge): void;
Expand Down Expand Up @@ -1054,6 +1058,7 @@ export default class ReactCalendarTimeline<
traditionalZoom={!!traditionalZoom}
onScroll={this.onScroll}
scrollOffset={scrollOffset}
continueDragOnMouseLeave={this.props.continueDragOnMouseLeave}
>
<MarkerCanvas>
{this.columns(canvasTimeStart, canvasTimeEnd, canvasWidth, minUnit, timeSteps, height)}
Expand Down
6 changes: 5 additions & 1 deletion src/lib/scroll/ScrollElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Props = {
onWheelZoom: (speed: number, xPosition: number, deltaY: number) => void;
onScroll: (n: number) => void;
scrollOffset: number;
continueDragOnMouseLeave?: boolean;
};

type State = {
Expand Down Expand Up @@ -77,6 +78,9 @@ class ScrollElement extends Component<Props, State> {
} else if (e.pointerType === "mouse") {
this.handleMouseMove(e);
}
if (this.props.continueDragOnMouseLeave) {
this.scrollComponentRef.current?.setPointerCapture(e.pointerId);
}
};

handlePointerEnd = (e: PointerEvent) => {
Expand Down Expand Up @@ -169,7 +173,7 @@ class ScrollElement extends Component<Props, State> {
};

handlePointerLeave = (e: PointerEvent) => {
if (e.pointerType === "mouse") {
if (e.pointerType === "mouse" && !this.props.continueDragOnMouseLeave) {
this.dragLastPosition = null;
this.setState({
isDragging: false,
Expand Down