diff --git a/dist/ReactCrop.js b/dist/ReactCrop.js index 9419aa8..01637d4 100644 --- a/dist/ReactCrop.js +++ b/dist/ReactCrop.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactCrop=t(require("react")):e.ReactCrop=t(e.react)}(this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=e.getBoundingClientRect(),r=document.documentElement;return{top:t.top+window.pageYOffset-r.clientTop,left:t.left+window.pageXOffset-r.clientLeft}}function c(e){var t=void 0,r=void 0;return e.touches?(t=e.touches[0].pageX,r=e.touches[0].pageY):(t=e.pageX,r=e.pageY),{x:t,y:r}}function d(e,t,r){return Math.min(Math.max(e,t),r)}function u(e){return e&&e.width&&e.height}function h(e){var t=void 0;return"n"===e?t="s":"ne"===e?t="sw":"e"===e?t="w":"se"===e?t="nw":"s"===e?t="n":"sw"===e?t="ne":"w"===e?t="e":"nw"===e&&(t="se"),t}function p(e,t){var r=l({},e);return e.width?r.height=e.width/e.aspect*t:e.height&&(r.width=e.height*e.aspect/t),e.y+e.height>100&&(r.height=100-e.y,r.width=e.height*e.aspect/t),e.x+e.width>100&&(r.width=100-e.x,r.height=e.width/e.aspect*t),r}var f=function(){function e(e,t){for(var r=0;r100?(i.width=e.width+(100-(e.x+e.width)),s=e.x+(100-(e.x+i.width)),d=!0):s<0&&(i.width=e.x+e.width,s=0,d=!0),d&&e.aspect&&(i.height=i.width/e.aspect*a,c100?(i.height=e.height+(100-(e.y+e.height)),c=e.y+(100-(e.y+i.height)),u=!0):c<0&&(i.height=e.y+e.height,c=0,u=!0),u&&e.aspect&&(i.width=i.height*e.aspect/a,s-1?(r.x=s,r.y=c,r.width=i.width,r.height=i.height):t.xOrds.indexOf(n)>-1?(r.x=s,r.width=i.width):t.yOrds.indexOf(n)>-1&&(r.y=c,r.height=i.height),o.lastYCrossover=o.yCrossOver,this.crossOverCheck(),r}},{key:"straightenYPath",value:function(e){var t=this.evData,r=t.ord,o=t.cropOffset,n=t.cropStartWidth/100*this.imageRef.width,a=t.cropStartHeight/100*this.imageRef.height,i=void 0,s=void 0;return"nw"===r||"se"===r?(i=a/n,s=o.top-o.left*i):(i=-a/n,s=o.top+(a-o.left*i)),i*e+s}},{key:"createCropSelection",value:function(){var e=this,t=this.props.disabled,r=this.getCropStyle();return g.default.createElement("div",{ref:function(t){e.cropSelectRef=t},style:r,className:"ReactCrop__crop-selection",onMouseDown:this.onCropMouseTouchDown,onTouchStart:this.onCropMouseTouchDown},!t&&g.default.createElement("div",{className:"ReactCrop__drag-elements"},g.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),g.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),g.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),g.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w"})))}},{key:"makeNewCrop",value:function(){return l({},t.defaultCrop,this.props.crop)}},{key:"crossOverCheck",value:function(){var e=this.evData;(!e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc>=0||e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc<=0)&&(e.xCrossOver=!e.xCrossOver),(!e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc>=0||e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc<=0)&&(e.yCrossOver=!e.yCrossOver);var t=e.xCrossOver!==e.startXCrossOver,r=e.yCrossOver!==e.startYCrossOver;e.inversedXOrd=!!t&&h(e.ord),e.inversedYOrd=!!r&&h(e.ord)}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,o=t.crossorigin,n=t.crop,a=t.disabled,i=t.imageAlt,s=t.src,c=this.state.cropIsActive,d=void 0;u(n)&&(d=this.createCropSelection());var h=["ReactCrop"];return c&&h.push("ReactCrop--active"),n&&(n.aspect&&h.push("ReactCrop--fixed-aspect"),!c||n.width&&n.height||h.push("ReactCrop--crop-invisible")),a&&h.push("ReactCrop--disabled"),g.default.createElement("div",{ref:function(t){e.componentRef=t},className:h.join(" "),onTouchStart:this.onComponentMouseTouchDown,onMouseDown:this.onComponentMouseTouchDown,tabIndex:"1",onKeyDown:this.onComponentKeyDown},g.default.createElement("img",{ref:function(t){e.imageRef=t},crossOrigin:o,className:"ReactCrop__image",src:s,onLoad:function(t){return e.onImageLoad(t.target)},alt:i}),d,r)}}]),t}(v.PureComponent);w.xOrds=["e","w"],w.yOrds=["n","s"],w.xyOrds=["nw","ne","se","sw"],w.arrowKey={left:37,up:38,right:39,down:40},w.nudgeStep=.2,w.defaultCrop={x:0,y:0,width:0,height:0},w.propTypes={src:y.default.string.isRequired,crop:y.default.shape({aspect:y.default.number,x:y.default.number,y:y.default.number,width:y.default.number,height:y.default.number}),imageAlt:y.default.string,minWidth:y.default.number,minHeight:y.default.number,maxWidth:y.default.number,maxHeight:y.default.number,keepSelection:y.default.bool,onChange:y.default.func.isRequired,onComplete:y.default.func,onImageLoaded:y.default.func,onDragStart:y.default.func,onDragEnd:y.default.func,disabled:y.default.bool,crossorigin:y.default.string,children:y.default.oneOfType([y.default.arrayOf(y.default.node),y.default.node])},w.defaultProps={crop:void 0,crossorigin:void 0,disabled:!1,imageAlt:"",maxWidth:100,maxHeight:100,minWidth:0,minHeight:0,keepSelection:!1,onComplete:function(){},onImageLoaded:function(){},onDragStart:function(){},onDragEnd:function(){},children:void 0},e.exports=w,e.exports.makeAspectCrop=p},function(t,r){t.exports=e},function(e,t,r){e.exports=r(3)()},function(e,t,r){"use strict";var o=r(4),n=r(5),a=r(6);e.exports=function(){function e(e,t,r,o,i,s){s!==a&&n(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=o,r.PropTypes=r,r}},function(e,t,r){"use strict";function o(e){return function(){return e}}var n=function(){};n.thatReturns=o,n.thatReturnsFalse=o(!1),n.thatReturnsTrue=o(!0),n.thatReturnsNull=o(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(e){return e},e.exports=n},function(e,t,r){"use strict";function o(e,t,r,o,a,i,s,c){if(n(t),!e){var d;if(void 0===t)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,o,a,i,s,c],h=0;d=new Error(t.replace(/%s/g,function(){return u[h++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}}var n=function(e){};e.exports=o},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactCrop=t(require("react")):e.ReactCrop=t(e.React)}(this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=e.getBoundingClientRect(),r=document.documentElement;return{top:t.top+window.pageYOffset-r.clientTop,left:t.left+window.pageXOffset-r.clientLeft}}function c(e){var t=void 0,r=void 0;return e.touches?(t=e.touches[0].pageX,r=e.touches[0].pageY):(t=e.pageX,r=e.pageY),{x:t,y:r}}function d(e,t,r){return Math.min(Math.max(e,t),r)}function u(e){return e&&e.width&&e.height}function h(e){var t=void 0;return"n"===e?t="s":"ne"===e?t="sw":"e"===e?t="w":"se"===e?t="nw":"s"===e?t="n":"sw"===e?t="ne":"w"===e?t="e":"nw"===e&&(t="se"),t}function p(e,t){var r=l({},e);return e.width?r.height=e.width/e.aspect*t:e.height&&(r.width=e.height*e.aspect/t),e.y+e.height>100&&(r.height=100-e.y,r.width=e.height*e.aspect/t),e.x+e.width>100&&(r.width=100-e.x,r.height=e.width/e.aspect*t),r}var f=function(){function e(e,t){for(var r=0;r100?(i.width=e.width+(100-(e.x+e.width)),s=e.x+(100-(e.x+i.width)),d=!0):s<0&&(i.width=e.x+e.width,s=0,d=!0),d&&e.aspect&&(i.height=i.width/e.aspect*a,c100?(i.height=e.height+(100-(e.y+e.height)),c=e.y+(100-(e.y+i.height)),u=!0):c<0&&(i.height=e.y+e.height,c=0,u=!0),u&&e.aspect&&(i.width=i.height*e.aspect/a,s-1?(r.x=s,r.y=c,r.width=i.width,r.height=i.height):t.xOrds.indexOf(n)>-1?(r.x=s,r.width=i.width):t.yOrds.indexOf(n)>-1&&(r.y=c,r.height=i.height),o.lastYCrossover=o.yCrossOver,this.crossOverCheck(),r}},{key:"straightenYPath",value:function(e){var t=this.evData,r=t.ord,o=t.cropOffset,n=t.cropStartWidth/100*this.imageRef.width,a=t.cropStartHeight/100*this.imageRef.height,i=void 0,s=void 0;return"nw"===r||"se"===r?(i=a/n,s=o.top-o.left*i):(i=-a/n,s=o.top+(a-o.left*i)),i*e+s}},{key:"createCropSelection",value:function(){var e=this,t=this.props.disabled,r=this.getCropStyle();return g.default.createElement("div",{ref:function(t){e.cropSelectRef=t},style:r,className:"ReactCrop__crop-selection",onMouseDown:this.onCropMouseTouchDown,onTouchStart:this.onCropMouseTouchDown},!t&&g.default.createElement("div",{className:"ReactCrop__drag-elements"},g.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),g.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),g.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),g.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw"}),g.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w"})))}},{key:"makeNewCrop",value:function(){return l({},t.defaultCrop,this.props.crop)}},{key:"crossOverCheck",value:function(){var e=this.evData;(!e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc>=0||e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc<=0)&&(e.xCrossOver=!e.xCrossOver),(!e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc>=0||e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc<=0)&&(e.yCrossOver=!e.yCrossOver);var t=e.xCrossOver!==e.startXCrossOver,r=e.yCrossOver!==e.startYCrossOver;e.inversedXOrd=!!t&&h(e.ord),e.inversedYOrd=!!r&&h(e.ord)}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,o=t.crossorigin,n=t.crop,a=t.disabled,i=t.imageAlt,s=t.src,c=this.state.cropIsActive,d=void 0;u(n)&&(d=this.createCropSelection());var h=["ReactCrop"];return c&&h.push("ReactCrop--active"),n&&(n.aspect&&h.push("ReactCrop--fixed-aspect"),!c||n.width&&n.height||h.push("ReactCrop--crop-invisible")),a&&h.push("ReactCrop--disabled"),g.default.createElement("div",{ref:function(t){e.componentRef=t},className:h.join(" "),onTouchStart:this.onComponentMouseTouchDown,onMouseDown:this.onComponentMouseTouchDown,tabIndex:"1",onKeyDown:this.onComponentKeyDown},g.default.createElement("img",{ref:function(t){e.imageRef=t},crossOrigin:o,className:"ReactCrop__image",src:s,onLoad:function(t){return e.onImageLoad(t.target)},alt:i}),d,r)}}]),t}(v.PureComponent);w.xOrds=["e","w"],w.yOrds=["n","s"],w.xyOrds=["nw","ne","se","sw"],w.arrowKey={left:37,up:38,right:39,down:40},w.nudgeStep=.2,w.defaultCrop={x:0,y:0,width:0,height:0},w.propTypes={src:y.default.string.isRequired,crop:y.default.shape({aspect:y.default.number,x:y.default.number,y:y.default.number,width:y.default.number,height:y.default.number}),imageAlt:y.default.string,minWidth:y.default.number,minHeight:y.default.number,maxWidth:y.default.number,maxHeight:y.default.number,keepSelection:y.default.bool,onChange:y.default.func.isRequired,onComplete:y.default.func,onImageLoaded:y.default.func,onDragStart:y.default.func,onDragEnd:y.default.func,disabled:y.default.bool,crossorigin:y.default.string,children:y.default.oneOfType([y.default.arrayOf(y.default.node),y.default.node])},w.defaultProps={crop:void 0,crossorigin:void 0,disabled:!1,imageAlt:"",maxWidth:100,maxHeight:100,minWidth:0,minHeight:0,keepSelection:!1,onComplete:function(){},onImageLoaded:function(){},onDragStart:function(){},onDragEnd:function(){},children:void 0},e.exports=w,e.exports.makeAspectCrop=p},function(t,r){t.exports=e},function(e,t,r){e.exports=r(3)()},function(e,t,r){"use strict";var o=r(4),n=r(5),a=r(6);e.exports=function(){function e(e,t,r,o,i,s){s!==a&&n(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=o,r.PropTypes=r,r}},function(e,t,r){"use strict";function o(e){return function(){return e}}var n=function(){};n.thatReturns=o,n.thatReturnsFalse=o(!1),n.thatReturnsTrue=o(!0),n.thatReturnsNull=o(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(e){return e},e.exports=n},function(e,t,r){"use strict";function o(e,t,r,o,a,i,s,c){if(n(t),!e){var d;if(void 0===t)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,o,a,i,s,c],h=0;d=new Error(t.replace(/%s/g,function(){return u[h++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}}var n=function(e){};e.exports=o},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}])}); \ No newline at end of file diff --git a/dist/ReactCrop.min.js b/dist/ReactCrop.min.js index 0a6a0e6..289e668 100644 --- a/dist/ReactCrop.min.js +++ b/dist/ReactCrop.min.js @@ -6,7 +6,7 @@ else if(typeof exports === 'object') exports["ReactCrop"] = factory(require("react")); else - root["ReactCrop"] = factory(root["react"]); + root["ReactCrop"] = factory(root["React"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_6__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache diff --git a/package.json b/package.json index 5044cf9..d62fe61 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-image-crop", - "version": "3.0.4", + "version": "3.0.5", "description": "A responsive image cropping tool for React", "repository": "https://github.com/DominicTobias/react-image-crop", "main": "index.js",