Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,13 @@ module.exports = React.createClass({
onStart: emptyFunction,
onDrag: emptyFunction,
onStop: emptyFunction,
onMouseDown: emptyFunction,
onMouseDown: emptyFunction
};
},

getInitialState: function (props) {
// Handle call from CWRP
var currentState = this.state;
props = props || this.props;
return {
// Whether or not we are currently dragging.
Expand All @@ -521,9 +522,10 @@ module.exports = React.createClass({
// Current transform x and y.
clientX: props.start.x, clientY: props.start.y,

// Can only determine if is SVG after mounted
isElementSVG: false

// Determines if the element is an svg or not. Default to false.
isElementSVG: currentState && currentState.isElementSVG !== undefined ?
currentState.isElementSVG :
false
};
},

Expand Down Expand Up @@ -682,7 +684,7 @@ module.exports = React.createClass({
// If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
// has a clean slate.
var transform = this.state.isElementSVG ? null :
createCSSTransform({
createCSSTransform({
// Set left if horizontal drag is enabled
x: canDragX(this) ?
this.state.clientX :
Expand All @@ -695,6 +697,8 @@ module.exports = React.createClass({
});


// This is primarily for IE as it ignores the CSS transform applied above
// and only respects the real transform attribute.
var svgTransform = !this.state.isElementSVG ? null :
createSVGTransform({
// Set left if horizontal drag is enabled
Expand Down
4 changes: 2 additions & 2 deletions specs/draggable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('react-draggable', function () {

var style = node.getAttribute('style');
expect(style.indexOf('transform: translate(100px, 100px);')).not.toEqual(-1);

});

it('should detect if an element is instanceof SVGElement and set state.isElementSVG to true', function() {
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('react-draggable', function () {

var transform = node.getAttribute('transform');
expect(transform.indexOf('translate(100,100)')).not.toEqual(-1);

});


Expand Down