|
1 | 1 | import * as React from "react"; |
2 | | -import { DraggableEventHandler, default as DraggableRoot } from "react-draggable"; |
| 2 | +import Draggable, { DraggableEventHandler } from "react-draggable"; |
3 | 3 | import { Enable, Resizable, ResizeDirection } from "re-resizable"; |
4 | 4 |
|
5 | | -// FIXME: https://github.com/mzabriskie/react-draggable/issues/381 |
6 | | -// I can not find `scale` too... |
7 | | -type $TODO = any; |
8 | | -const Draggable: any = DraggableRoot; |
9 | | - |
10 | 5 | export type Grid = [number, number]; |
11 | 6 |
|
12 | 7 | export type Position = { |
@@ -209,7 +204,7 @@ export class Rnd extends React.PureComponent<Props, State> { |
209 | 204 | onDragStop: () => {}, |
210 | 205 | }; |
211 | 206 | resizable!: Resizable; |
212 | | - draggable!: $TODO; // Draggable; |
| 207 | + draggable!: Draggable; |
213 | 208 | resizingPosition = { x: 0, y: 0 }; |
214 | 209 | offsetFromParent = { left: 0, top: 0 }; |
215 | 210 | resizableElement: { current: HTMLElement | null } = { current: null }; |
@@ -507,7 +502,8 @@ export class Rnd extends React.PureComponent<Props, State> { |
507 | 502 | } |
508 | 503 | } |
509 | 504 |
|
510 | | - if (newPos.x !== this.draggable.state.x || newPos.y !== this.draggable.state.y) { |
| 505 | + const draggableState = this.draggable.state as unknown as { x: number; y: number }; |
| 506 | + if (newPos.x !== draggableState.x || newPos.y !== draggableState.y) { |
511 | 507 | this.draggable.setState(newPos); |
512 | 508 | } |
513 | 509 |
|
@@ -572,7 +568,7 @@ export class Rnd extends React.PureComponent<Props, State> { |
572 | 568 | }; |
573 | 569 | } |
574 | 570 |
|
575 | | - refDraggable = (c: $TODO) => { |
| 571 | + refDraggable = (c: Draggable) => { |
576 | 572 | if (!c) return; |
577 | 573 | this.draggable = c; |
578 | 574 | }; |
@@ -642,6 +638,7 @@ export class Rnd extends React.PureComponent<Props, State> { |
642 | 638 | handle={dragHandleClassName ? `.${dragHandleClassName}` : undefined} |
643 | 639 | defaultPosition={defaultValue} |
644 | 640 | onMouseDown={onMouseDown} |
| 641 | + // @ts-expect-error |
645 | 642 | onMouseUp={onMouseUp} |
646 | 643 | onStart={this.onDragStart} |
647 | 644 | onDrag={this.onDrag} |
|
0 commit comments