UNPKG

ldx-widgets

Version:

widgets

33 lines (22 loc) 727 B
React = require 'react' {div} = React.DOM Draggable = React.createClass displayName: 'Draggable' getDefaultProps: -> centerOnCursor: true render: -> {position, component, options, className, centerOnCursor, height, width} = @props {x, y} = position if centerOnCursor x = x - width / 2 y = y - (height - height / 2) div { className: "draggable #{className or ''}" style: transform: "translateX(#{x}px) translateY(#{y}px) translateZ(0px)" msTransform: "translate(#{x}px) translateY(#{y}px)" WebkitTransform: "translateX(#{x}px) translateY(#{y}px)" height: height width: width }, component(options) module.exports = Draggable