Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
react-droplite
Advanced tools
Light react component to add drag and drop functionality to your lists.
Install the package with npm install droplite
There are four basic requirements
const MyComponent = (props) => {
const [items, setItems] = useState(["A", "B", "C", "D"])
// Requirement 1: add unique key
const listItems = items.map(item =><li key={item}>{item}</li>)
// Requirement 2: Implement on new order Handler
const onNewOrder = (draggedItem, dropOntoItem) => {
const newItemOrder = [...items]
const draggedItemIndex = items.indexOf(draggedItem)
newItemOrder.splice(draggedItemIndex, 1)
newItemOrder.splice(items.indexOf(dropOntoItem), 0, items[draggedItemIndex])
setItems(newItemOrder)
}
// Requirement 3: Wrap the list with DragList HOC
// Requirement 4: pass onNewOrder handler as prop
return (
<div>
<DragList onNewOrder={onNewOrder}>
{listItems}
</DragList>
</div>
)
}
See Storybooks
Droplite depends on the HTML Drag and Drop API.
DragList
component manages internal state of the drag and drop operation.
The key function in DragList
is the dragOverHandler
that takes care of which element is being dragged over that can later be displaced. Once the onDragEndHandler
is triggered, the current dragged element and the one below it (the draggedOver) are passed onto the onNewOrder
handler.
Draggable
is just a wrapper for your custom defined components that injects props and css classes that are required to start managing the drag and drop event listeners.
Support for mobile devices is not considered.
Smooth animations
FAQs
Fat free react drag and drop lists
The npm package react-droplite receives a total of 0 weekly downloads. As such, react-droplite popularity was classified as not popular.
We found that react-droplite 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.