| 13 | |
| 14 | export class Cursor extends Plugin<DragDropManager> { |
| 15 | constructor( |
| 16 | public manager: DragDropManager, |
| 17 | options?: CursorPluginOptions |
| 18 | ) { |
| 19 | super(manager, options); |
| 20 | |
| 21 | const {cursor = 'grabbing'} = options ?? {}; |
| 22 | const styleInjector = manager.registry.plugins.get( |
| 23 | StyleInjector as any |
| 24 | ) as StyleInjector | undefined; |
| 25 | |
| 26 | const unregisterStyles = styleInjector?.register( |
| 27 | `* { cursor: ${cursor} !important; }` |
| 28 | ); |
| 29 | |
| 30 | if (unregisterStyles) { |
| 31 | const originalDestroy = this.destroy.bind(this); |
| 32 | this.destroy = () => { |
| 33 | unregisterStyles(); |
| 34 | originalDestroy(); |
| 35 | }; |
| 36 | } |
| 37 | } |
| 38 | } |