Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
react-draggable2
Advanced tools
React draggable component
Based on https://github.com/mzabriskie/react-draggable
$ npm install react-draggable2
http://mzabriskie.github.io/react-draggable/example/
/** @jsx React.DOM */
var React = require('react'),
Draggable = require('react-draggable');
var App = React.createClass({
handleStart: function (event, ui) {
console.log('Event: ', event);
console.log('Position: ', ui.position);
},
handleDrag: function (event, ui) {
console.log('Event: ', event);
console.log('Position: ', ui.position);
},
handleStop: function (event, ui) {
console.log('Event: ', event);
console.log('Position: ', ui.position);
},
render: function () {
return (
// <Draggable/> transparently adds draggable interactivity
// to whatever element is supplied as `this.props.children`.
// Only a single element is allowed or an Error will be thrown.
//
// `axis` determines which axis the draggable can move.
// - 'both' allows movement horizontally and vertically (default).
// - 'x' limits movement to horizontal axis.
// - 'y' limits movement to vertical axis.
//
// `handle` specifies a selector to be used as the handle that initiates drag.
//
// `cancel` specifies a selector to be used to prevent drag initialization.
//
// `bound` determines whether to bound the movement to the parent box.
// - 'top' bounds movement to the top edge of the parent box.
// - 'right' bounds movement to the right edge of the parent box.
// - 'bottom' bounds movement to the bottom edge of the parent box.
// - 'left' bounds movement to the left edge of the parent box.
// - 'all' bounds movement to all edges (default if not specified).
// - 'point' to constrain only the top-left corner.
// - 'box' to constrain the entire box (default if not specified).
//
// `constrain` takes a function to constrain the dragging.
//
// `start` specifies the x and y that the dragged item should start at
//
// `zIndex` specifies the zIndex to use while dragging.
//
// `onStart` is called when dragging starts.
//
// `onDrag` is called while dragging.
//
// `onStop` is called when dragging stops.
<Draggable
axis="x"
handle=".handle"
grid={constrain(25)}
start={{x: 25, y: 25}}
bound="all box"
zIndex={100}
onStart={this.handleStart}
onDrag={this.handleDrag}
onStop={this.handleStop}>
<div>
<div className="handle">Drag from here</div>
<div>Lorem ipsum...</div>
</div>
</Draggable>
);
}
});
function constrain (snap) {
function constrainOffset (offset, prev) {
var delta = offset - prev;
if (Math.abs(delta) >= snap) {
return prev + parseInt(delta / snap, 10) * snap;
}
return prev;
}
return function (pos) {
return {
top: constrainOffset(pos.top, pos.prevTop),
left: constrainOffset(pos.left, pos.prevLeft)
};
};
}
React.renderComponent(<App/>, document.body);
$ npm install && npm start
$ npm test
MIT
0.4.2 (Dec 7, 2014)
FAQs
React draggable component
The npm package react-draggable2 receives a total of 61 weekly downloads. As such, react-draggable2 popularity was classified as not popular.
We found that react-draggable2 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.