Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesssooi committed Jan 25, 2018
2 parents 5ac7b7f + f98856b commit 931aa2c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ var ratio = cropInstance.getValue('ratio');
// value = {x: 0.1, y: 0.3: width: 0.57, height: 0.57}
```

#### destroy()

Destroys the Croppr instance and restores the original `img` element.

#### moveTo(x: Number, y: Number)

Moves the crop region to the specified coordinates. Returns the Croppr instance.
Expand Down
23 changes: 18 additions & 5 deletions dist/croppr.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,21 +560,24 @@ var CropprCore = function () {
throw 'Image src not provided.';
}
this._initialized = false;
this._targetEl = element;
this._restore = {
parent: element.parentNode,
element: element
};
if (!deferred) {
if (element.width === 0 || element.height === 0) {
element.onload = function () {
_this.initialize();
_this.initialize(element);
};
} else {
this.initialize();
this.initialize(element);
}
}
}
createClass(CropprCore, [{
key: 'initialize',
value: function initialize() {
this.createDOM(this._targetEl);
value: function initialize(element) {
this.createDOM(element);
this.options.convertToPixels(this.cropperEl);
this.attachHandlerEvents();
this.attachRegionEvents();
Expand Down Expand Up @@ -621,6 +624,11 @@ var CropprCore = function () {
this.containerEl.appendChild(this.cropperEl);
targetEl.parentElement.replaceChild(this.containerEl, targetEl);
}
}, {
key: 'destroy',
value: function destroy() {
this._restore.parent.replaceChild(this._restore.element, this.containerEl);
}
/**
* Create a new box region with a set of options.
* @param {Object} opts The options.
Expand Down Expand Up @@ -1078,6 +1086,11 @@ var Croppr$1 = function (_CropprCore) {
value: function getValue(mode) {
return get(Croppr.prototype.__proto__ || Object.getPrototypeOf(Croppr.prototype), 'getValue', this).call(this, mode);
}
}, {
key: 'destroy',
value: function destroy() {
return get(Croppr.prototype.__proto__ || Object.getPrototypeOf(Croppr.prototype), 'destroy', this).call(this);
}
/**
* Moves the crop region to a specified coordinate.
* @param {Number} x
Expand Down
Loading

0 comments on commit 931aa2c

Please sign in to comment.