Skip to content

Commit

Permalink
Keep the element's original transform properties while and after drag…
Browse files Browse the repository at this point in the history
…ging (fix the issue desandro#92)
  • Loading branch information
Gang Wu committed Jun 26, 2015
1 parent ed35f65 commit f5b1262
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions draggabilly.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ Draggabilly.prototype.dragEnd = function( event, pointer ) {
this.isDragging = false;
// use top left position when complete
if ( transformProperty ) {
this.element.style[ transformProperty ] = '';
var transform = this.element.style[ transformProperty ];
transform = transform.replace( /translate(3d)?\(.*\)/, '' );
this.element.style[ transformProperty ] = transform;
this.setLeftTop();
}
classie.remove( this.element, 'is-dragging' );
Expand Down Expand Up @@ -459,7 +461,9 @@ Draggabilly.prototype.setLeftTop = function() {
Draggabilly.prototype.positionDrag = transformProperty ?
function() {
// position with transform
this.element.style[ transformProperty ] = translate( this.dragPoint.x, this.dragPoint.y );
var transform = this.element.style[ transformProperty ];
transform = transform.replace( /translate(3d)?\(.*\)/, '' );
this.element.style[ transformProperty ] = transform + translate( this.dragPoint.x, this.dragPoint.y );
} : Draggabilly.prototype.setLeftTop;

// ----- staticClick ----- //
Expand All @@ -485,7 +489,9 @@ Draggabilly.prototype.destroy = function() {
this.disable();
// reset styles
if ( transformProperty ) {
this.element.style[ transformProperty ] = '';
var transform = this.element.style[ transformProperty ];
transform = transform.replace( /translate(3d)?\(.*\)/, '' );
this.element.style[ transformProperty ] = transform;
}
this.element.style.left = '';
this.element.style.top = '';
Expand Down

0 comments on commit f5b1262

Please sign in to comment.