Skip to content

Commit

Permalink
Release v0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyuanchen committed May 28, 2016
1 parent e9d3c9f commit af85df2
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 59 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog


## 0.7.1 (May 28, 2016)

- Improved the rotate and scale transform behaviour.
- Improved the `getCroppedCanvas` method (returns the whole canvas if it is not cropped).
- Check cross origin setting when load image by XMLHTTPRequest.


## 0.7.0 (Mar 20, 2016)

- Supports 7 custom events: `build`, `built`, `cropstart`, `cropmove`, `cropend`, `crop` and `zoom`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ Change the crop box position and size with new data.
- Rotated image: requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).
- Cross-origin image: requires HTML5 [CORS settings attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) support ([IE 11+](http://caniuse.com/cors)).

Get a canvas drawn the cropped image.
Get a canvas drawn the cropped image. If it is not cropped, then returns the whole canvas.

> After then, you can display the canvas as an image directly, or use [HTMLCanvasElement.toDataURL](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL) to get a Data URL, or use [HTMLCanvasElement.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) to get a blob and upload it to server with [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) if the browser supports these APIs.
Expand Down
7 changes: 3 additions & 4 deletions demo/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ window.onload = function () {
var dataRotate = document.getElementById('dataRotate');
var dataScaleX = document.getElementById('dataScaleX');
var dataScaleY = document.getElementById('dataScaleY');
var isUndefined = function (obj) {
return typeof obj === 'undefined';
};
var options = {
aspectRatio: 16 / 9,
preview: '.img-preview',
Expand Down Expand Up @@ -51,10 +54,6 @@ window.onload = function () {
};
var cropper = new Cropper(image, options);

function isUndefined(obj) {
return typeof obj === 'undefined';
}

function preventDefault(e) {
if (e) {
if (e.preventDefault) {
Expand Down
4 changes: 2 additions & 2 deletions dist/cropper.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Cropper.js v0.7.0
* Cropper.js v0.7.1
* https://github.com/fengyuanchen/cropperjs
*
* Copyright (c) 2015-2016 Fengyuan Chen
* Released under the MIT license
*
* Date: 2016-03-20T06:15:36.234Z
* Date: 2016-05-28T14:59:00.132Z
*/
.cropper-container {
font-size: 0;
Expand Down
56 changes: 33 additions & 23 deletions dist/cropper.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Cropper.js v0.7.0
* Cropper.js v0.7.1
* https://github.com/fengyuanchen/cropperjs
*
* Copyright (c) 2015-2016 Fengyuan Chen
* Released under the MIT license
*
* Date: 2016-03-20T06:15:36.234Z
* Date: 2016-05-28T14:59:00.132Z
*/

(function (global, factory) {
Expand Down Expand Up @@ -330,6 +330,22 @@
}
}

function removeListener(element, type, handler) {
var types = trim(type).split(REGEXP_SPACES);

if (types.length > 1) {
return each(types, function (type) {
removeListener(element, type, handler);
});
}

if (element.removeEventListener) {
element.removeEventListener(type, handler, false);
} else if (element.detachEvent) {
element.detachEvent('on' + type, handler);
}
}

function addListener(element, type, handler, once) {
var types = trim(type).split(REGEXP_SPACES);
var originalHandler = handler;
Expand All @@ -355,22 +371,6 @@
}
}

function removeListener(element, type, handler) {
var types = trim(type).split(REGEXP_SPACES);

if (types.length > 1) {
return each(types, function (type) {
removeListener(element, type, handler);
});
}

if (element.removeEventListener) {
element.removeEventListener(type, handler, false);
} else if (element.detachEvent) {
element.detachEvent('on' + type, handler);
}
}

function dispatchEvent(element, type, data) {
var event;

Expand Down Expand Up @@ -537,14 +537,15 @@
var scaleX = data.scaleX;
var scaleY = data.scaleY;

if (isNumber(rotate)) {
transforms.push('rotate(' + rotate + 'deg)');
}

// Scale should come first before rotate
if (isNumber(scaleX) && isNumber(scaleY)) {
transforms.push('scale(' + scaleX + ',' + scaleY + ')');
}

if (isNumber(rotate)) {
transforms.push('rotate(' + rotate + 'deg)');
}

return transforms.length ? transforms.join(' ') : 'none';
}

Expand Down Expand Up @@ -853,6 +854,10 @@
_this.read(this.response);
};

if (options.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) {
url = addTimestamp(url);
}

xhr.open('get', url);
xhr.responseType = 'arraybuffer';
xhr.send();
Expand Down Expand Up @@ -3215,10 +3220,15 @@
var context;
var data;

if (!_this.built || !_this.cropped || !SUPPORT_CANVAS) {
if (!_this.built || !SUPPORT_CANVAS) {
return;
}

// Return the whole canvas if not cropped
if (!_this.cropped) {
return getSourceCanvas(_this.image, _this.imageData);
}

if (!isPlainObject(options)) {
options = {};
}
Expand Down
4 changes: 2 additions & 2 deletions dist/cropper.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/cropper.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
<nav class="collapse navbar-collapse" id="navbar-collapse" role="navigation">
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/fengyuanchen/cropperjs/tree/v0.7.0/README.md">Docs</a></li>
<li><a href="https://github.com/fengyuanchen/cropperjs/tree/v0.7.1/README.md">Docs</a></li>
<li><a href="https://fengyuanchen.github.io/photo-editor" title="An advanced example of Cropper.js">Photo Editor</a></li>
<li><a href="https://github.com/fengyuanchen/cropperjs">GitHub</a></li>
<li><a href="https://fengyuanchen.github.io">More</a></li>
Expand All @@ -45,7 +45,7 @@
<!-- Jumbotron -->
<div class="jumbotron docs-jumbotron">
<div class="container">
<h1>Cropper.js <small class="version">v0.7.0</small></h1>
<h1>Cropper.js <small class="version">v0.7.1</small></h1>
<p class="lead">JavaScript image cropper.</p>
<div class="docs-carbonads-container">
<div class="docs-carbonads">
Expand Down
7 changes: 3 additions & 4 deletions docs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ window.onload = function () {
var dataRotate = document.getElementById('dataRotate');
var dataScaleX = document.getElementById('dataScaleX');
var dataScaleY = document.getElementById('dataScaleY');
var isUndefined = function (obj) {
return typeof obj === 'undefined';
};
var options = {
aspectRatio: 16 / 9,
preview: '.img-preview',
Expand Down Expand Up @@ -51,10 +54,6 @@ window.onload = function () {
};
var cropper = new Cropper(image, options);

function isUndefined(obj) {
return typeof obj === 'undefined';
}

function preventDefault(e) {
if (e) {
if (e.preventDefault) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cropperjs",
"description": "JavaScript image cropper.",
"version": "0.7.0",
"version": "0.7.1",
"main": "dist/cropper.js",
"license": "MIT",
"repository": "fengyuanchen/cropperjs",
Expand Down Expand Up @@ -33,7 +33,7 @@
"gulp-autoprefixer": "^3.1.0",
"gulp-concat": "^2.6.0",
"gulp-csscomb": "^3.0.6",
"gulp-csslint": "^0.2.2",
"gulp-csslint": "^0.3.0",
"gulp-htmlcomb": "^0.1.0",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^1.12.0",
Expand Down
32 changes: 16 additions & 16 deletions src/js/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@
}
}

function removeListener(element, type, handler) {
var types = trim(type).split(REGEXP_SPACES);

if (types.length > 1) {
return each(types, function (type) {
removeListener(element, type, handler);
});
}

if (element.removeEventListener) {
element.removeEventListener(type, handler, false);
} else if (element.detachEvent) {
element.detachEvent('on' + type, handler);
}
}

function addListener(element, type, handler, once) {
var types = trim(type).split(REGEXP_SPACES);
var originalHandler = handler;
Expand All @@ -237,22 +253,6 @@
}
}

function removeListener(element, type, handler) {
var types = trim(type).split(REGEXP_SPACES);

if (types.length > 1) {
return each(types, function (type) {
removeListener(element, type, handler);
});
}

if (element.removeEventListener) {
element.removeEventListener(type, handler, false);
} else if (element.detachEvent) {
element.detachEvent('on' + type, handler);
}
}

function dispatchEvent(element, type, data) {
var event;

Expand Down

0 comments on commit af85df2

Please sign in to comment.