Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bottom style fix for removing height expanding bug of elements, wh... #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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