Skip to content

Commit

Permalink
Require result options to be an object
Browse files Browse the repository at this point in the history
Also remove unused backgroundColor result option.
  • Loading branch information
theodorejb committed Nov 5, 2023
1 parent 2b1fb99 commit adcf152
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
10 changes: 1 addition & 9 deletions croppie.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,6 @@
canvas.width = canvasWidth;
canvas.height = canvasHeight;

if (data.backgroundColor) {
ctx.fillStyle = data.backgroundColor;
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
}

// By default assume we're going to draw the entire
// source image onto the destination canvas.
var sx = left,
Expand Down Expand Up @@ -1083,11 +1078,9 @@
var self = this,
data = _get.call(self),
opts = deepExtend(clone(RESULT_DEFAULTS), clone(options)),
resultType = (typeof (options) === 'string' ? options : opts.type),
size = opts.size || 'viewport',
format = opts.format,
quality = opts.quality,
backgroundColor = opts.backgroundColor,
circle = typeof opts.circle === 'boolean' ? opts.circle : (self.options.viewport.type === 'circle'),
vpRect = self.elements.viewport.getBoundingClientRect(),
ratio = vpRect.width / vpRect.height,
Expand Down Expand Up @@ -1116,10 +1109,9 @@

data.circle = circle;
data.url = self.data.url;
data.backgroundColor = backgroundColor;

prom = new Promise(function (resolve) {
switch(resultType) {
switch(opts.type) {
case 'rawcanvas':
resolve(_getCanvas.call(self, data));
break;
Expand Down
4 changes: 1 addition & 3 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ var Demo = (function() {
console.log('resize update', ev);
});
document.querySelector('.resizer-result').addEventListener('click', function (ev) {
resize.result({
type: 'blob'
}).then(function (blob) {
resize.result({ type: 'blob' }).then(function (blob) {
popupResult({
src: window.URL.createObjectURL(blob)
});
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ <h2>Demos</h2>
url: 'demo/demo-2.jpg',
});
//on button click
resize.result('blob').then(function(blob) {
resize.result({ type: 'blob' }).then(function (blob) {
// do something with cropped blob
});</code></pre>
<div class="actions">
Expand Down

0 comments on commit adcf152

Please sign in to comment.