An open API service indexing awesome lists of open source software.

https://github.com/devnax/react-movebox


https://github.com/devnax/react-movebox

Last synced: 7 months ago
JSON representation

Awesome Lists containing this project

README

          

Move any element

## Use

```js
import useMovebox from 'react-movebox'

const App = () => {
const [refs, state] = useMovebox({
defaultStyle: false, // optional
boundary: { // optional
width: 500,
height: 500
},
start: (s) => {
console.log(s);
},
moving: (s) => {
console.log(state);
},
end: (s) => {
console.log(s);
},
})

return (






);
};

ReactDOM.render(, document.getElementById('root'));

```

## Arguments

```js
const Args = {
defaultStyle?: boolean;
boundary?: {
width: number;
height: number;
};
start?: (state: StateProps) => void;
end?: (state: StateProps) => void;
moving?: (state: StateProps) => void;
}

```

## State Props
```js

const StateProps = {
pos: {
left: number,
top: number
},
initX: number,
initY: number,
height: number,
width: number,
isMouseDown: boolean,
}

```

## Refs

```
refs = {
boxRef: any,
handlerRef: any,
boundaryRef: any
}

```