-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathAutoFillHandle.tsx
More file actions
42 lines (32 loc) · 953 Bytes
/
Copy pathAutoFillHandle.tsx
File metadata and controls
42 lines (32 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as React from "react";
import * as Actions from "./actions";
import useDispatch from "./use-dispatch";
const AutoFillHandle: React.FC = () => {
const dispatch = useDispatch();
const autoFillStart = React.useCallback(() => {
dispatch(Actions.autoFillStart());
}, [dispatch]);
const autoFillEnd = React.useCallback(() => {
dispatch(Actions.autoFillEnd());
}, [dispatch]);
const handleMouseDown = React.useCallback(
(event: React.MouseEvent) => {
event.stopPropagation();
event.preventDefault();
autoFillStart();
const handleMouseUp = () => {
autoFillEnd();
window.removeEventListener("mouseup", handleMouseUp);
};
window.addEventListener("mouseup", handleMouseUp);
},
[autoFillStart, autoFillEnd]
);
return (
<div
className="Spreadsheet__auto-fill-handle"
onMouseDown={handleMouseDown}
/>
);
};
export default AutoFillHandle;