Skip to content

Commit

Permalink
Release v0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Fengyuan Chen committed Dec 28, 2015
1 parent 787a47e commit 5c2a88c
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 28 deletions.
4 changes: 2 additions & 2 deletions dist/cropper.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Cropper v0.5.3
* Cropper v0.5.4
* https://github.com/fengyuanchen/cropperjs
*
* Copyright (c) 2015 Fengyuan Chen
* Released under the MIT license
*
* Date: 2015-12-24T08:55:11.099Z
* Date: 2015-12-28T03:39:33.053Z
*/
.cropper-container {
font-size: 0;
Expand Down
68 changes: 53 additions & 15 deletions dist/cropper.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Cropper v0.5.3
* Cropper v0.5.4
* https://github.com/fengyuanchen/cropperjs
*
* Copyright (c) 2015 Fengyuan Chen
* Released under the MIT license
*
* Date: 2015-12-24T08:55:18.789Z
* Date: 2015-12-28T03:39:49.283Z
*/

(function (global, factory) {
Expand Down Expand Up @@ -101,9 +101,10 @@
var PI = Math.PI;

// Utilities
var EMPTY_OBJECT = {};
var toString = EMPTY_OBJECT.toString;
var hasOwnProperty = EMPTY_OBJECT.hasOwnProperty;
var objectProto = Object.prototype;
var toString = objectProto.toString;
var hasOwnProperty = objectProto.hasOwnProperty;
var slice = Array.prototype.slice;
var fromCharCode = String.fromCharCode;

function typeOf(obj) {
Expand Down Expand Up @@ -149,18 +150,13 @@
}

function toArray(obj, offset) {
var args = [];
offset = offset >= 0 ? offset : 0;

if (Array.from) {
return Array.from(obj).slice(offset || 0);
return Array.from(obj).slice(offset);
}

// This is necessary for IE8
if (isNumber(offset)) {
args.push(offset);
}

return args.slice.apply(obj, args);
return slice.call(obj, offset);
}

function trim(str) {
Expand Down Expand Up @@ -393,6 +389,27 @@
};
}

function getTouchesCenter(touches) {
var length = touches.length;
var pageX = 0;
var pageY = 0;

if (length) {
each(touches, function (touch) {
pageX += touch.pageX;
pageY += touch.pageY;
});

pageX /= length;
pageY /= length;
}

return {
pageX: pageX,
pageY: pageY
};
}

function getByTag(element, tagName, index) {
var elements = element.getElementsByTagName(tagName);

Expand Down Expand Up @@ -2642,6 +2659,8 @@
var naturalHeight = canvasData.naturalHeight;
var newWidth;
var newHeight;
var offset;
var center;

ratio = Number(ratio);

Expand All @@ -2657,8 +2676,27 @@
return _this;
}

canvasData.left -= (newWidth - width) / 2;
canvasData.top -= (newHeight - height) / 2;
if (_originalEvent) {
offset = getOffset(_this.cropper);
center = _originalEvent.touches ? getTouchesCenter(_originalEvent.touches) : {
pageX: _originalEvent.pageX,
pageY: _originalEvent.pageY
};

// Zoom from the triggering point of the event
canvasData.left -= (newWidth - width) * (
((center.pageX - offset.left) - canvasData.left) / width
);
canvasData.top -= (newHeight - height) * (
((center.pageY - offset.top) - canvasData.top) / height
);
} else {

// Zoom from the center of the canvas
canvasData.left -= (newWidth - width) / 2;
canvasData.top -= (newHeight - height) / 2;
}

canvasData.width = newWidth;
canvasData.height = newHeight;
_this.renderCanvas(true);
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 @@ -41,7 +41,7 @@
</div>
<nav class="collapse navbar-collapse" id="navbar-collapse-1" role="navigation">
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/fengyuanchen/cropperjs/tree/v0.5.3/README.md">Docs</a></li>
<li><a href="https://github.com/fengyuanchen/cropperjs/tree/v0.5.4/README.md">Docs</a></li>
<li><a href="https://github.com/fengyuanchen/cropperjs">GitHub</a></li>
<li><a href="http://chenfengyuan.com">About</a></li>
<li><a href="http://fengyuanchen.github.io">More</a></li>
Expand All @@ -53,7 +53,7 @@
<!-- Jumbotron -->
<div class="jumbotron docs-jumbotron">
<div class="container">
<h1>Cropper.js <small class="version">v0.5.3</small></h1>
<h1>Cropper.js <small class="version">v0.5.4</small></h1>
<p class="lead">JavaScript image cropper.</p>
<div class="docs-carbonads-container">
<div class="docs-carbonads">
Expand Down
8 changes: 4 additions & 4 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.5.3",
"version": "0.5.4",
"main": "dist/cropper.js",
"license": "MIT",
"repository": "fengyuanchen/cropperjs",
Expand Down Expand Up @@ -31,10 +31,10 @@
"devDependencies": {
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-concat": "~2.6.0",
"gulp-concat": "^2.6.0",
"gulp-csscomb": "^3.0.6",
"gulp-csslint": "^0.2.0",
"gulp-htmlcomb": "0.1.0",
"gulp-htmlcomb": "^0.1.0",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^1.12.0",
"gulp-load-plugins": "^1.1.0",
Expand All @@ -43,7 +43,7 @@
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-sass": "^2.1.1",
"gulp-sourcemaps": "~1.6.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.5.1"
}
}

0 comments on commit 5c2a88c

Please sign in to comment.