Skip to content
Open
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
30 changes: 29 additions & 1 deletion draggabilly.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ extend( Draggabilly.prototype, EventEmitter.prototype );

Draggabilly.prototype.options = {
};

Draggabilly.prototype._create = function() {

// properties
Expand All @@ -131,6 +130,8 @@ Draggabilly.prototype._create = function() {
this.element.style.position = 'relative';
}

this._fixBottomRightPosition();

this.enable();
this.setHandles();

Expand Down Expand Up @@ -166,6 +167,33 @@ Draggabilly.prototype.setHandles = function() {
}
};

// bottom style fix, added for removing height expanding bug
// of elements, which position is absolute
Draggabilly.prototype._fixBottomRightPosition = function(){
var style = getStyle(this.element);
var parent_node = this.element.parentNode;

var bottom = parseInt(style.bottom, 10);
if( !isNaN(bottom) )
{
var element_height = this.element.offsetHeight;

var parent_height = Math.max(parent_node.clientHeight, parent_node.innerHeight || 0);
this.element.style.top = String(parent_height - element_height + bottom) + 'px';
this.element.style.bottom = 'auto';
}

var right = parseInt(style.right, 10);
if( !isNaN(right) )
{
var element_width = this.element.offsetWidth;
var parent_width = Math.max(parent_node.clientWidth, parent_node.innerWidth || 0);
this.element.style.left = String(parent_width - element_width + right) + 'px';
this.element.style.right = 'auto';
}
};


// remove default dragging interaction on all images in IE8
// IE8 does its own drag thing on images, which messes stuff up

Expand Down