From ed7463af09d06f7f80c5e09ab169b4f6e78842b4 Mon Sep 17 00:00:00 2001 From: Danny Morrow Date: Thu, 17 Aug 2017 09:42:19 -0400 Subject: [PATCH 1/2] Fix destroy method and support images that aren't draggable If you select an image with an aspect ratio that fits correctly in the drag area, then no scaling is applied and everything breaks. --- jquery.drag-n-crop.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jquery.drag-n-crop.js b/jquery.drag-n-crop.js index 162e9c0..4d23733 100644 --- a/jquery.drag-n-crop.js +++ b/jquery.drag-n-crop.js @@ -17,6 +17,7 @@ containment: 'dragncrop-containment', horizontal: 'dragncrop-horizontal', vertical: 'dragncrop-vertical', + nodrag: 'dragncrop-nodrag', // Options' classes overflow: 'dragncrop-overflow', @@ -100,6 +101,9 @@ if (self.options.loaded) { self.options.loaded(); } + } else { + self._setPosition({top: 0, left: 0}); + self.options.loaded(); } } ); @@ -110,8 +114,12 @@ this.container.find('.' + this.classes.containment + ',' + '.' + this.classes.overlay + ',' + '.' + this.classes.instruction).remove(); + this.container.removeClass(this.classes.overflow).removeClass(this.classes.container); this.element.removeClass(this.classes.horizontal) + .removeClass(this.classes.nodrag) .removeClass(this.classes.vertical); + this.element.css('left', ''); + this.element.css('top', ''); }, getPosition: function() { @@ -159,7 +167,7 @@ return true; }else{ - + $(this.element).addClass(this.classes.nodrag); return false; } From 386081110ee6c7692be5a17d3fc4f15c862347fb Mon Sep 17 00:00:00 2001 From: Danny Morrow Date: Thu, 17 Aug 2017 09:44:32 -0400 Subject: [PATCH 2/2] Add .dragncrop-nodrag --- jquery.drag-n-crop.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jquery.drag-n-crop.css b/jquery.drag-n-crop.css index b55ffd6..502bbda 100644 --- a/jquery.drag-n-crop.css +++ b/jquery.drag-n-crop.css @@ -35,6 +35,11 @@ max-height: none; } +.dragncrop-nodrag { + width: 100%; + height: 100%; +} + .dragncrop-containment { position: absolute; }