1.4.5 • Published 11 months ago
@hffxx/react-overflow-box v1.4.5
react-overflow-box
React Overflowbox to implement mouse-like dragging.
Demo
Install
npm i @hffxx/react-overflow-box
yarn add @hffxx/react-overflow-box
Usage
import { Overflowbox } from '@hffxx/react-overflow-box';
const Component = () => {
return (
<Overflowbox width={500} height={500}>
<img src={your_src} alt="" />
</Overflowbox>
);
};
Component properties
Prop | Type | Description | Default |
---|---|---|---|
width | number | View width | |
height | number | View height | |
x | number | Initial X-axis view position | |
y | number | Initial Y-axis view position | |
setX | SetStateAction | React setState for X-axis value | |
setY | SetStateAction | React setState for Y-axis value | |
wrapper | ElementType | Wrapper element | "div" |
reactRef | MutableRefObject | Ref | |
children | ReactNode | Children | |
showScrollbar | Boolean | Show the scrollbars | false |
smoothScrolling | Boolean | Enables smooth animation for scrolling | false |
className | String | Custom classname for the wrapper | |
disableX | Boolean | Disable X-axis view drag | false |
disableY | Boolean | Disable Y-axis view drag | false |
disable | Boolean | Disable X-axis and Y-axis view drag | false |
onDragStart | Function | Invoked when the user starts dragging | |
onDragEnd | Function | Invoked when the user ends dragging | |
onMoveStart | Function | Invoked when the view position starts changing | |
onMoveEnd | Function | Invoked when the view position stops changing | |
cursor | Cursor | Overrides default cursor | "grab" |
grabCursor | Cursor | Overrides default cursor while dragging | "grabbing" |
disableScrollWheel | Boolean | Disables scrolling inside wrapper | false |
FAQ
How do I position the view in pixels?
In the Overflowbox component, you pass the x and y as number. If you have an image that is 1000px width, you can set x value as 500 to center the image.
License
The source code is licensed under MIT
1.4.5
11 months ago
1.4.4
11 months ago
1.4.3
12 months ago
1.4.2
12 months ago
1.3.7
1 year ago
1.2.8
1 year ago
1.3.6
1 year ago
1.2.7
1 year ago
1.3.5
1 year ago
1.3.4
1 year ago
1.3.3
1 year ago
1.4.1
1 year ago
1.3.2
1 year ago
1.4.0
1 year ago
1.3.1
1 year ago
1.3.0
1 year ago
1.3.9
1 year ago
1.3.8
1 year ago
1.2.9
1 year ago
1.2.6
1 year ago
1.2.5
1 year ago
1.2.4
1 year ago
1.2.3
1 year ago
1.2.2
1 year ago
1.2.1
1 year ago
1.2.0
1 year ago
1.1.9
1 year ago
1.1.8
1 year ago
1.1.7
1 year ago
1.1.6
1 year ago
1.1.5
1 year ago
1.1.4
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.1.1
1 year ago
1.1.0
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago