
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Pleasantly minimal drag-and-drop for React Web.
Now with auto-scrolling.
To date there are a number of quality drag-and-drop implementations available for React, ranging from the low-level but powerful (the popular and arguably "de-facto" react-dnd) to highly-featured but focussed (react-beautiful-dnd or react-sortable-hoc). In a real world use case, however, I came up against some limitations in these libraries and decided to roll my own. The design decisions that differentiate downdrop from other solutions are:
The term "drag-and-drop" encompasses a wide variety of different scenarios, so it is not really possible to document any single "default" use case. However, a list that can be rearranged by dragging items might be rendered thusly:
import { DragDropProvider, DragHandle DropTarget } from "downdrop";
const DraggableList = ({items, onDrag, onOver, onDrop}) => (
<DragDropProvider onDrop={this.handleDrop}>
{this.props.items.map(item => (
<DropTarget key={item.id} data={item} onOver={this.handleOver}>
<DragHandle data={item} onDrag={this.handleDrag}>
<Item>{item.text}</Item>
</DragHandle>
</DropTarget>
))}
</DragDropProvider>
);
The implementation details of onDrag, onOver and onDrop, and how they might modify state to provide visual feedback, are left to the developer. More complete reference implementations are provided in the examples but this render example shows off the simplistic nature of the supplied primitives.
yarn add downdrop
Or npm if you prefer.
Downdrop utilises a provider component. This can be placed at the top level of your app if you wish, although this is not required; but it must at least wrap all DragHandles and DropTargets that need to work together. You may wish to handle some events at the provider level; this allows you to destroy the dragged component during drag yet still respond to events.
import { DragDropProvider } from "downdrop";
<DragDropProvider onDrop={(e,data)=>handleDropped(data)}>
<App />
</DragDropProvider>
onDrop: function(event: SyntheticEvent, data: any)
Handler to be called when the user ends a drag operation by releasing the mouse
onMove: function(event: SyntheticEvent, data: any, context: eventContext)
scrollNearViewportEdge: string(none|both|horizontal|vertical, default:both)
Whether to automatically scroll when dragging near the viewport edges. Can scroll on either axis, both or none.
scrollProximity: number(default: 100)
How near (in pixels) to the edge of the viewport the mouse must be in order to trigger viewport scrolling.
scrollSpeed: number(default: 1200)
Maximum speed at which to scroll, in pixels per second. Scrolling will be faster the nearer the user hsa dragged to the viewport, from 0 at the edge of the promimity bound, up to the maximum when 1 pixel away from the edge.
minimumDragDistance: number(default: 3)
Number of pixels the mouse must move after pressing the button down before the element is actually considered to be dragging. Prevents accidentally moving things when trying to just click on them.
Examples are found in https://github.com/downplay/downdrop/tree/master/examples/source/examples. To run them, clone the repository and execute:
yarn build
yarn examples
Then navigate to http://127.0.0.1:3311/
The dev server is hot module enabled so tweak at will.
scrollNearViewportEdge, scrollProximity, and scrollSpeed of <DragDropProvider>.minimumDragDistance property of <DragDropProvider>OrderableListWithPortal demonstrating using react-portal to render the element being draggedreact-domPlease report any other bugs or issues on GitHub: https://github.com/downplay/downdrop
©2017 Downplay Ltd
Distributed under MIT license. See LICENSE for full details.
FAQs
Pleasantly minimal drag-and-drop for React
We found that downdrop 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.