Gathering detailed insights and metrics for react-moveable-kk
Gathering detailed insights and metrics for react-moveable-kk
Gathering detailed insights and metrics for react-moveable-kk
Gathering detailed insights and metrics for react-moveable-kk
react-moveable
A React Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable, Groupable.
moveable
Moveable is Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable, Groupable, Snappable.
ngx-moveable
An Angular Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable, Groupable, Snappable.
croact
Simple React for compatible use
npm install react-moveable-kk
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
89 Commits
1 Watching
2 Branches
1 Contributors
Updated on 22 Nov 2023
TypeScript (67.8%)
HTML (15.15%)
JavaScript (8.94%)
Vue (7.03%)
Less (0.62%)
CSS (0.45%)
Cumulative downloads
Total Downloads
Last day
-66.7%
2
Compared to previous day
Last week
-85.5%
32
Compared to previous week
Last month
4.7%
2,628
Compared to previous month
Last year
9,315.1%
6,873
Compared to previous year
14
51
这个拓展了阴影, 自定义了React Moveable
A React Component that create Moveable, Draggable, Resizable, Scalable, Rotatable, Warpable, Pinchable, Groupable, Snappable.
Demo / Storybook / API / Main Project
Moveable | |||
---|---|---|---|
Draggable | Resizable | Scalable | Rotatable |
Warpable | Pinchable | Groupable | Snappable |
Clippable | Roundable | OriginDraggable | Selecto |
1$ npm i react-moveable
1import Moveable from "react-moveable"; 2 3render() { 4 return ( 5 <Moveable 6 target={document.querySelector(".target")} 7 container={null} 8 origin={true} 9 10 /* Resize event edges */ 11 edge={false} 12 13 /* draggable */ 14 draggable={true} 15 throttleDrag={0} 16 onDragStart={({ target, clientX, clientY }) => { 17 console.log("onDragStart", target); 18 }} 19 onDrag={({ 20 target, 21 beforeDelta, beforeDist, 22 left, top, 23 right, bottom, 24 delta, dist, 25 transform, 26 clientX, clientY, 27 }: OnDrag) => { 28 console.log("onDrag left, top", left, top); 29 // target!.style.left = `${left}px`; 30 // target!.style.top = `${top}px`; 31 console.log("onDrag translate", dist); 32 target!.style.transform = transform; 33 }} 34 onDragEnd={({ target, isDrag, clientX, clientY }) => { 35 console.log("onDragEnd", target, isDrag); 36 }} 37 38 /* When resize or scale, keeps a ratio of the width, height. */ 39 keepRatio={true} 40 41 /* resizable*/ 42 /* Only one of resizable, scalable, warpable can be used. */ 43 resizable={true} 44 throttleResize={0} 45 onResizeStart={({ target , clientX, clientY}) => { 46 console.log("onResizeStart", target); 47 }} 48 onResize={({ 49 target, width, height, 50 dist, delta, direction, 51 clientX, clientY, 52 }: OnResize) => { 53 console.log("onResize", target); 54 delta[0] && (target!.style.width = `${width}px`); 55 delta[1] && (target!.style.height = `${height}px`); 56 }} 57 onResizeEnd={({ target, isDrag, clientX, clientY }) => { 58 console.log("onResizeEnd", target, isDrag); 59 }} 60 61 /* scalable */ 62 /* Only one of resizable, scalable, warpable can be used. */ 63 scalable={true} 64 throttleScale={0} 65 onScaleStart={({ target, clientX, clientY }) => { 66 console.log("onScaleStart", target); 67 }} 68 onScale={({ 69 target, scale, dist, delta, transform, 70 clientX, clientY, 71 }: OnScale) => { 72 console.log("onScale scale", scale); 73 target!.style.transform = transform; 74 }} 75 onScaleEnd={({ target, isDrag, clientX, clientY }) => { 76 console.log("onScaleEnd", target, isDrag); 77 }} 78 79 /* rotatable */ 80 rotatable={true} 81 throttleRotate={0} 82 onRotateStart={({ target, clientX, clientY }) => { 83 console.log("onRotateStart", target); 84 }} 85 onRotate={({ 86 target, 87 delta, dist, 88 transform, 89 clientX, clientY, 90 }: onRotate) => { 91 console.log("onRotate", dist); 92 target!.style.transform = transform; 93 }} 94 onRotateEnd={({ target, isDrag, clientX, clientY }) => { 95 console.log("onRotateEnd", target, isDrag); 96 }} 97 // Enabling pinchable lets you use events that 98 // can be used in draggable, resizable, scalable, and rotateable. 99 pinchable={true} 100 onPinchStart={({ target, clientX, clientY, datas }) => { 101 // pinchStart event occur before dragStart, rotateStart, scaleStart, resizeStart 102 console.log("onPinchStart"); 103 }} 104 onPinch={({ target, clientX, clientY, datas }) => { 105 // pinch event occur before drag, rotate, scale, resize 106 console.log("onPinch"); 107 }} 108 onPinchEnd={({ isDrag, target, clientX, clientY, datas }) => { 109 // pinchEnd event occur before dragEnd, rotateEnd, scaleEnd, resizeEnd 110 console.log("onPinchEnd"); 111 }} 112 /> 113 ); 114}
If you are using React 18's concurrent mode, use flushSync
for UI sync.
1import React from 'react'; 2import ReactDOM from 'react-dom/client'; 3import { flushSync } from "react-dom"; 4 5import Moveable from "react-moveable"; 6 7 8function App() { 9 return <Moveable flushSync={flushSync} /> 10} 11 12const root = ReactDOM.createRoot(document.getElementById("root")); 13 14root.render( 15 <React.StrictMode> 16 <App /> 17 </React.StrictMode> 18);
npm start
The main project was made with react
and I used croact
to make it lighter with umd.
For development and testing, check in packages/react-moveable.
$ yarn
$ npm run packages:build
$ npm run storybook
Runs the app in the development mode.
Open http://localhost:6006 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Please give a ⭐️ if this project helped you!
If you have any questions or requests or want to contribute to moveable
or other packages, please write the issue or give me a Pull Request freely.
This project exists thanks to all the people who contribute. [Contribute].
If you find a bug, please report to us opening a new Issue on GitHub.
This project is MIT licensed.
MIT License
Copyright (c) 2019 Daybrush
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
No vulnerabilities found.
No security vulnerabilities found.