Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@nosferatu500/react-dnd-scrollzone
Advanced tools
A cross browser solution to scrolling during drag and drop.
Forked from https://github.com/azuqua/react-dnd-scrollzone with support for react-dnd@16.
Cross browser compatible scrolling containers for drag and drop interactions.
import React from 'react'
import { HTML5Backend } from 'react-dnd-html5-backend'
import { DndProvider } from 'react-dnd'
import withScrolling, {createVerticalStrength, createHorizontalStrength} from '@nosferatu500/react-dnd-scrollzone'
import {DragItem} from './DragItem'
import './App.css'
const ScrollingComponent = withScrolling(
React.forwardRef((props, ref) => {
const {dragDropManager, ...otherProps} = props;
return <div ref={ref} {...otherProps} />
}))
const ITEMS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const verticalStrength = createVerticalStrength(150);
const horizontalStrength = createHorizontalStrength(150);
const App = () => (
<DndProvider backend={HTML5Backend}>
<ScrollingComponent className="App" verticalStrength={verticalStrength} horizontalStrength={horizontalStrength}>
{ITEMS.map((n) => (
<DragItem key={n} label={`Item ${n}`} />
))}
</ScrollingComponent>
</DndProvider>
Note: You should replace the original div
you would like to make scrollable with the ScrollingComponent
.
import withScrolling, { createVerticalStrength, createHorizontalStrength } from '@nosferatu500/react-dnd-scrollzone';
const Scrollzone = withScrolling('ul');
const vStrength = createVerticalStrength(500);
const hStrength = createHorizontalStrength(300);
// zone will scroll when the cursor drags within
// 500px of the top/bottom and 300px of the left/right
const zone = (
<Scrollzone verticalStrength={vStrength} horizontalStrength={hStrength}>
</Scrollzone>
);
withScrolling
A React higher order component with the following properties:
const ScrollZone = withScrolling(String|Component);
<ScrollZone
strengthMultiplier={Number}
horizontalStrength={Function}
verticalStrength={Function}
onScrollChange={Function} >
{children}
</Scrollzone>
Apply the withScrolling function to any html-identifier ("div", "ul" etc) or react component to add drag and drop scrolling behaviour.
horizontalStrength
a function that returns the strength of the horizontal scroll directionverticalStrength
- a function that returns the strength of the vertical scroll directionstrengthMultiplier
- strength multiplier, play around with this (default 30)onScrollChange
- a function that is called when scrollLeft
or scrollTop
of the component are changed. Called with those two arguments in that order.The strength functions are both called with two arguments. An object representing the rectangle occupied by the Scrollzone, and an object representing the coordinates of mouse.
They should return a value between -1 and 1.
createVerticalStrength(buffer)
and createHorizontalStrength(buffer)
These allow you to create linearly scaling strength functions with a sensitivity different than the default value of 150px.
FAQs
A cross browser solution to scrolling during drag and drop.
We found that @nosferatu500/react-dnd-scrollzone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.