diff --git a/.babelrc b/.babelrc index a07f0f9..710e4e5 100644 --- a/.babelrc +++ b/.babelrc @@ -5,10 +5,15 @@ "react" ], "env": { - "development": { - "sourceMaps": "inline" + "commonjs": { + "plugins": [ + ["transform-es2015-modules-commonjs", { "loose": true }] + ] }, - "production": { + "es": { + "plugins": [ + "./build/use-lodash-es" + ] } } } diff --git a/README.md b/README.md index 679c6d3..e910863 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ alt="File size" /> -Lightweight pure JavaScript image crop library. [Plays nicely with React](http://webseed.github.io/crop/examples/react). +Lightweight pure JavaScript image crop library. [Plays nicely with React](http://webseed.github.io/crop/react-example). ## Install diff --git a/dist/.keep b/dist/.keep new file mode 100644 index 0000000..e69de29 diff --git a/dist/tinycrop.js b/dist/tinycrop.js index e8a21b7..bec7ea3 100644 --- a/dist/tinycrop.js +++ b/dist/tinycrop.js @@ -1,1316 +1,1644 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.tinycrop = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { - var h = parent.height; - - var cols = 32; - var size = parent.width / cols; - var rows = Math.ceil(h / size); - - g.fillStyle = this.colors[1]; - for (var i = 0; i < cols; i += 1) { - for (var j = 0; j < rows; j += 1) { - if ((i + j) % 2 === 0) { - g.fillRect(i * size, j * size, size, size); - } - } - } - } - - this.isDirty = false; - } -}; - -module.exports = BackgroundLayer; - -},{}],2:[function(require,module,exports){ -'use strict'; - -var loaded = require('./loadImage.js'); -var Listeners = require('./Listeners.js'); - -var Image = function Image(source) { - this.width = 0; - this.height = 0; - - this.hasLoaded = false; - this.src = null; - - this.listeners = Listeners.create(); - - if (!source) { - return; - } - - if (typeof source === 'string') { - this.src = source; - var img = document.createElement('img'); - img.src = this.src; - source = img; - } else { - this.src = source.src; - } - - this.source = source; - - loaded(source, function (err) { - if (err) { - this.notify('error', err); - } else { - this.hasLoaded = true; - this.width = source.naturalWidth; - this.height = source.naturalHeight; - this.notify('load', this); - } - }.bind(this)); -}; - -Image.create = function (source) { - return new Image(source); -}; - -Image.prototype.getAspectRatio = function () { - if (!this.hasLoaded) { - return 1; - } - - return this.width / this.height; -}; - -Image.prototype.notify = function (type, data) { - var listeners = this.listeners; - setTimeout(function () { - listeners.notify(type, data); - }, 0); -}; - -Image.prototype.on = function (type, fn) { - this.listeners.on(type, fn); - return this; -}; - -Image.prototype.off = function (type, fn) { - this.listeners.off(type, fn); - return this; -}; - -module.exports = Image; - -},{"./Listeners.js":5,"./loadImage.js":11}],3:[function(require,module,exports){ -'use strict'; - -var Rectangle = require('./Rectangle.js'); - -var ImageLayer = function ImageLayer(opts) { - opts = opts || {}; - this.bounds = Rectangle.create(0, 0, 0, 0); - this.image = opts.image || null; - this.parent = opts.parent; - this.context = opts.context; -}; - -ImageLayer.create = function (opts) { - return new ImageLayer(opts); -}; - -ImageLayer.prototype.setImage = function (image) { - this.image = image; -}; - -ImageLayer.prototype.revalidate = function () { - var parent = this.parent; - var image = this.image; - var bounds = this.bounds; - - if (image) { - // Constrained by width (otherwise height) - if (image.width / image.height >= parent.width / parent.height) { - bounds.width = parent.width; - bounds.height = Math.ceil(image.height / image.width * parent.width); - bounds.x = 0; - bounds.y = Math.floor((parent.height - bounds.height) * 0.5); - } else { - bounds.width = Math.ceil(image.width / image.height * parent.height); - bounds.height = parent.height; - bounds.x = Math.floor((parent.width - bounds.width) * 0.5); - bounds.y = 0; - } - } -}; - -ImageLayer.prototype.paint = function () { - var g = this.context; - var image = this.image; - var bounds = this.bounds; - - if (image && image.hasLoaded) { - g.drawImage(image.source, 0, 0, image.width, image.height, bounds.x, bounds.y, bounds.width, bounds.height); - } -}; - -module.exports = ImageLayer; - -},{"./Rectangle.js":6}],4:[function(require,module,exports){ -'use strict'; - -var Listeners = require('./Listeners.js'); - -var Input = function Input(domElement) { - var listeners = Listeners.create(); - var downEvent = null; - this.listeners = listeners; - - function createEventForMouse(source) { - var x = source.offsetX; - var y = source.offsetY; - - return { - source: source, - x: x, - y: y, - dx: downEvent ? x - downEvent.x : 0, - dy: downEvent ? y - downEvent.y : 0, - type: 'Mouse' - }; - } - - function createEventForTouch(source) { - var bounds = source.target.getBoundingClientRect(); - var touch = source.touches.length > 0 ? source.touches[0] : source.changedTouches[0]; - - var x = touch.clientX - bounds.left; - var y = touch.clientY - bounds.top; - - return { - source: source, - x: x, - y: y, - dx: downEvent ? x - downEvent.x : 0, - dy: downEvent ? y - downEvent.y : 0, - type: 'Touch' - }; - } - - domElement.addEventListener('mousedown', function (source) { - downEvent = createEventForMouse(source); - listeners.notify('down', downEvent); - }); - - domElement.addEventListener('touchstart', function (source) { - downEvent = createEventForTouch(source); - listeners.notify('down', downEvent); - }); - - domElement.addEventListener('mousemove', function (source) { - listeners.notify('move', createEventForMouse(source)); - }); - - domElement.addEventListener('touchmove', function (source) { - listeners.notify('move', createEventForTouch(source)); - }); - - domElement.addEventListener('mouseup', function (source) { - listeners.notify('up', createEventForMouse(source)); - }); - - domElement.addEventListener('touchend', function (source) { - listeners.notify('up', createEventForTouch(source)); - downEvent = null; - }); - - domElement.addEventListener('mouseout', function (source) { - listeners.notify('cancel', createEventForMouse(source)); - downEvent = null; - }); - - domElement.addEventListener('touchcancel', function (source) { - listeners.notify('cancel', createEventForTouch(source)); - downEvent = null; - }); -}; - -Input.create = function (domElement) { - return new Input(domElement); -}; - -Input.prototype.on = function (type, fn) { - this.listeners.on(type, fn); - return this; -}; - -Input.prototype.off = function (type, fn) { - this.listeners.off(type, fn); - return this; -}; - -module.exports = Input; - -},{"./Listeners.js":5}],5:[function(require,module,exports){ -"use strict"; - -var Listeners = function Listeners(opts) { - this.events = {}; -}; - -Listeners.create = function (opts) { - return new Listeners(opts); -}; - -Listeners.prototype.on = function (type, fn) { - if (!this.events[type]) { - this.events[type] = []; - } - - if (this.events[type].indexOf(fn) === -1) { - this.events[type].push(fn); - } - - return this; -}; - -Listeners.prototype.off = function (type, fn) { - if (this.events[type]) { - var i = this.events[type].indexOf(fn); - if (i !== -1) { - this.events[type].splice(i, 1); - } - } - - return this; -}; - -Listeners.prototype.notify = function (type, data) { - if (this.events[type]) { - this.events[type].forEach(function (fn) { - fn.call(this, data); - }.bind(this)); - } -}; - -Listeners.prototype.clearAll = function () { - this.events = {}; -}; - -module.exports = Listeners; - -},{}],6:[function(require,module,exports){ -"use strict"; - -var Rectangle = function Rectangle(x, y, width, height) { - this._x = x; - this._y = y; - this._width = width; - this._height = height; -}; - -Rectangle.prototype.copy = function (copy) { - this._x = copy.x; - this._y = copy.y; - this._width = copy.width; - this._height = copy.height; - return this; -}; - -Rectangle.prototype.clone = function () { - return Rectangle.create(this._x, this._y, this._width, this._height); -}; - -Rectangle.prototype.round = function () { - var dx = this._x; - var dy = this._y; - this._x = Math.round(dx); - this._y = Math.round(dy); - dx -= this._x; - dy -= this._y; - this._width = Math.round(this._width + dx); - this._height = Math.round(this._height + dy); - return this; -}; - -Rectangle.prototype.isInside = function (point) { - return point.x >= this.left && point.y >= this.top && point.x < this.right && point.y < this.bottom; -}; - -Object.defineProperties(Rectangle.prototype, { - x: { - get: function get() { - return this._x; - }, - set: function set(v) { - this._x = v; - } - }, - y: { - get: function get() { - return this._y; - }, - set: function set(v) { - this._y = v; - } - }, - centerX: { - get: function get() { - return this._x + this._width * 0.5; - }, - set: function set(v) { - this._x = v - this._width * 0.5; - } - }, - centerY: { - get: function get() { - return this._y + this._height * 0.5; - }, - set: function set(v) { - this._y = v - this._height * 0.5; - } - }, - width: { - get: function get() { - return this._width; - }, - set: function set(v) { - this._width = v; - } - }, - height: { - get: function get() { - return this._height; - }, - set: function set(v) { - this._height = v; - } - }, - left: { - get: function get() { - return this._x; - }, - set: function set(v) { - this._width = this._x + this._width - v; - this._x = v; - } - }, - top: { - get: function get() { - return this._y; - }, - set: function set(v) { - this._height = this._y + this._height - v; - this._y = v; - } - }, - right: { - get: function get() { - return this._x + this._width; - }, - set: function set(v) { - this._width = v - this._x; - } - }, - bottom: { - get: function get() { - return this._y + this._height; - }, - set: function set(v) { - this._height = v - this._y; - } - }, - aspectRatio: { - get: function get() { - return this._width / this._height; - } - } -}); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["tinycrop"] = factory(); + else + root["tinycrop"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; -Rectangle.create = function (x, y, width, height) { - return new Rectangle(x, y, width, height); -}; - -module.exports = Rectangle; - -},{}],7:[function(require,module,exports){ -'use strict'; - -var Rectangle = require('./Rectangle.js'); - -var Selection = function Selection(opts) { - this.target = opts.target || null; - this.bounds = Rectangle.create(0, 0, 0, 0); - this.boundsPx = Rectangle.create(0, 0, 0, 0); - this.region = Rectangle.create(0, 0, 0, 0); - - this.initialOpts = { - x: opts.x, - y: opts.y, - width: opts.width, - height: opts.height - }; - - this.aspectRatio = opts.aspectRatio; - this.minWidth = opts.minWidth !== undefined ? opts.minWidth : 100; - this.minHeight = opts.minHeight !== undefined ? opts.minHeight : 100; - - this.boundsMinWidth = 0; - this.boundsMinHeight = 0; - - this._delta = { x: 0, h: 0 }; -}; - -Object.defineProperties(Selection.prototype, { - x: { - get: function get() { - return this.bounds.x; - }, - set: function set(v) { - this.bounds.x = v; - } - }, - y: { - get: function get() { - return this.bounds.y; - }, - set: function set(v) { - this.bounds.y = v; - } - }, - width: { - get: function get() { - return this.bounds.width; - }, - set: function set(v) { - this.bounds.width = v; - } - }, - height: { - get: function get() { - return this.bounds.height; - }, - set: function set(v) { - this.bounds.height = v; - } - }, - left: { - get: function get() { - return this.bounds.x; - }, - set: function set(v) { - this.bounds.left = v; - } - }, - top: { - get: function get() { - return this.bounds.y; - }, - set: function set(v) { - this.bounds.top = v; - } - }, - right: { - get: function get() { - return this.bounds.right; - }, - set: function set(v) { - this.bounds.right = v; - } - }, - bottom: { - get: function get() { - return this.bounds.bottom; - }, - set: function set(v) { - this.bounds.bottom = v; - } - } -}); +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -Selection.prototype.getBoundsLengthForRegion = function (regionLen) { - return regionLen / this.region.width * this.width; -}; - -Selection.prototype.moveBy = function (dx, dy) { - var bounds = this.bounds; - var target = this.target; - - bounds.x = Math.min(Math.max(bounds.x + dx, target.bounds.x), target.bounds.x + target.bounds.width - bounds.width); - bounds.y = Math.min(Math.max(bounds.y + dy, target.bounds.y), target.bounds.y + target.bounds.height - bounds.height); - - return this.updateRegionFromBounds(); -}; - -Selection.prototype.resizeBy = function (dx, dy, p) { - var delta = this._delta; - var aspectRatio = this.aspectRatio; - var bounds = this.bounds; - var boundsMinWidth = this.boundsMinWidth; - var boundsMinHeight = this.boundsMinHeight; - var target = this.target; - - function calculateDelta(x, y) { - delta.width = bounds.width + x; - delta.height = bounds.height + y; - - delta.width = Math.max(boundsMinWidth, delta.width); - delta.height = Math.max(boundsMinHeight, delta.height); - - if (aspectRatio) { - if (delta.width / delta.height > aspectRatio) { - delta.width = delta.height * aspectRatio; - } else { - delta.height = delta.width / aspectRatio; - } - } - - delta.width -= bounds.width; - delta.height -= bounds.height; - - return delta; - } - - if (p[0] === 'n') { - dy = Math.min(dy, this.top - target.bounds.top); - } else if (p[0] === 's') { - dy = Math.min(dy, target.bounds.bottom - this.bottom); - } - - if (p[1] === 'w') { - dx = Math.min(dx, this.left - target.bounds.left); - } else if (p[1] === 'e') { - dx = Math.min(dx, target.bounds.right - this.right); - } - - delta = calculateDelta(dx, dy); - - switch (p) { - case 'nw': - this.left -= delta.width; - this.top -= delta.height; - break; - case 'ne': - this.right += delta.width; - this.top -= delta.height; - break; - case 'sw': - this.left -= delta.width; - this.bottom += delta.height; - break; - case 'se': - this.right += delta.width; - this.bottom += delta.height; - break; - } - - return this.updateRegionFromBounds(); -}; - -Selection.prototype.autoSizeRegion = function () { - var target = this.target; - var region = this.region; - var aspectRatio = this.aspectRatio; - var initialOpts = this.initialOpts; - var beforeX = region.x; - var beforeY = region.y; - var beforeWidth = region.width; - var beforeHeight = region.height; - - region.x = initialOpts.x !== undefined ? initialOpts.x : 0; - region.y = initialOpts.y !== undefined ? initialOpts.y : 0; - - region.width = initialOpts.width !== undefined ? initialOpts.width : target.image.width; - region.height = initialOpts.height !== undefined ? initialOpts.height : target.image.height; - - if (aspectRatio) { - if (region.width / region.height > aspectRatio) { - region.width = region.height * aspectRatio; - } else { - region.height = region.width / aspectRatio; - } - } - - if (initialOpts.x === undefined) { - region.centerX = target.image.width * 0.5; - } - - if (initialOpts.y === undefined) { - region.centerY = target.image.height * 0.5; - } - - region.round(); - - this.updateBoundsFromRegion(); - - return region.x !== beforeX || region.y !== beforeY || region.width !== beforeWidth || region.height !== beforeHeight; -}; - -Selection.prototype.updateRegionFromBounds = function () { - var target = this.target; - var region = this.region; - var bounds = this.bounds; - var beforeX = region.x; - var beforeY = region.y; - var beforeWidth = region.width; - var beforeHeight = region.height; - - region.x = target.image.width * (bounds.x - target.bounds.x) / target.bounds.width; - region.y = target.image.height * (bounds.y - target.bounds.y) / target.bounds.height; - - region.width = target.image.width * (bounds.width / target.bounds.width); - region.height = target.image.height * (bounds.height / target.bounds.height); - - region.round(); - - return region.x !== beforeX || region.y !== beforeY || region.width !== beforeWidth || region.height !== beforeHeight; -}; - -Selection.prototype.updateBoundsFromRegion = function () { - var target = this.target; - var region = this.region; - var bounds = this.bounds; - - if (target.image) { - bounds.x = target.bounds.x + target.bounds.width * (region.x / target.image.width); - bounds.y = target.bounds.y + target.bounds.height * (region.y / target.image.height); - bounds.width = target.bounds.width * (region.width / target.image.width); - bounds.height = target.bounds.height * (region.height / target.image.height); - } - - this.boundsMinWidth = this.getBoundsLengthForRegion(this.minWidth); - this.boundsMinHeight = this.getBoundsLengthForRegion(this.minHeight); -}; - -Selection.prototype.isInside = function (point) { - return this.bounds.isInside(point); -}; - -Selection.create = function (opts) { - return new Selection(opts); -}; - -module.exports = Selection; - -},{"./Rectangle.js":6}],8:[function(require,module,exports){ -'use strict'; - -var Input = require('./Input.js'); -var Listeners = require('./Listeners.js'); -var Selection = require('./Selection.js'); -var Rectangle = require('./Rectangle.js'); - -var SelectionLayer = function SelectionLayer(opts) { - opts = opts || {}; - - this.selection = Selection.create(opts); - - this.parent = opts.parent; - this.context = opts.context; - this.context.setLineDash = this.context.setLineDash || function () {}; - this.target = opts.target; - - var handleOpts = opts.handle || {}; - handleOpts.length = handleOpts.handleLength || 32; - handleOpts.depth = handleOpts.depth || 3; - handleOpts.size = handleOpts.size || handleOpts.length * 2; - handleOpts.color = handleOpts.color || 'rgba(255, 255, 255, 1.0)'; - handleOpts.activeColor = handleOpts.activeColor || 'rgba(255, 0, 160, 1.0)'; - this.handleOpts = handleOpts; - - this.listeners = Listeners.create(); - - this.input = Input.create(this.parent.canvas); - - this.activeRegion = null; - this.downBounds = Rectangle.create(0, 0, 0, 0); - - this.input.on('down', this.onInputDown.bind(this)); - this.input.on('move', this.onInputMove.bind(this)); - this.input.on('up', this.onInputUpOrCancel.bind(this)).on('cancel', this.onInputUpOrCancel.bind(this)); -}; - -SelectionLayer.create = function (opts) { - return new SelectionLayer(opts); -}; - -SelectionLayer.prototype.onInputDown = function (e) { - var hitRegion = this.findHitRegion(e); - - if (hitRegion) { - e.source.preventDefault(); - this.activeRegion = hitRegion; - this.setCursor(hitRegion); - this.downBounds.copy(this.selection.bounds); - this.listeners.notify('start', this.selection.region); - } -}; - -SelectionLayer.prototype.onInputMove = function (e) { - var activeRegion = this.activeRegion; - - if (!activeRegion) { - var hitRegion = this.findHitRegion(e); - if (hitRegion) { - e.source.preventDefault(); - this.setCursor(hitRegion); - } else { - this.resetCursor(); - } - } else { - e.source.preventDefault(); - - var selection = this.selection; - var hasChanged = false; - selection.bounds.copy(this.downBounds); - - if (activeRegion === 'move') { - hasChanged = selection.moveBy(e.dx, e.dy); - if (hasChanged) { - this.listeners.notify('move', this.selection.region); - } - } else { - var dir = activeRegion.substring(0, 2); - var dx = dir[1] === 'w' ? -e.dx : e.dx; - var dy = dir[0] === 'n' ? -e.dy : e.dy; - hasChanged = selection.resizeBy(dx, dy, dir); - if (hasChanged) { - this.listeners.notify('resize', this.selection.region); - } - } - - if (hasChanged) { - this.listeners.notify('change', this.selection.region); - } - } -}; - -SelectionLayer.prototype.onInputUpOrCancel = function (e) { - e.source.preventDefault(); - if (this.activeRegion) { - this.activeRegion = null; - this.resetCursor(); - this.listeners.notify('end', this.selection.region); - } -}; - -SelectionLayer.prototype.findHitRegion = function (point) { - var hitRegion = null; - var closest = Number.MAX_VALUE; - - var d = this.isWithinNorthWestHandle(point); - if (d !== false && d < closest) { - closest = d; - hitRegion = 'nw-resize'; - } - - d = this.isWithinNorthEastHandle(point); - if (d !== false && d < closest) { - closest = d; - hitRegion = 'ne-resize'; - } - - d = this.isWithinSouthWestHandle(point); - if (d !== false && d < closest) { - closest = d; - hitRegion = 'sw-resize'; - } - - d = this.isWithinSouthEastHandle(point); - if (d !== false && d < closest) { - closest = d; - hitRegion = 'se-resize'; - } - - if (hitRegion) { - return hitRegion; - } else if (this.isWithinBounds(point)) { - return 'move'; - } else { - return null; - } -}; - -SelectionLayer.prototype.on = function (type, fn) { - this.listeners.on(type, fn); - return this; -}; - -SelectionLayer.prototype.off = function (type, fn) { - this.listeners.off(type, fn); - return this; -}; - -SelectionLayer.prototype.setCursor = function (type) { - if (this.parent.canvas.style.cursor !== type) { - this.parent.canvas.style.cursor = type; - } -}; - -SelectionLayer.prototype.resetCursor = function () { - this.setCursor('auto'); -}; - -SelectionLayer.prototype.isWithinRadius = function (ax, ay, bx, by, r) { - var tsq = r * r; - var dx = ax - bx; - var dy = ay - by; - var dsq = dx * dx + dy * dy; - return dsq < tsq ? dsq : false; -}; - -SelectionLayer.prototype.isWithinNorthWestHandle = function (point) { - return this.isWithinRadius(point.x, point.y, this.selection.left, this.selection.top, this.getHandleRadius()); -}; - -SelectionLayer.prototype.isWithinNorthEastHandle = function (point) { - return this.isWithinRadius(point.x, point.y, this.selection.right, this.selection.top, this.getHandleRadius()); -}; - -SelectionLayer.prototype.isWithinSouthWestHandle = function (point) { - return this.isWithinRadius(point.x, point.y, this.selection.left, this.selection.bottom, this.getHandleRadius()); -}; - -SelectionLayer.prototype.isWithinSouthEastHandle = function (point) { - return this.isWithinRadius(point.x, point.y, this.selection.right, this.selection.bottom, this.getHandleRadius()); -}; - -SelectionLayer.prototype.isWithinBounds = function (point) { - return this.selection.isInside(point); -}; - -SelectionLayer.prototype.getHandleRadius = function () { - return this.handleOpts.size / 2; -}; - -SelectionLayer.prototype.onImageLoad = function () { - this.autoSizeRegionAndNotify(); -}; - -SelectionLayer.prototype.setAspectRatio = function (aspectRatio) { - this.selection.aspectRatio = aspectRatio; - this.autoSizeRegionAndNotify(); -}; - -SelectionLayer.prototype.autoSizeRegionAndNotify = function () { - var hasChanged = this.selection.autoSizeRegion(); - if (hasChanged) { - this.listeners.notify('change', this.selection.region); - } -}; - -SelectionLayer.prototype.revalidate = function () { - this.selection.updateBoundsFromRegion(); -}; - -SelectionLayer.prototype.paint = function () { - this.selection.boundsPx.copy(this.selection.bounds).round(); - - this.paintOutside(); - this.paintInside(); -}; - -SelectionLayer.prototype.paintOutside = function () { - var bounds = this.selection.boundsPx; - var g = this.context; - var target = this.target; - - var tl = target.bounds.x; - var tt = target.bounds.y; - var tw = target.bounds.width; - var tr = target.bounds.right; - var tb = target.bounds.bottom; - - var bl = bounds.x; - var bt = bounds.y; - var bh = bounds.height; - var br = bounds.right; - var bb = bounds.bottom; - - g.fillStyle = 'rgba(0, 0, 0, 0.5)'; - g.fillRect(tl, tt, tw, bt - tt); - g.fillRect(tl, bt, bl - tl, bh); - g.fillRect(br, bt, tr - br, bh); - g.fillRect(tl, bb, tw, tb - bb); -}; - -SelectionLayer.prototype.paintInside = function () { - var g = this.context; - var bounds = this.selection.boundsPx; - var activeRegion = this.activeRegion; - var opts = this.handleOpts; - - var lengthWidth = Math.min(opts.length, bounds.width * 0.5); - var lengthHeight = Math.min(opts.length, bounds.height * 0.5); - var depth = opts.depth; - var color = opts.color; - var activeColor = opts.activeColor; - var length = 0; // TODO: CHECK - - // Sides - g.fillStyle = 'rgba(255, 255, 255, 0.3)'; - g.fillRect(bounds.x + length, bounds.y, bounds.width - 2 * length, depth); - g.fillRect(bounds.x + length, bounds.bottom - depth, bounds.width - 2 * length, depth); - g.fillRect(bounds.x, bounds.y + length, depth, bounds.height - 2 * length); - g.fillRect(bounds.right - depth, bounds.y + length, depth, bounds.height - 2 * length); - - // Handles - var isMoveRegion = activeRegion === 'move'; - - g.fillStyle = isMoveRegion || activeRegion === 'nw-resize' ? activeColor : color; - g.fillRect(bounds.x, bounds.y, lengthWidth, depth); - g.fillRect(bounds.x, bounds.y + depth, depth, lengthHeight - depth); - - g.fillStyle = isMoveRegion || activeRegion === 'ne-resize' ? activeColor : color; - g.fillRect(bounds.right - lengthWidth, bounds.y, lengthWidth, depth); - g.fillRect(bounds.right - depth, bounds.y + depth, depth, lengthHeight - depth); - - g.fillStyle = isMoveRegion || activeRegion === 'sw-resize' ? activeColor : color; - g.fillRect(bounds.x, bounds.bottom - depth, lengthWidth, depth); - g.fillRect(bounds.x, bounds.bottom - lengthHeight, depth, lengthHeight - depth); - - g.fillStyle = isMoveRegion || activeRegion === 'se-resize' ? activeColor : color; - g.fillRect(bounds.right - lengthWidth, bounds.bottom - depth, lengthWidth, depth); - g.fillRect(bounds.right - depth, bounds.bottom - lengthHeight, depth, lengthHeight - depth); - - // Guides - g.strokeStyle = 'rgba(255, 255, 255, 0.6)'; - g.setLineDash([2, 3]); - g.lineWidth = 1; - g.beginPath(); - var bw3 = bounds.width / 3; - var bh3 = bounds.height / 3; - g.moveTo(bounds.x + bw3, bounds.y); - g.lineTo(bounds.x + bw3, bounds.y + bounds.height); - g.moveTo(bounds.x + 2 * bw3, bounds.y); - g.lineTo(bounds.x + 2 * bw3, bounds.y + bounds.height); - g.moveTo(bounds.x, bounds.y + bh3); - g.lineTo(bounds.x + bounds.width, bounds.y + bh3); - g.moveTo(bounds.x, bounds.y + 2 * bh3); - g.lineTo(bounds.x + bounds.width, bounds.y + 2 * bh3); - g.stroke(); - g.closePath(); -}; - -module.exports = SelectionLayer; - -},{"./Input.js":4,"./Listeners.js":5,"./Rectangle.js":6,"./Selection.js":7}],9:[function(require,module,exports){ -"use strict"; - -// http://snippetrepo.com/snippets/basic-vanilla-javascript-throttlingdebounce -function debounce(fn, wait, immediate) { - var timeout; - return function () { - var context = this; - var args = arguments; - clearTimeout(timeout); - timeout = setTimeout(function () { - timeout = null; - if (!immediate) fn.apply(context, args); - }, wait); - if (immediate && !timeout) fn.apply(context, args); - }; -}; - -module.exports = debounce; - -},{}],10:[function(require,module,exports){ -'use strict'; - -var debounce = require('./debounce.js'); -var BackgroundLayer = require('./BackgroundLayer.js'); -var ImageLayer = require('./ImageLayer.js'); -var SelectionLayer = require('./SelectionLayer.js'); -var Image = require('./Image.js'); -var Listeners = require('./Listeners.js'); - -var DEFAULT_CANVAS_WIDTH = 400; -var DEFAULT_CANVAS_HEIGHT = 300; - -var Crop = function Crop(opts) { - this.parent = typeof opts.parent === 'string' ? document.querySelector(opts.parent) : opts.parent; - - this.canvas = document.createElement('canvas'); - this.context = this.canvas.getContext('2d'); - this.boundsOpts = opts.bounds || { width: '100%', height: 'auto' }; - opts.selection = opts.selection || {}; - this.debounceResize = opts.debounceResize !== undefined ? opts.debounceResize : true; - this.listeners = Listeners.create(); - - this.parent.appendChild(this.canvas); - - this.backgroundLayer = BackgroundLayer.create({ - parent: this, - context: this.context, - colors: opts.backgroundColors || ['#fff', '#f0f0f0'] - }); - - this.imageLayer = ImageLayer.create({ - parent: this, - context: this.context, - image: this.image - }); - - this.selectionLayer = SelectionLayer.create({ - parent: this, - context: this.context, - target: this.imageLayer, - aspectRatio: opts.selection.aspectRatio, - minWidth: opts.selection.minWidth, - minHeight: opts.selection.minHeight, - x: opts.selection.x, - y: opts.selection.y, - width: opts.selection.width, - height: opts.selection.height, - handle: { - color: opts.selection.color, - activeColor: opts.selection.activeColor - } - }); - - var listeners = this.listeners; - var paint = this.paint.bind(this); - - this.selectionLayer.on('start', function (region) { - paint(); - listeners.notify('start', region); - }).on('move', function (region) { - listeners.notify('move', region); - }).on('resize', function (region) { - listeners.notify('resize', region); - }).on('change', function (region) { - paint(); - listeners.notify('change', region); - }).on('end', function (region) { - paint(); - listeners.notify('end', region); - }); - - window.addEventListener('resize', this.debounceResize ? debounce(this.revalidateAndPaint.bind(this), 100) : this.revalidateAndPaint.bind(this)); - - this.setImage(opts.image); - - this.revalidateAndPaint(); -}; - -Crop.create = function (opts) { - return new Crop(opts); -}; - -Crop.prototype.on = function (type, fn) { - this.listeners.on(type, fn); - return this; -}; - -Crop.prototype.off = function (type, fn) { - this.listeners.off(type, fn); - return this; -}; - -Crop.prototype.revalidateAndPaint = function () { - this.revalidate(); - this.paint(); -}; - -Crop.prototype.revalidate = function () { - var parent = this.parent; - var image = this.image; - - var boundsWidth = this.boundsOpts.width; - var boundsHeight = this.boundsOpts.height; - var width = 0; - var height = 0; - - if (isInteger(boundsWidth)) { - width = boundsWidth; - } else if (parent && isPercent(boundsWidth)) { - width = Math.round(parent.clientWidth * getPercent(boundsWidth) / 100); - } else { - width = DEFAULT_CANVAS_WIDTH; - } - - if (isInteger(boundsHeight)) { - height = boundsHeight; - } else if (isPercent(boundsHeight)) { - height = Math.round(width * getPercent(boundsHeight) / 100); - } else if (image && image.hasLoaded && isAuto(boundsHeight)) { - height = Math.floor(width / image.getAspectRatio()); - } else { - height = DEFAULT_CANVAS_HEIGHT; - } - - this.resizeCanvas(width, height); - - this.backgroundLayer.revalidate(); - this.imageLayer.revalidate(); - this.selectionLayer.revalidate(); -}; - -Crop.prototype.paint = function () { - var g = this.context; - - g.save(); - g.scale(this.ratio, this.ratio); - - this.backgroundLayer.paint(); - - if (this.image && this.image.hasLoaded) { - this.imageLayer.paint(); - this.selectionLayer.paint(); - } - - g.restore(); -}; - -Crop.prototype.resizeCanvas = function (width, height) { - var context = this.context; - var canvas = this.canvas; - this.ratio = 1; - - if (!context.webkitBackingStorePixelRatio) { - this.ratio = window.devicePixelRatio || 1; - } - - this.width = width; - this.height = height; - - canvas.width = this.width * this.ratio; - canvas.height = this.height * this.ratio; -}; - -Crop.prototype.setImage = function (source) { - var image = Image.create(source).on('load', function () { - this.selectionLayer.onImageLoad(); - this.revalidateAndPaint(); - }.bind(this)).on('error', function (e) { - console.error(e); - }); - - this.imageLayer.setImage(image); - this.image = image; - this.revalidateAndPaint(); -}; - -Crop.prototype.getImage = function () { - return this.image; -}; - -Crop.prototype.setAspectRatio = function (aspectRatio) { - this.selectionLayer.setAspectRatio(aspectRatio); - this.revalidateAndPaint(); -}; - -Crop.prototype.setBounds = function (opts) { - this.boundsOpts = opts; - this.revalidateAndPaint(); -}; - -Crop.prototype.setBackgroundColors = function (colors) { - this.backgroundLayer.setColors(colors); - this.revalidateAndPaint(); -}; - -Crop.prototype.dispose = noop; - -function noop() {}; - -function isPercent(v) { - if (typeof v !== 'string') { - return false; - } - - if (v.length < 1) { - return false; - } - - if (v[v.length - 1] === '%') { - return true; - } -} - -function getPercent(v) { - if (!isPercent(v)) { - return 0; - } +/******/ // Flag the module as loaded +/******/ module.loaded = true; - return v.slice(0, -1); -} +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } -function isAuto(v) { - return v === 'auto'; -} -function isInteger(v) { - return typeof v === 'number' && Math.round(v) === v; -} +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; -module.exports = Crop; +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; -},{"./BackgroundLayer.js":1,"./Image.js":2,"./ImageLayer.js":3,"./Listeners.js":5,"./SelectionLayer.js":8,"./debounce.js":9}],11:[function(require,module,exports){ -'use strict'; +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; -/* - * Modified version of http://github.com/desandro/imagesloaded v2.1.1 - * MIT License. - */ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { -var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; - -function loadImage(image, callback) { - if (!image.nodeName || image.nodeName.toLowerCase() !== 'img') { - return callback(new Error('First argument must an image element')); - } + 'use strict'; - if (image.src && image.complete && image.naturalWidth !== undefined) { - return callback(null, true); - } + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - image.addEventListener('load', function () { - callback(null, false); - }); + var _debounce = __webpack_require__(9); - image.addEventListener('error', function (e) { - callback(new Error('Failed to load image \'' + (image.src || '') + '\'')); - }); + var _debounce2 = _interopRequireDefault(_debounce); - if (image.complete) { - var src = image.src; - image.src = BLANK; - image.src = src; - } -} - -module.exports = loadImage; + var _BackgroundLayer = __webpack_require__(3); -},{}]},{},[10])(10) + var _BackgroundLayer2 = _interopRequireDefault(_BackgroundLayer); + + var _ImageLayer = __webpack_require__(5); + + var _ImageLayer2 = _interopRequireDefault(_ImageLayer); + + var _SelectionLayer = __webpack_require__(8); + + var _SelectionLayer2 = _interopRequireDefault(_SelectionLayer); + + var _Image = __webpack_require__(4); + + var _Image2 = _interopRequireDefault(_Image); + + var _Listeners = __webpack_require__(1); + + var _Listeners2 = _interopRequireDefault(_Listeners); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var DEFAULT_CANVAS_WIDTH = 400; + var DEFAULT_CANVAS_HEIGHT = 300; + + var Crop = function () { + function Crop(opts) { + _classCallCheck(this, Crop); + + this.parent = typeof opts.parent === 'string' ? document.querySelector(opts.parent) : opts.parent; + + this.canvas = document.createElement('canvas'); + this.context = this.canvas.getContext('2d'); + this.boundsOpts = opts.bounds || { width: '100%', height: 'auto' }; + opts.selection = opts.selection || {}; + this.debounceResize = opts.debounceResize !== undefined ? opts.debounceResize : true; + this.listeners = _Listeners2.default.create(); + + this.parent.appendChild(this.canvas); + + this.backgroundLayer = _BackgroundLayer2.default.create({ + parent: this, + context: this.context, + colors: opts.backgroundColors || ['#fff', '#f0f0f0'] + }); + + this.imageLayer = _ImageLayer2.default.create({ + parent: this, + context: this.context, + image: this.image + }); + + this.selectionLayer = _SelectionLayer2.default.create({ + parent: this, + context: this.context, + target: this.imageLayer, + aspectRatio: opts.selection.aspectRatio, + minWidth: opts.selection.minWidth, + minHeight: opts.selection.minHeight, + x: opts.selection.x, + y: opts.selection.y, + width: opts.selection.width, + height: opts.selection.height, + handle: { + color: opts.selection.color, + activeColor: opts.selection.activeColor + } + }); + + var listeners = this.listeners; + var paint = this.paint.bind(this); + + this.selectionLayer.on('start', function (region) { + paint(); + listeners.notify('start', region); + }).on('move', function (region) { + listeners.notify('move', region); + }).on('resize', function (region) { + listeners.notify('resize', region); + }).on('change', function (region) { + paint(); + listeners.notify('change', region); + }).on('end', function (region) { + paint(); + listeners.notify('end', region); + }); + + window.addEventListener('resize', this.debounceResize ? (0, _debounce2.default)(this.revalidateAndPaint.bind(this), 100) : this.revalidateAndPaint.bind(this)); + + this.setImage(opts.image); + + this.revalidateAndPaint(); + } + + _createClass(Crop, [{ + key: 'on', + value: function on(type, fn) { + this.listeners.on(type, fn); + return this; + } + }, { + key: 'off', + value: function off(type, fn) { + this.listeners.off(type, fn); + return this; + } + }, { + key: 'revalidateAndPaint', + value: function revalidateAndPaint() { + this.revalidate(); + this.paint(); + } + }, { + key: 'revalidate', + value: function revalidate() { + var parent = this.parent; + var image = this.image; + + var boundsWidth = this.boundsOpts.width; + var boundsHeight = this.boundsOpts.height; + var width = 0; + var height = 0; + + if (isInteger(boundsWidth)) { + width = boundsWidth; + } else if (parent && isPercent(boundsWidth)) { + width = Math.round(parent.clientWidth * getPercent(boundsWidth) / 100); + } else { + width = DEFAULT_CANVAS_WIDTH; + } + + if (isInteger(boundsHeight)) { + height = boundsHeight; + } else if (isPercent(boundsHeight)) { + height = Math.round(width * getPercent(boundsHeight) / 100); + } else if (image && image.hasLoaded && isAuto(boundsHeight)) { + height = Math.floor(width / image.getAspectRatio()); + } else { + height = DEFAULT_CANVAS_HEIGHT; + } + + this.resizeCanvas(width, height); + + this.backgroundLayer.revalidate(); + this.imageLayer.revalidate(); + this.selectionLayer.revalidate(); + } + }, { + key: 'paint', + value: function paint() { + var g = this.context; + + g.save(); + g.scale(this.ratio, this.ratio); + + this.backgroundLayer.paint(); + + if (this.image && this.image.hasLoaded) { + this.imageLayer.paint(); + this.selectionLayer.paint(); + } + + g.restore(); + } + }, { + key: 'resizeCanvas', + value: function resizeCanvas(width, height) { + var context = this.context; + var canvas = this.canvas; + this.ratio = 1; + + if (!context.webkitBackingStorePixelRatio) { + this.ratio = window.devicePixelRatio || 1; + } + + this.width = width; + this.height = height; + + canvas.width = this.width * this.ratio; + canvas.height = this.height * this.ratio; + } + }, { + key: 'setImage', + value: function setImage(source) { + var _this = this; + + var image = _Image2.default.create(source).on('load', function () { + _this.selectionLayer.onImageLoad(); + _this.revalidateAndPaint(); + }).on('error', function (e) { + console.error(e); + }); + + this.imageLayer.setImage(image); + this.image = image; + this.revalidateAndPaint(); + } + }, { + key: 'getImage', + value: function getImage() { + return this.image; + } + }, { + key: 'setAspectRatio', + value: function setAspectRatio(aspectRatio) { + this.selectionLayer.setAspectRatio(aspectRatio); + this.revalidateAndPaint(); + } + }, { + key: 'setBounds', + value: function setBounds(opts) { + this.boundsOpts = opts; + this.revalidateAndPaint(); + } + }, { + key: 'setBackgroundColors', + value: function setBackgroundColors(colors) { + this.backgroundLayer.setColors(colors); + this.revalidateAndPaint(); + } + }]); + + return Crop; + }(); + + Crop.create = function (opts) { + return new Crop(opts); + }; + + Crop.prototype.dispose = noop; + + function noop() {} + + function isPercent(v) { + if (typeof v !== 'string') { + return false; + } + + if (v.length < 1) { + return false; + } + + if (v[v.length - 1] === '%') { + return true; + } + } + + function getPercent(v) { + if (!isPercent(v)) { + return 0; + } + + return v.slice(0, -1); + } + + function isAuto(v) { + return v === 'auto'; + } + + function isInteger(v) { + return typeof v === 'number' && Math.round(v) === v; + } + + module.exports = Crop; + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var Listeners = function () { + function Listeners(opts) { + _classCallCheck(this, Listeners); + + this.events = {}; + } + + _createClass(Listeners, [{ + key: "on", + value: function on(type, fn) { + if (!this.events[type]) { + this.events[type] = []; + } + + if (this.events[type].indexOf(fn) === -1) { + this.events[type].push(fn); + } + + return this; + } + }, { + key: "off", + value: function off(type, fn) { + if (this.events[type]) { + var i = this.events[type].indexOf(fn); + if (i !== -1) { + this.events[type].splice(i, 1); + } + } + + return this; + } + }, { + key: "notify", + value: function notify(type, data) { + var _this = this; + + if (this.events[type]) { + this.events[type].forEach(function (fn) { + fn.call(_this, data); + }); + } + } + }, { + key: "clearAll", + value: function clearAll() { + this.events = {}; + } + }]); + + return Listeners; + }(); + + Listeners.create = function (opts) { + return new Listeners(opts); + }; + + exports.default = Listeners; + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var Rectangle = function () { + function Rectangle(x, y, width, height) { + _classCallCheck(this, Rectangle); + + this._x = x; + this._y = y; + this._width = width; + this._height = height; + } + + _createClass(Rectangle, [{ + key: "copy", + value: function copy(_copy) { + this._x = _copy.x; + this._y = _copy.y; + this._width = _copy.width; + this._height = _copy.height; + return this; + } + }, { + key: "clone", + value: function clone() { + return Rectangle.create(this._x, this._y, this._width, this._height); + } + }, { + key: "round", + value: function round() { + var dx = this._x; + var dy = this._y; + this._x = Math.round(dx); + this._y = Math.round(dy); + dx -= this._x; + dy -= this._y; + this._width = Math.round(this._width + dx); + this._height = Math.round(this._height + dy); + return this; + } + }, { + key: "isInside", + value: function isInside(point) { + return point.x >= this.left && point.y >= this.top && point.x < this.right && point.y < this.bottom; + } + }]); + + return Rectangle; + }(); + + Object.defineProperties(Rectangle.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(v) { + this._x = v; + } + }, + y: { + get: function get() { + return this._y; + }, + set: function set(v) { + this._y = v; + } + }, + centerX: { + get: function get() { + return this._x + this._width * 0.5; + }, + set: function set(v) { + this._x = v - this._width * 0.5; + } + }, + centerY: { + get: function get() { + return this._y + this._height * 0.5; + }, + set: function set(v) { + this._y = v - this._height * 0.5; + } + }, + width: { + get: function get() { + return this._width; + }, + set: function set(v) { + this._width = v; + } + }, + height: { + get: function get() { + return this._height; + }, + set: function set(v) { + this._height = v; + } + }, + left: { + get: function get() { + return this._x; + }, + set: function set(v) { + this._width = this._x + this._width - v; + this._x = v; + } + }, + top: { + get: function get() { + return this._y; + }, + set: function set(v) { + this._height = this._y + this._height - v; + this._y = v; + } + }, + right: { + get: function get() { + return this._x + this._width; + }, + set: function set(v) { + this._width = v - this._x; + } + }, + bottom: { + get: function get() { + return this._y + this._height; + }, + set: function set(v) { + this._height = v - this._y; + } + }, + aspectRatio: { + get: function get() { + return this._width / this._height; + } + } + }); + + Rectangle.create = function (x, y, width, height) { + return new Rectangle(x, y, width, height); + }; + + exports.default = Rectangle; + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var BackgroundLayer = function () { + function BackgroundLayer() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, BackgroundLayer); + + this.colors = opts.colors; + this.parent = opts.parent; + this.context = opts.context; + this.isDirty = true; + } + + _createClass(BackgroundLayer, [{ + key: "revalidate", + value: function revalidate() { + this.isDirty = true; + } + }, { + key: "setColors", + value: function setColors(colors) { + this.colors = colors; + } + }, { + key: "paint", + value: function paint() { + if (this.isDirty) { + var parent = this.parent; + var g = this.context; + + if (!this.colors || !this.colors.length) { + g.clearRect(0, 0, parent.width, parent.height); + } else { + g.fillStyle = this.colors[0]; + g.fillRect(0, 0, parent.width, parent.height); + } + + if (this.colors && this.colors.length > 1) { + var h = parent.height; + + var cols = 32; + var size = parent.width / cols; + var rows = Math.ceil(h / size); + + g.fillStyle = this.colors[1]; + for (var i = 0; i < cols; i += 1) { + for (var j = 0; j < rows; j += 1) { + if ((i + j) % 2 === 0) { + g.fillRect(i * size, j * size, size, size); + } + } + } + } + + this.isDirty = false; + } + } + }]); + + return BackgroundLayer; + }(); + + BackgroundLayer.create = function (opts) { + return new BackgroundLayer(opts); + }; + + exports.default = BackgroundLayer; + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _loadImage = __webpack_require__(10); + + var _loadImage2 = _interopRequireDefault(_loadImage); + + var _Listeners = __webpack_require__(1); + + var _Listeners2 = _interopRequireDefault(_Listeners); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var Image = function () { + function Image(source) { + var _this = this; + + _classCallCheck(this, Image); + + this.width = 0; + this.height = 0; + + this.hasLoaded = false; + this.src = null; + + this.listeners = _Listeners2.default.create(); + + if (!source) { + return; + } + + if (typeof source === 'string') { + this.src = source; + var img = document.createElement('img'); + img.src = this.src; + source = img; + } else { + this.src = source.src; + } + + this.source = source; + + (0, _loadImage2.default)(source, function (err) { + if (err) { + _this.notify('error', err); + } else { + _this.hasLoaded = true; + _this.width = source.naturalWidth; + _this.height = source.naturalHeight; + _this.notify('load', _this); + } + }); + } + + _createClass(Image, [{ + key: 'getAspectRatio', + value: function getAspectRatio() { + if (!this.hasLoaded) { + return 1; + } + + return this.width / this.height; + } + }, { + key: 'notify', + value: function notify(type, data) { + var listeners = this.listeners; + setTimeout(function () { + listeners.notify(type, data); + }, 0); + } + }, { + key: 'on', + value: function on(type, fn) { + this.listeners.on(type, fn); + return this; + } + }, { + key: 'off', + value: function off(type, fn) { + this.listeners.off(type, fn); + return this; + } + }]); + + return Image; + }(); + + Image.create = function (source) { + return new Image(source); + }; + + exports.default = Image; + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _Rectangle = __webpack_require__(2); + + var _Rectangle2 = _interopRequireDefault(_Rectangle); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var ImageLayer = function () { + function ImageLayer() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, ImageLayer); + + this.bounds = _Rectangle2.default.create(0, 0, 0, 0); + this.image = opts.image || null; + this.parent = opts.parent; + this.context = opts.context; + } + + _createClass(ImageLayer, [{ + key: 'setImage', + value: function setImage(image) { + this.image = image; + } + }, { + key: 'revalidate', + value: function revalidate() { + var parent = this.parent; + var image = this.image; + var bounds = this.bounds; + + if (image) { + // Constrained by width (otherwise height) + if (image.width / image.height >= parent.width / parent.height) { + bounds.width = parent.width; + bounds.height = Math.ceil(image.height / image.width * parent.width); + bounds.x = 0; + bounds.y = Math.floor((parent.height - bounds.height) * 0.5); + } else { + bounds.width = Math.ceil(image.width / image.height * parent.height); + bounds.height = parent.height; + bounds.x = Math.floor((parent.width - bounds.width) * 0.5); + bounds.y = 0; + } + } + } + }, { + key: 'paint', + value: function paint() { + var g = this.context; + var image = this.image; + var bounds = this.bounds; + + if (image && image.hasLoaded) { + g.drawImage(image.source, 0, 0, image.width, image.height, bounds.x, bounds.y, bounds.width, bounds.height); + } + } + }]); + + return ImageLayer; + }(); + + ImageLayer.create = function (opts) { + return new ImageLayer(opts); + }; + + exports.default = ImageLayer; + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _Listeners = __webpack_require__(1); + + var _Listeners2 = _interopRequireDefault(_Listeners); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var Input = function () { + function Input(domElement) { + _classCallCheck(this, Input); + + var listeners = _Listeners2.default.create(); + var downEvent = null; + this.listeners = listeners; + + function createEventForMouse(source) { + var x = source.offsetX; + var y = source.offsetY; + + return { + source: source, + x: x, + y: y, + dx: downEvent ? x - downEvent.x : 0, + dy: downEvent ? y - downEvent.y : 0, + type: 'Mouse' + }; + } + + function createEventForTouch(source) { + var bounds = source.target.getBoundingClientRect(); + var touch = source.touches.length > 0 ? source.touches[0] : source.changedTouches[0]; + + var x = touch.clientX - bounds.left; + var y = touch.clientY - bounds.top; + + return { + source: source, + x: x, + y: y, + dx: downEvent ? x - downEvent.x : 0, + dy: downEvent ? y - downEvent.y : 0, + type: 'Touch' + }; + } + + domElement.addEventListener('mousedown', function (source) { + downEvent = createEventForMouse(source); + listeners.notify('down', downEvent); + }); + + domElement.addEventListener('touchstart', function (source) { + downEvent = createEventForTouch(source); + listeners.notify('down', downEvent); + }); + + domElement.addEventListener('mousemove', function (source) { + listeners.notify('move', createEventForMouse(source)); + }); + + domElement.addEventListener('touchmove', function (source) { + listeners.notify('move', createEventForTouch(source)); + }); + + domElement.addEventListener('mouseup', function (source) { + listeners.notify('up', createEventForMouse(source)); + }); + + domElement.addEventListener('touchend', function (source) { + listeners.notify('up', createEventForTouch(source)); + downEvent = null; + }); + + domElement.addEventListener('mouseout', function (source) { + listeners.notify('cancel', createEventForMouse(source)); + downEvent = null; + }); + + domElement.addEventListener('touchcancel', function (source) { + listeners.notify('cancel', createEventForTouch(source)); + downEvent = null; + }); + } + + _createClass(Input, [{ + key: 'on', + value: function on(type, fn) { + this.listeners.on(type, fn); + return this; + } + }, { + key: 'off', + value: function off(type, fn) { + this.listeners.off(type, fn); + return this; + } + }]); + + return Input; + }(); + + Input.create = function (domElement) { + return new Input(domElement); + }; + + exports.default = Input; + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _Rectangle = __webpack_require__(2); + + var _Rectangle2 = _interopRequireDefault(_Rectangle); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var Selection = function () { + function Selection(opts) { + _classCallCheck(this, Selection); + + this.target = opts.target || null; + this.bounds = _Rectangle2.default.create(0, 0, 0, 0); + this.boundsPx = _Rectangle2.default.create(0, 0, 0, 0); + this.region = _Rectangle2.default.create(0, 0, 0, 0); + + this.initialOpts = { + x: opts.x, + y: opts.y, + width: opts.width, + height: opts.height + }; + + this.aspectRatio = opts.aspectRatio; + this.minWidth = opts.minWidth !== undefined ? opts.minWidth : 100; + this.minHeight = opts.minHeight !== undefined ? opts.minHeight : 100; + + this.boundsMinWidth = 0; + this.boundsMinHeight = 0; + + this._delta = { x: 0, h: 0 }; + } + + _createClass(Selection, [{ + key: 'getBoundsLengthForRegion', + value: function getBoundsLengthForRegion(regionLen) { + return regionLen / this.region.width * this.width; + } + }, { + key: 'moveBy', + value: function moveBy(dx, dy) { + var bounds = this.bounds; + var target = this.target; + + bounds.x = Math.min(Math.max(bounds.x + dx, target.bounds.x), target.bounds.x + target.bounds.width - bounds.width); + bounds.y = Math.min(Math.max(bounds.y + dy, target.bounds.y), target.bounds.y + target.bounds.height - bounds.height); + + return this.updateRegionFromBounds(); + } + }, { + key: 'resizeBy', + value: function resizeBy(dx, dy, p) { + var delta = this._delta; + var aspectRatio = this.aspectRatio; + var bounds = this.bounds; + var boundsMinWidth = this.boundsMinWidth; + var boundsMinHeight = this.boundsMinHeight; + var target = this.target; + + function calculateDelta(x, y) { + delta.width = bounds.width + x; + delta.height = bounds.height + y; + + delta.width = Math.max(boundsMinWidth, delta.width); + delta.height = Math.max(boundsMinHeight, delta.height); + + if (aspectRatio) { + if (delta.width / delta.height > aspectRatio) { + delta.width = delta.height * aspectRatio; + } else { + delta.height = delta.width / aspectRatio; + } + } + + delta.width -= bounds.width; + delta.height -= bounds.height; + + return delta; + } + + if (p[0] === 'n') { + dy = Math.min(dy, this.top - target.bounds.top); + } else if (p[0] === 's') { + dy = Math.min(dy, target.bounds.bottom - this.bottom); + } + + if (p[1] === 'w') { + dx = Math.min(dx, this.left - target.bounds.left); + } else if (p[1] === 'e') { + dx = Math.min(dx, target.bounds.right - this.right); + } + + delta = calculateDelta(dx, dy); + + switch (p) { + case 'nw': + this.left -= delta.width; + this.top -= delta.height; + break; + case 'ne': + this.right += delta.width; + this.top -= delta.height; + break; + case 'sw': + this.left -= delta.width; + this.bottom += delta.height; + break; + case 'se': + this.right += delta.width; + this.bottom += delta.height; + break; + } + + return this.updateRegionFromBounds(); + } + }, { + key: 'autoSizeRegion', + value: function autoSizeRegion() { + var target = this.target; + var region = this.region; + var aspectRatio = this.aspectRatio; + var initialOpts = this.initialOpts; + var beforeX = region.x; + var beforeY = region.y; + var beforeWidth = region.width; + var beforeHeight = region.height; + + region.x = initialOpts.x !== undefined ? initialOpts.x : 0; + region.y = initialOpts.y !== undefined ? initialOpts.y : 0; + + region.width = initialOpts.width !== undefined ? initialOpts.width : target.image.width; + region.height = initialOpts.height !== undefined ? initialOpts.height : target.image.height; + + if (aspectRatio) { + if (region.width / region.height > aspectRatio) { + region.width = region.height * aspectRatio; + } else { + region.height = region.width / aspectRatio; + } + } + + if (initialOpts.x === undefined) { + region.centerX = target.image.width * 0.5; + } + + if (initialOpts.y === undefined) { + region.centerY = target.image.height * 0.5; + } + + region.round(); + + this.updateBoundsFromRegion(); + + return region.x !== beforeX || region.y !== beforeY || region.width !== beforeWidth || region.height !== beforeHeight; + } + }, { + key: 'updateRegionFromBounds', + value: function updateRegionFromBounds() { + var target = this.target; + var region = this.region; + var bounds = this.bounds; + var beforeX = region.x; + var beforeY = region.y; + var beforeWidth = region.width; + var beforeHeight = region.height; + + region.x = target.image.width * (bounds.x - target.bounds.x) / target.bounds.width; + region.y = target.image.height * (bounds.y - target.bounds.y) / target.bounds.height; + + region.width = target.image.width * (bounds.width / target.bounds.width); + region.height = target.image.height * (bounds.height / target.bounds.height); + + region.round(); + + return region.x !== beforeX || region.y !== beforeY || region.width !== beforeWidth || region.height !== beforeHeight; + } + }, { + key: 'updateBoundsFromRegion', + value: function updateBoundsFromRegion() { + var target = this.target; + var region = this.region; + var bounds = this.bounds; + + if (target.image) { + bounds.x = target.bounds.x + target.bounds.width * (region.x / target.image.width); + bounds.y = target.bounds.y + target.bounds.height * (region.y / target.image.height); + bounds.width = target.bounds.width * (region.width / target.image.width); + bounds.height = target.bounds.height * (region.height / target.image.height); + } + + this.boundsMinWidth = this.getBoundsLengthForRegion(this.minWidth); + this.boundsMinHeight = this.getBoundsLengthForRegion(this.minHeight); + } + }, { + key: 'isInside', + value: function isInside(point) { + return this.bounds.isInside(point); + } + }]); + + return Selection; + }(); + + Object.defineProperties(Selection.prototype, { + x: { + get: function get() { + return this.bounds.x; + }, + set: function set(v) { + this.bounds.x = v; + } + }, + y: { + get: function get() { + return this.bounds.y; + }, + set: function set(v) { + this.bounds.y = v; + } + }, + width: { + get: function get() { + return this.bounds.width; + }, + set: function set(v) { + this.bounds.width = v; + } + }, + height: { + get: function get() { + return this.bounds.height; + }, + set: function set(v) { + this.bounds.height = v; + } + }, + left: { + get: function get() { + return this.bounds.x; + }, + set: function set(v) { + this.bounds.left = v; + } + }, + top: { + get: function get() { + return this.bounds.y; + }, + set: function set(v) { + this.bounds.top = v; + } + }, + right: { + get: function get() { + return this.bounds.right; + }, + set: function set(v) { + this.bounds.right = v; + } + }, + bottom: { + get: function get() { + return this.bounds.bottom; + }, + set: function set(v) { + this.bounds.bottom = v; + } + } + }); + + Selection.create = function (opts) { + return new Selection(opts); + }; + + exports.default = Selection; + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _Input = __webpack_require__(6); + + var _Input2 = _interopRequireDefault(_Input); + + var _Listeners = __webpack_require__(1); + + var _Listeners2 = _interopRequireDefault(_Listeners); + + var _Selection = __webpack_require__(7); + + var _Selection2 = _interopRequireDefault(_Selection); + + var _Rectangle = __webpack_require__(2); + + var _Rectangle2 = _interopRequireDefault(_Rectangle); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var SelectionLayer = function () { + function SelectionLayer() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, SelectionLayer); + + this.selection = _Selection2.default.create(opts); + + this.parent = opts.parent; + this.context = opts.context; + this.context.setLineDash = this.context.setLineDash || function () {}; + this.target = opts.target; + + var handleOpts = opts.handle || {}; + handleOpts.length = handleOpts.handleLength || 32; + handleOpts.depth = handleOpts.depth || 3; + handleOpts.size = handleOpts.size || handleOpts.length * 2; + handleOpts.color = handleOpts.color || 'rgba(255, 255, 255, 1.0)'; + handleOpts.activeColor = handleOpts.activeColor || 'rgba(255, 0, 160, 1.0)'; + this.handleOpts = handleOpts; + + this.listeners = _Listeners2.default.create(); + + this.input = _Input2.default.create(this.parent.canvas); + + this.activeRegion = null; + this.downBounds = _Rectangle2.default.create(0, 0, 0, 0); + + this.input.on('down', this.onInputDown.bind(this)); + this.input.on('move', this.onInputMove.bind(this)); + this.input.on('up', this.onInputUpOrCancel.bind(this)).on('cancel', this.onInputUpOrCancel.bind(this)); + } + + _createClass(SelectionLayer, [{ + key: 'onInputDown', + value: function onInputDown(e) { + var hitRegion = this.findHitRegion(e); + + if (hitRegion) { + e.source.preventDefault(); + this.activeRegion = hitRegion; + this.setCursor(hitRegion); + this.downBounds.copy(this.selection.bounds); + this.listeners.notify('start', this.selection.region); + } + } + }, { + key: 'onInputMove', + value: function onInputMove(e) { + var activeRegion = this.activeRegion; + + if (!activeRegion) { + var hitRegion = this.findHitRegion(e); + if (hitRegion) { + e.source.preventDefault(); + this.setCursor(hitRegion); + } else { + this.resetCursor(); + } + } else { + e.source.preventDefault(); + + var selection = this.selection; + var hasChanged = false; + selection.bounds.copy(this.downBounds); + + if (activeRegion === 'move') { + hasChanged = selection.moveBy(e.dx, e.dy); + if (hasChanged) { + this.listeners.notify('move', this.selection.region); + } + } else { + var dir = activeRegion.substring(0, 2); + var dx = dir[1] === 'w' ? -e.dx : e.dx; + var dy = dir[0] === 'n' ? -e.dy : e.dy; + hasChanged = selection.resizeBy(dx, dy, dir); + if (hasChanged) { + this.listeners.notify('resize', this.selection.region); + } + } + + if (hasChanged) { + this.listeners.notify('change', this.selection.region); + } + } + } + }, { + key: 'onInputUpOrCancel', + value: function onInputUpOrCancel(e) { + e.source.preventDefault(); + if (this.activeRegion) { + this.activeRegion = null; + this.resetCursor(); + this.listeners.notify('end', this.selection.region); + } + } + }, { + key: 'findHitRegion', + value: function findHitRegion(point) { + var hitRegion = null; + var closest = Number.MAX_VALUE; + + var d = this.isWithinNorthWestHandle(point); + if (d !== false && d < closest) { + closest = d; + hitRegion = 'nw-resize'; + } + + d = this.isWithinNorthEastHandle(point); + if (d !== false && d < closest) { + closest = d; + hitRegion = 'ne-resize'; + } + + d = this.isWithinSouthWestHandle(point); + if (d !== false && d < closest) { + closest = d; + hitRegion = 'sw-resize'; + } + + d = this.isWithinSouthEastHandle(point); + if (d !== false && d < closest) { + closest = d; + hitRegion = 'se-resize'; + } + + if (hitRegion) { + return hitRegion; + } else if (this.isWithinBounds(point)) { + return 'move'; + } else { + return null; + } + } + }, { + key: 'on', + value: function on(type, fn) { + this.listeners.on(type, fn); + return this; + } + }, { + key: 'off', + value: function off(type, fn) { + this.listeners.off(type, fn); + return this; + } + }, { + key: 'setCursor', + value: function setCursor(type) { + if (this.parent.canvas.style.cursor !== type) { + this.parent.canvas.style.cursor = type; + } + } + }, { + key: 'resetCursor', + value: function resetCursor() { + this.setCursor('auto'); + } + }, { + key: 'isWithinRadius', + value: function isWithinRadius(ax, ay, bx, by, r) { + var tsq = r * r; + var dx = ax - bx; + var dy = ay - by; + var dsq = dx * dx + dy * dy; + return dsq < tsq ? dsq : false; + } + }, { + key: 'isWithinNorthWestHandle', + value: function isWithinNorthWestHandle(point) { + return this.isWithinRadius(point.x, point.y, this.selection.left, this.selection.top, this.getHandleRadius()); + } + }, { + key: 'isWithinNorthEastHandle', + value: function isWithinNorthEastHandle(point) { + return this.isWithinRadius(point.x, point.y, this.selection.right, this.selection.top, this.getHandleRadius()); + } + }, { + key: 'isWithinSouthWestHandle', + value: function isWithinSouthWestHandle(point) { + return this.isWithinRadius(point.x, point.y, this.selection.left, this.selection.bottom, this.getHandleRadius()); + } + }, { + key: 'isWithinSouthEastHandle', + value: function isWithinSouthEastHandle(point) { + return this.isWithinRadius(point.x, point.y, this.selection.right, this.selection.bottom, this.getHandleRadius()); + } + }, { + key: 'isWithinBounds', + value: function isWithinBounds(point) { + return this.selection.isInside(point); + } + }, { + key: 'getHandleRadius', + value: function getHandleRadius() { + return this.handleOpts.size / 2; + } + }, { + key: 'onImageLoad', + value: function onImageLoad() { + this.autoSizeRegionAndNotify(); + } + }, { + key: 'setAspectRatio', + value: function setAspectRatio(aspectRatio) { + this.selection.aspectRatio = aspectRatio; + this.autoSizeRegionAndNotify(); + } + }, { + key: 'autoSizeRegionAndNotify', + value: function autoSizeRegionAndNotify() { + var hasChanged = this.selection.autoSizeRegion(); + if (hasChanged) { + this.listeners.notify('change', this.selection.region); + } + } + }, { + key: 'revalidate', + value: function revalidate() { + this.selection.updateBoundsFromRegion(); + } + }, { + key: 'paint', + value: function paint() { + this.selection.boundsPx.copy(this.selection.bounds).round(); + + this.paintOutside(); + this.paintInside(); + } + }, { + key: 'paintOutside', + value: function paintOutside() { + var bounds = this.selection.boundsPx; + var g = this.context; + var target = this.target; + + var tl = target.bounds.x; + var tt = target.bounds.y; + var tw = target.bounds.width; + var tr = target.bounds.right; + var tb = target.bounds.bottom; + + var bl = bounds.x; + var bt = bounds.y; + var bh = bounds.height; + var br = bounds.right; + var bb = bounds.bottom; + + g.fillStyle = 'rgba(0, 0, 0, 0.5)'; + g.fillRect(tl, tt, tw, bt - tt); + g.fillRect(tl, bt, bl - tl, bh); + g.fillRect(br, bt, tr - br, bh); + g.fillRect(tl, bb, tw, tb - bb); + } + }, { + key: 'paintInside', + value: function paintInside() { + var g = this.context; + var bounds = this.selection.boundsPx; + var activeRegion = this.activeRegion; + var opts = this.handleOpts; + + var lengthWidth = Math.min(opts.length, bounds.width * 0.5); + var lengthHeight = Math.min(opts.length, bounds.height * 0.5); + var depth = opts.depth; + var color = opts.color; + var activeColor = opts.activeColor; + var length = 0; // TODO: CHECK + + // Sides + g.fillStyle = 'rgba(255, 255, 255, 0.3)'; + g.fillRect(bounds.x + length, bounds.y, bounds.width - 2 * length, depth); + g.fillRect(bounds.x + length, bounds.bottom - depth, bounds.width - 2 * length, depth); + g.fillRect(bounds.x, bounds.y + length, depth, bounds.height - 2 * length); + g.fillRect(bounds.right - depth, bounds.y + length, depth, bounds.height - 2 * length); + + // Handles + var isMoveRegion = activeRegion === 'move'; + + g.fillStyle = isMoveRegion || activeRegion === 'nw-resize' ? activeColor : color; + g.fillRect(bounds.x, bounds.y, lengthWidth, depth); + g.fillRect(bounds.x, bounds.y + depth, depth, lengthHeight - depth); + + g.fillStyle = isMoveRegion || activeRegion === 'ne-resize' ? activeColor : color; + g.fillRect(bounds.right - lengthWidth, bounds.y, lengthWidth, depth); + g.fillRect(bounds.right - depth, bounds.y + depth, depth, lengthHeight - depth); + + g.fillStyle = isMoveRegion || activeRegion === 'sw-resize' ? activeColor : color; + g.fillRect(bounds.x, bounds.bottom - depth, lengthWidth, depth); + g.fillRect(bounds.x, bounds.bottom - lengthHeight, depth, lengthHeight - depth); + + g.fillStyle = isMoveRegion || activeRegion === 'se-resize' ? activeColor : color; + g.fillRect(bounds.right - lengthWidth, bounds.bottom - depth, lengthWidth, depth); + g.fillRect(bounds.right - depth, bounds.bottom - lengthHeight, depth, lengthHeight - depth); + + // Guides + g.strokeStyle = 'rgba(255, 255, 255, 0.6)'; + g.setLineDash([2, 3]); + g.lineWidth = 1; + g.beginPath(); + var bw3 = bounds.width / 3; + var bh3 = bounds.height / 3; + g.moveTo(bounds.x + bw3, bounds.y); + g.lineTo(bounds.x + bw3, bounds.y + bounds.height); + g.moveTo(bounds.x + 2 * bw3, bounds.y); + g.lineTo(bounds.x + 2 * bw3, bounds.y + bounds.height); + g.moveTo(bounds.x, bounds.y + bh3); + g.lineTo(bounds.x + bounds.width, bounds.y + bh3); + g.moveTo(bounds.x, bounds.y + 2 * bh3); + g.lineTo(bounds.x + bounds.width, bounds.y + 2 * bh3); + g.stroke(); + g.closePath(); + } + }]); + + return SelectionLayer; + }(); + + SelectionLayer.create = function (opts) { + return new SelectionLayer(opts); + }; + + exports.default = SelectionLayer; + +/***/ }, +/* 9 */ +/***/ function(module, exports) { + + "use strict"; + + exports.__esModule = true; + // http://snippetrepo.com/snippets/basic-vanilla-javascript-throttlingdebounce + function debounce(fn, wait, immediate) { + var timeout = void 0; + return function () { + var context = this; + var args = arguments; + clearTimeout(timeout); + timeout = setTimeout(function () { + timeout = null; + if (!immediate) fn.apply(context, args); + }, wait); + if (immediate && !timeout) fn.apply(context, args); + }; + } + exports.default = debounce; + +/***/ }, +/* 10 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.__esModule = true; + /* + * Modified version of http://github.com/desandro/imagesloaded v2.1.1 + * MIT License. + */ + + var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; + + function loadImage(image, callback) { + if (!image.nodeName || image.nodeName.toLowerCase() !== 'img') { + return callback(new Error('First argument must an image element')); + } + + if (image.src && image.complete && image.naturalWidth !== undefined) { + return callback(null, true); + } + + image.addEventListener('load', function () { + callback(null, false); + }); + + image.addEventListener('error', function (e) { + callback(new Error('Failed to load image \'' + (image.src || '') + '\'')); + }); + + if (image.complete) { + var src = image.src; + image.src = BLANK; + image.src = src; + } + } + + exports.default = loadImage; + +/***/ } +/******/ ]) }); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvQmFja2dyb3VuZExheWVyLmpzIiwic3JjL0ltYWdlLmpzIiwic3JjL0ltYWdlTGF5ZXIuanMiLCJzcmMvSW5wdXQuanMiLCJzcmMvTGlzdGVuZXJzLmpzIiwic3JjL1JlY3RhbmdsZS5qcyIsInNyYy9TZWxlY3Rpb24uanMiLCJzcmMvU2VsZWN0aW9uTGF5ZXIuanMiLCJzcmMvZGVib3VuY2UuanMiLCJzcmMvaW5kZXguanMiLCJzcmMvbG9hZEltYWdlLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7QUNBQSxJQUFJLGtCQUFrQixTQUFsQixlQUFrQixDQUFVLElBQVYsRUFBZ0I7QUFDcEMsU0FBTyxRQUFRLEVBQWY7O0FBRUEsT0FBSyxNQUFMLEdBQWMsS0FBSyxNQUFuQjs7QUFFQSxPQUF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5tb2R1bGUuZXhwb3J0cyA9IGxvYWRJbWFnZVxuIl19 +; \ No newline at end of file diff --git a/dist/tinycrop.min.js b/dist/tinycrop.min.js index ca1d375..0d67277 100644 --- a/dist/tinycrop.min.js +++ b/dist/tinycrop.min.js @@ -1 +1 @@ -!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.tinycrop=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o1){var h=parent.height,cols=32,size=parent.width/cols,rows=Math.ceil(h/size);g.fillStyle=this.colors[1];for(var i=0;i=parent.width/parent.height?(bounds.width=parent.width,bounds.height=Math.ceil(image.height/image.width*parent.width),bounds.x=0,bounds.y=Math.floor(.5*(parent.height-bounds.height))):(bounds.width=Math.ceil(image.width/image.height*parent.height),bounds.height=parent.height,bounds.x=Math.floor(.5*(parent.width-bounds.width)),bounds.y=0))},ImageLayer.prototype.paint=function(){var g=this.context,image=this.image,bounds=this.bounds;image&&image.hasLoaded&&g.drawImage(image.source,0,0,image.width,image.height,bounds.x,bounds.y,bounds.width,bounds.height)},module.exports=ImageLayer},{"./Rectangle.js":6}],4:[function(require,module,exports){"use strict";var Listeners=require("./Listeners.js"),Input=function(domElement){function createEventForMouse(source){var x=source.offsetX,y=source.offsetY;return{source:source,x:x,y:y,dx:downEvent?x-downEvent.x:0,dy:downEvent?y-downEvent.y:0,type:"Mouse"}}function createEventForTouch(source){var bounds=source.target.getBoundingClientRect(),touch=source.touches.length>0?source.touches[0]:source.changedTouches[0],x=touch.clientX-bounds.left,y=touch.clientY-bounds.top;return{source:source,x:x,y:y,dx:downEvent?x-downEvent.x:0,dy:downEvent?y-downEvent.y:0,type:"Touch"}}var listeners=Listeners.create(),downEvent=null;this.listeners=listeners,domElement.addEventListener("mousedown",function(source){downEvent=createEventForMouse(source),listeners.notify("down",downEvent)}),domElement.addEventListener("touchstart",function(source){downEvent=createEventForTouch(source),listeners.notify("down",downEvent)}),domElement.addEventListener("mousemove",function(source){listeners.notify("move",createEventForMouse(source))}),domElement.addEventListener("touchmove",function(source){listeners.notify("move",createEventForTouch(source))}),domElement.addEventListener("mouseup",function(source){listeners.notify("up",createEventForMouse(source))}),domElement.addEventListener("touchend",function(source){listeners.notify("up",createEventForTouch(source)),downEvent=null}),domElement.addEventListener("mouseout",function(source){listeners.notify("cancel",createEventForMouse(source)),downEvent=null}),domElement.addEventListener("touchcancel",function(source){listeners.notify("cancel",createEventForTouch(source)),downEvent=null})};Input.create=function(domElement){return new Input(domElement)},Input.prototype.on=function(type,fn){return this.listeners.on(type,fn),this},Input.prototype.off=function(type,fn){return this.listeners.off(type,fn),this},module.exports=Input},{"./Listeners.js":5}],5:[function(require,module,exports){"use strict";var Listeners=function(opts){this.events={}};Listeners.create=function(opts){return new Listeners(opts)},Listeners.prototype.on=function(type,fn){return this.events[type]||(this.events[type]=[]),this.events[type].indexOf(fn)===-1&&this.events[type].push(fn),this},Listeners.prototype.off=function(type,fn){if(this.events[type]){var i=this.events[type].indexOf(fn);i!==-1&&this.events[type].splice(i,1)}return this},Listeners.prototype.notify=function(type,data){this.events[type]&&this.events[type].forEach(function(fn){fn.call(this,data)}.bind(this))},Listeners.prototype.clearAll=function(){this.events={}},module.exports=Listeners},{}],6:[function(require,module,exports){"use strict";var Rectangle=function(x,y,width,height){this._x=x,this._y=y,this._width=width,this._height=height};Rectangle.prototype.copy=function(copy){return this._x=copy.x,this._y=copy.y,this._width=copy.width,this._height=copy.height,this},Rectangle.prototype.clone=function(){return Rectangle.create(this._x,this._y,this._width,this._height)},Rectangle.prototype.round=function(){var dx=this._x,dy=this._y;return this._x=Math.round(dx),this._y=Math.round(dy),dx-=this._x,dy-=this._y,this._width=Math.round(this._width+dx),this._height=Math.round(this._height+dy),this},Rectangle.prototype.isInside=function(point){return point.x>=this.left&&point.y>=this.top&&point.xaspectRatio?delta.width=delta.height*aspectRatio:delta.height=delta.width/aspectRatio),delta.width-=bounds.width,delta.height-=bounds.height,delta}var delta=this._delta,aspectRatio=this.aspectRatio,bounds=this.bounds,boundsMinWidth=this.boundsMinWidth,boundsMinHeight=this.boundsMinHeight,target=this.target;switch("n"===p[0]?dy=Math.min(dy,this.top-target.bounds.top):"s"===p[0]&&(dy=Math.min(dy,target.bounds.bottom-this.bottom)),"w"===p[1]?dx=Math.min(dx,this.left-target.bounds.left):"e"===p[1]&&(dx=Math.min(dx,target.bounds.right-this.right)),delta=calculateDelta(dx,dy),p){case"nw":this.left-=delta.width,this.top-=delta.height;break;case"ne":this.right+=delta.width,this.top-=delta.height;break;case"sw":this.left-=delta.width,this.bottom+=delta.height;break;case"se":this.right+=delta.width,this.bottom+=delta.height}return this.updateRegionFromBounds()},Selection.prototype.autoSizeRegion=function(){var target=this.target,region=this.region,aspectRatio=this.aspectRatio,initialOpts=this.initialOpts,beforeX=region.x,beforeY=region.y,beforeWidth=region.width,beforeHeight=region.height;return region.x=void 0!==initialOpts.x?initialOpts.x:0,region.y=void 0!==initialOpts.y?initialOpts.y:0,region.width=void 0!==initialOpts.width?initialOpts.width:target.image.width,region.height=void 0!==initialOpts.height?initialOpts.height:target.image.height,aspectRatio&&(region.width/region.height>aspectRatio?region.width=region.height*aspectRatio:region.height=region.width/aspectRatio),void 0===initialOpts.x&&(region.centerX=.5*target.image.width),void 0===initialOpts.y&&(region.centerY=.5*target.image.height),region.round(),this.updateBoundsFromRegion(),region.x!==beforeX||region.y!==beforeY||region.width!==beforeWidth||region.height!==beforeHeight},Selection.prototype.updateRegionFromBounds=function(){var target=this.target,region=this.region,bounds=this.bounds,beforeX=region.x,beforeY=region.y,beforeWidth=region.width,beforeHeight=region.height;return region.x=target.image.width*(bounds.x-target.bounds.x)/target.bounds.width,region.y=target.image.height*(bounds.y-target.bounds.y)/target.bounds.height,region.width=target.image.width*(bounds.width/target.bounds.width),region.height=target.image.height*(bounds.height/target.bounds.height),region.round(),region.x!==beforeX||region.y!==beforeY||region.width!==beforeWidth||region.height!==beforeHeight},Selection.prototype.updateBoundsFromRegion=function(){var target=this.target,region=this.region,bounds=this.bounds;target.image&&(bounds.x=target.bounds.x+target.bounds.width*(region.x/target.image.width),bounds.y=target.bounds.y+target.bounds.height*(region.y/target.image.height),bounds.width=target.bounds.width*(region.width/target.image.width),bounds.height=target.bounds.height*(region.height/target.image.height)),this.boundsMinWidth=this.getBoundsLengthForRegion(this.minWidth),this.boundsMinHeight=this.getBoundsLengthForRegion(this.minHeight)},Selection.prototype.isInside=function(point){return this.bounds.isInside(point)},Selection.create=function(opts){return new Selection(opts)},module.exports=Selection},{"./Rectangle.js":6}],8:[function(require,module,exports){"use strict";var Input=require("./Input.js"),Listeners=require("./Listeners.js"),Selection=require("./Selection.js"),Rectangle=require("./Rectangle.js"),SelectionLayer=function(opts){opts=opts||{},this.selection=Selection.create(opts),this.parent=opts.parent,this.context=opts.context,this.context.setLineDash=this.context.setLineDash||function(){},this.target=opts.target;var handleOpts=opts.handle||{};handleOpts.length=handleOpts.handleLength||32,handleOpts.depth=handleOpts.depth||3,handleOpts.size=handleOpts.size||2*handleOpts.length,handleOpts.color=handleOpts.color||"rgba(255, 255, 255, 1.0)",handleOpts.activeColor=handleOpts.activeColor||"rgba(255, 0, 160, 1.0)",this.handleOpts=handleOpts,this.listeners=Listeners.create(),this.input=Input.create(this.parent.canvas),this.activeRegion=null,this.downBounds=Rectangle.create(0,0,0,0),this.input.on("down",this.onInputDown.bind(this)),this.input.on("move",this.onInputMove.bind(this)),this.input.on("up",this.onInputUpOrCancel.bind(this)).on("cancel",this.onInputUpOrCancel.bind(this))};SelectionLayer.create=function(opts){return new SelectionLayer(opts)},SelectionLayer.prototype.onInputDown=function(e){var hitRegion=this.findHitRegion(e);hitRegion&&(e.source.preventDefault(),this.activeRegion=hitRegion,this.setCursor(hitRegion),this.downBounds.copy(this.selection.bounds),this.listeners.notify("start",this.selection.region))},SelectionLayer.prototype.onInputMove=function(e){var activeRegion=this.activeRegion;if(activeRegion){e.source.preventDefault();var selection=this.selection,hasChanged=!1;if(selection.bounds.copy(this.downBounds),"move"===activeRegion)hasChanged=selection.moveBy(e.dx,e.dy),hasChanged&&this.listeners.notify("move",this.selection.region);else{var dir=activeRegion.substring(0,2),dx="w"===dir[1]?-e.dx:e.dx,dy="n"===dir[0]?-e.dy:e.dy;hasChanged=selection.resizeBy(dx,dy,dir),hasChanged&&this.listeners.notify("resize",this.selection.region)}hasChanged&&this.listeners.notify("change",this.selection.region)}else{var hitRegion=this.findHitRegion(e);hitRegion?(e.source.preventDefault(),this.setCursor(hitRegion)):this.resetCursor()}},SelectionLayer.prototype.onInputUpOrCancel=function(e){e.source.preventDefault(),this.activeRegion&&(this.activeRegion=null,this.resetCursor(),this.listeners.notify("end",this.selection.region))},SelectionLayer.prototype.findHitRegion=function(point){var hitRegion=null,closest=Number.MAX_VALUE,d=this.isWithinNorthWestHandle(point);return d!==!1&&d=1&&("%"===t[t.length-1]||void 0))}function r(t){return h(t)?t.slice(0,-1):0}function u(t){return"auto"===t}function a(t){return"number"==typeof t&&Math.round(t)===t}var c=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),l=i(9),d=n(l),f=i(3),g=n(f),y=i(5),v=n(y),p=i(8),b=n(p),w=i(4),m=n(w),x=i(1),_=n(x),k=400,R=300,M=function(){function t(e){o(this,t),this.parent="string"==typeof e.parent?document.querySelector(e.parent):e.parent,this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.boundsOpts=e.bounds||{width:"100%",height:"auto"},e.selection=e.selection||{},this.debounceResize=void 0===e.debounceResize||e.debounceResize,this.listeners=_["default"].create(),this.parent.appendChild(this.canvas),this.backgroundLayer=g["default"].create({parent:this,context:this.context,colors:e.backgroundColors||["#fff","#f0f0f0"]}),this.imageLayer=v["default"].create({parent:this,context:this.context,image:this.image}),this.selectionLayer=b["default"].create({parent:this,context:this.context,target:this.imageLayer,aspectRatio:e.selection.aspectRatio,minWidth:e.selection.minWidth,minHeight:e.selection.minHeight,x:e.selection.x,y:e.selection.y,width:e.selection.width,height:e.selection.height,handle:{color:e.selection.color,activeColor:e.selection.activeColor}});var i=this.listeners,n=this.paint.bind(this);this.selectionLayer.on("start",function(t){n(),i.notify("start",t)}).on("move",function(t){i.notify("move",t)}).on("resize",function(t){i.notify("resize",t)}).on("change",function(t){n(),i.notify("change",t)}).on("end",function(t){n(),i.notify("end",t)}),window.addEventListener("resize",this.debounceResize?(0,d["default"])(this.revalidateAndPaint.bind(this),100):this.revalidateAndPaint.bind(this)),this.setImage(e.image),this.revalidateAndPaint()}return c(t,[{key:"on",value:function(t,e){return this.listeners.on(t,e),this}},{key:"off",value:function(t,e){return this.listeners.off(t,e),this}},{key:"revalidateAndPaint",value:function(){this.revalidate(),this.paint()}},{key:"revalidate",value:function(){var t=this.parent,e=this.image,i=this.boundsOpts.width,n=this.boundsOpts.height,o=0,s=0;o=a(i)?i:t&&h(i)?Math.round(t.clientWidth*r(i)/100):k,s=a(n)?n:h(n)?Math.round(o*r(n)/100):e&&e.hasLoaded&&u(n)?Math.floor(o/e.getAspectRatio()):R,this.resizeCanvas(o,s),this.backgroundLayer.revalidate(),this.imageLayer.revalidate(),this.selectionLayer.revalidate()}},{key:"paint",value:function(){var t=this.context;t.save(),t.scale(this.ratio,this.ratio),this.backgroundLayer.paint(),this.image&&this.image.hasLoaded&&(this.imageLayer.paint(),this.selectionLayer.paint()),t.restore()}},{key:"resizeCanvas",value:function(t,e){var i=this.context,n=this.canvas;this.ratio=1,i.webkitBackingStorePixelRatio||(this.ratio=window.devicePixelRatio||1),this.width=t,this.height=e,n.width=this.width*this.ratio,n.height=this.height*this.ratio}},{key:"setImage",value:function(t){var e=this,i=m["default"].create(t).on("load",function(){e.selectionLayer.onImageLoad(),e.revalidateAndPaint()}).on("error",function(t){console.error(t)});this.imageLayer.setImage(i),this.image=i,this.revalidateAndPaint()}},{key:"getImage",value:function(){return this.image}},{key:"setAspectRatio",value:function(t){this.selectionLayer.setAspectRatio(t),this.revalidateAndPaint()}},{key:"setBounds",value:function(t){this.boundsOpts=t,this.revalidateAndPaint()}},{key:"setBackgroundColors",value:function(t){this.backgroundLayer.setColors(t),this.revalidateAndPaint()}}]),t}();M.create=function(t){return new M(t)},M.prototype.dispose=s,t.exports=M},function(t,e){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var n=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(){function t(e){i(this,t),this.events={}}return n(t,[{key:"on",value:function(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].indexOf(e)===-1&&this.events[t].push(e),this}},{key:"off",value:function(t,e){if(this.events[t]){var i=this.events[t].indexOf(e);i!==-1&&this.events[t].splice(i,1)}return this}},{key:"notify",value:function(t,e){var i=this;this.events[t]&&this.events[t].forEach(function(t){t.call(i,e)})}},{key:"clearAll",value:function(){this.events={}}}]),t}();o.create=function(t){return new o(t)},e["default"]=o},function(t,e){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var n=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(){function t(e,n,o,s){i(this,t),this._x=e,this._y=n,this._width=o,this._height=s}return n(t,[{key:"copy",value:function(t){return this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height,this}},{key:"clone",value:function(){return t.create(this._x,this._y,this._width,this._height)}},{key:"round",value:function(){var t=this._x,e=this._y;return this._x=Math.round(t),this._y=Math.round(e),t-=this._x,e-=this._y,this._width=Math.round(this._width+t),this._height=Math.round(this._height+e),this}},{key:"isInside",value:function(t){return t.x>=this.left&&t.y>=this.top&&this.right>t.x&&this.bottom>t.y}}]),t}();Object.defineProperties(o.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t}},y:{get:function(){return this._y},set:function(t){this._y=t}},centerX:{get:function(){return this._x+.5*this._width},set:function(t){this._x=t-.5*this._width}},centerY:{get:function(){return this._y+.5*this._height},set:function(t){this._y=t-.5*this._height}},width:{get:function(){return this._width},set:function(t){this._width=t}},height:{get:function(){return this._height},set:function(t){this._height=t}},left:{get:function(){return this._x},set:function(t){this._width=this._x+this._width-t,this._x=t}},top:{get:function(){return this._y},set:function(t){this._height=this._y+this._height-t,this._y=t}},right:{get:function(){return this._x+this._width},set:function(t){this._width=t-this._x}},bottom:{get:function(){return this._y+this._height},set:function(t){this._height=t-this._y}},aspectRatio:{get:function(){return this._width/this._height}}}),o.create=function(t,e,i,n){return new o(t,e,i,n)},e["default"]=o},function(t,e){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var n=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t),this.colors=e.colors,this.parent=e.parent,this.context=e.context,this.isDirty=!0}return n(t,[{key:"revalidate",value:function(){this.isDirty=!0}},{key:"setColors",value:function(t){this.colors=t}},{key:"paint",value:function(){if(this.isDirty){var t=this.parent,e=this.context;if(this.colors&&this.colors.length?(e.fillStyle=this.colors[0],e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height),this.colors&&this.colors.length>1){var i=t.height,n=32,o=t.width/n,s=Math.ceil(i/o);e.fillStyle=this.colors[1];for(var h=0;n>h;h+=1)for(var r=0;s>r;r+=1)(h+r)%2===0&&e.fillRect(h*o,r*o,o,o)}this.isDirty=!1}}}]),t}();o.create=function(t){return new o(t)},e["default"]=o},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var s=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=i(10),r=n(h),u=i(1),a=n(u),c=function(){function t(e){var i=this;if(o(this,t),this.width=0,this.height=0,this.hasLoaded=!1,this.src=null,this.listeners=a["default"].create(),e){if("string"==typeof e){this.src=e;var n=document.createElement("img");n.src=this.src,e=n}else this.src=e.src;this.source=e,(0,r["default"])(e,function(t){t?i.notify("error",t):(i.hasLoaded=!0,i.width=e.naturalWidth,i.height=e.naturalHeight,i.notify("load",i))})}}return s(t,[{key:"getAspectRatio",value:function(){return this.hasLoaded?this.width/this.height:1}},{key:"notify",value:function(t,e){var i=this.listeners;setTimeout(function(){i.notify(t,e)},0)}},{key:"on",value:function(t,e){return this.listeners.on(t,e),this}},{key:"off",value:function(t,e){return this.listeners.off(t,e),this}}]),t}();c.create=function(t){return new c(t)},e["default"]=c},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var s=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=i(2),r=n(h),u=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.bounds=r["default"].create(0,0,0,0),this.image=e.image||null,this.parent=e.parent,this.context=e.context}return s(t,[{key:"setImage",value:function(t){this.image=t}},{key:"revalidate",value:function(){var t=this.parent,e=this.image,i=this.bounds;e&&(t.width/t.height>e.width/e.height?(i.width=Math.ceil(e.width/e.height*t.height),i.height=t.height,i.x=Math.floor(.5*(t.width-i.width)),i.y=0):(i.width=t.width,i.height=Math.ceil(e.height/e.width*t.width),i.x=0,i.y=Math.floor(.5*(t.height-i.height))))}},{key:"paint",value:function(){var t=this.context,e=this.image,i=this.bounds;e&&e.hasLoaded&&t.drawImage(e.source,0,0,e.width,e.height,i.x,i.y,i.width,i.height)}}]),t}();u.create=function(t){return new u(t)},e["default"]=u},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var s=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=i(1),r=n(h),u=function(){function t(e){function i(t){var e=t.offsetX,i=t.offsetY;return{source:t,x:e,y:i,dx:h?e-h.x:0,dy:h?i-h.y:0,type:"Mouse"}}function n(t){var e=t.target.getBoundingClientRect(),i=t.touches.length>0?t.touches[0]:t.changedTouches[0],n=i.clientX-e.left,o=i.clientY-e.top;return{source:t,x:n,y:o,dx:h?n-h.x:0,dy:h?o-h.y:0,type:"Touch"}}o(this,t);var s=r["default"].create(),h=null;this.listeners=s,e.addEventListener("mousedown",function(t){h=i(t),s.notify("down",h)}),e.addEventListener("touchstart",function(t){h=n(t),s.notify("down",h)}),e.addEventListener("mousemove",function(t){s.notify("move",i(t))}),e.addEventListener("touchmove",function(t){s.notify("move",n(t))}),e.addEventListener("mouseup",function(t){s.notify("up",i(t))}),e.addEventListener("touchend",function(t){s.notify("up",n(t)),h=null}),e.addEventListener("mouseout",function(t){s.notify("cancel",i(t)),h=null}),e.addEventListener("touchcancel",function(t){s.notify("cancel",n(t)),h=null})}return s(t,[{key:"on",value:function(t,e){return this.listeners.on(t,e),this}},{key:"off",value:function(t,e){return this.listeners.off(t,e),this}}]),t}();u.create=function(t){return new u(t)},e["default"]=u},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var s=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=i(2),r=n(h),u=function(){function t(e){o(this,t),this.target=e.target||null,this.bounds=r["default"].create(0,0,0,0),this.boundsPx=r["default"].create(0,0,0,0),this.region=r["default"].create(0,0,0,0),this.initialOpts={x:e.x,y:e.y,width:e.width,height:e.height},this.aspectRatio=e.aspectRatio,this.minWidth=void 0!==e.minWidth?e.minWidth:100,this.minHeight=void 0!==e.minHeight?e.minHeight:100,this.boundsMinWidth=0,this.boundsMinHeight=0,this._delta={x:0,h:0}}return s(t,[{key:"getBoundsLengthForRegion",value:function(t){return t/this.region.width*this.width}},{key:"moveBy",value:function(t,e){var i=this.bounds,n=this.target;return i.x=Math.min(Math.max(i.x+t,n.bounds.x),n.bounds.x+n.bounds.width-i.width),i.y=Math.min(Math.max(i.y+e,n.bounds.y),n.bounds.y+n.bounds.height-i.height),this.updateRegionFromBounds()}},{key:"resizeBy",value:function(t,e,i){function n(t,e){return o.width=h.width+t,o.height=h.height+e,o.width=Math.max(r,o.width),o.height=Math.max(u,o.height),s&&(o.width/o.height>s?o.width=o.height*s:o.height=o.width/s),o.width-=h.width,o.height-=h.height,o}var o=this._delta,s=this.aspectRatio,h=this.bounds,r=this.boundsMinWidth,u=this.boundsMinHeight,a=this.target;switch("n"===i[0]?e=Math.min(e,this.top-a.bounds.top):"s"===i[0]&&(e=Math.min(e,a.bounds.bottom-this.bottom)),"w"===i[1]?t=Math.min(t,this.left-a.bounds.left):"e"===i[1]&&(t=Math.min(t,a.bounds.right-this.right)),o=n(t,e),i){case"nw":this.left-=o.width,this.top-=o.height;break;case"ne":this.right+=o.width,this.top-=o.height;break;case"sw":this.left-=o.width,this.bottom+=o.height;break;case"se":this.right+=o.width,this.bottom+=o.height}return this.updateRegionFromBounds()}},{key:"autoSizeRegion",value:function(){var t=this.target,e=this.region,i=this.aspectRatio,n=this.initialOpts,o=e.x,s=e.y,h=e.width,r=e.height;return e.x=void 0!==n.x?n.x:0,e.y=void 0!==n.y?n.y:0,e.width=void 0!==n.width?n.width:t.image.width,e.height=void 0!==n.height?n.height:t.image.height,i&&(e.width/e.height>i?e.width=e.height*i:e.height=e.width/i),void 0===n.x&&(e.centerX=.5*t.image.width),void 0===n.y&&(e.centerY=.5*t.image.height),e.round(),this.updateBoundsFromRegion(),e.x!==o||e.y!==s||e.width!==h||e.height!==r}},{key:"updateRegionFromBounds",value:function(){var t=this.target,e=this.region,i=this.bounds,n=e.x,o=e.y,s=e.width,h=e.height;return e.x=t.image.width*(i.x-t.bounds.x)/t.bounds.width,e.y=t.image.height*(i.y-t.bounds.y)/t.bounds.height,e.width=t.image.width*(i.width/t.bounds.width),e.height=t.image.height*(i.height/t.bounds.height),e.round(),e.x!==n||e.y!==o||e.width!==s||e.height!==h}},{key:"updateBoundsFromRegion",value:function(){var t=this.target,e=this.region,i=this.bounds;t.image&&(i.x=t.bounds.x+t.bounds.width*(e.x/t.image.width),i.y=t.bounds.y+t.bounds.height*(e.y/t.image.height),i.width=t.bounds.width*(e.width/t.image.width),i.height=t.bounds.height*(e.height/t.image.height)),this.boundsMinWidth=this.getBoundsLengthForRegion(this.minWidth),this.boundsMinHeight=this.getBoundsLengthForRegion(this.minHeight)}},{key:"isInside",value:function(t){return this.bounds.isInside(t)}}]),t}();Object.defineProperties(u.prototype,{x:{get:function(){return this.bounds.x},set:function(t){this.bounds.x=t}},y:{get:function(){return this.bounds.y},set:function(t){this.bounds.y=t}},width:{get:function(){return this.bounds.width},set:function(t){this.bounds.width=t}},height:{get:function(){return this.bounds.height},set:function(t){this.bounds.height=t}},left:{get:function(){return this.bounds.x},set:function(t){this.bounds.left=t}},top:{get:function(){return this.bounds.y},set:function(t){this.bounds.top=t}},right:{get:function(){return this.bounds.right},set:function(t){this.bounds.right=t}},bottom:{get:function(){return this.bounds.bottom},set:function(t){this.bounds.bottom=t}}}),u.create=function(t){return new u(t)},e["default"]=u},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var s=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),h=i(6),r=n(h),u=i(1),a=n(u),c=i(7),l=n(c),d=i(2),f=n(d),g=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.selection=l["default"].create(e),this.parent=e.parent,this.context=e.context,this.context.setLineDash=this.context.setLineDash||function(){},this.target=e.target;var i=e.handle||{};i.length=i.handleLength||32,i.depth=i.depth||3,i.size=i.size||2*i.length,i.color=i.color||"rgba(255, 255, 255, 1.0)",i.activeColor=i.activeColor||"rgba(255, 0, 160, 1.0)",this.handleOpts=i,this.listeners=a["default"].create(),this.input=r["default"].create(this.parent.canvas),this.activeRegion=null,this.downBounds=f["default"].create(0,0,0,0),this.input.on("down",this.onInputDown.bind(this)),this.input.on("move",this.onInputMove.bind(this)),this.input.on("up",this.onInputUpOrCancel.bind(this)).on("cancel",this.onInputUpOrCancel.bind(this))}return s(t,[{key:"onInputDown",value:function(t){var e=this.findHitRegion(t);e&&(t.source.preventDefault(),this.activeRegion=e,this.setCursor(e),this.downBounds.copy(this.selection.bounds),this.listeners.notify("start",this.selection.region))}},{key:"onInputMove",value:function(t){var e=this.activeRegion;if(e){t.source.preventDefault();var i=this.selection,n=!1;if(i.bounds.copy(this.downBounds),"move"===e)n=i.moveBy(t.dx,t.dy),n&&this.listeners.notify("move",this.selection.region);else{var o=e.substring(0,2),s="w"===o[1]?-t.dx:t.dx,h="n"===o[0]?-t.dy:t.dy;n=i.resizeBy(s,h,o),n&&this.listeners.notify("resize",this.selection.region)}n&&this.listeners.notify("change",this.selection.region)}else{var r=this.findHitRegion(t);r?(t.source.preventDefault(),this.setCursor(r)):this.resetCursor()}}},{key:"onInputUpOrCancel",value:function(t){t.source.preventDefault(),this.activeRegion&&(this.activeRegion=null,this.resetCursor(),this.listeners.notify("end",this.selection.region))}},{key:"findHitRegion",value:function(t){var e=null,i=Number.MAX_VALUE,n=this.isWithinNorthWestHandle(t);return n!==!1&&i>n&&(i=n,e="nw-resize"),n=this.isWithinNorthEastHandle(t),n!==!1&&i>n&&(i=n,e="ne-resize"),n=this.isWithinSouthWestHandle(t),n!==!1&&i>n&&(i=n,e="sw-resize"),n=this.isWithinSouthEastHandle(t),n!==!1&&i>n&&(i=n,e="se-resize"),e?e:this.isWithinBounds(t)?"move":null}},{key:"on",value:function(t,e){return this.listeners.on(t,e),this}},{key:"off",value:function(t,e){return this.listeners.off(t,e),this}},{key:"setCursor",value:function(t){this.parent.canvas.style.cursor!==t&&(this.parent.canvas.style.cursor=t)}},{key:"resetCursor",value:function(){this.setCursor("auto")}},{key:"isWithinRadius",value:function(t,e,i,n,o){var s=o*o,h=t-i,r=e-n,u=h*h+r*r;return s>u&&u}},{key:"isWithinNorthWestHandle",value:function(t){return this.isWithinRadius(t.x,t.y,this.selection.left,this.selection.top,this.getHandleRadius())}},{key:"isWithinNorthEastHandle",value:function(t){return this.isWithinRadius(t.x,t.y,this.selection.right,this.selection.top,this.getHandleRadius())}},{key:"isWithinSouthWestHandle",value:function(t){return this.isWithinRadius(t.x,t.y,this.selection.left,this.selection.bottom,this.getHandleRadius())}},{key:"isWithinSouthEastHandle",value:function(t){return this.isWithinRadius(t.x,t.y,this.selection.right,this.selection.bottom,this.getHandleRadius())}},{key:"isWithinBounds",value:function(t){return this.selection.isInside(t)}},{key:"getHandleRadius",value:function(){return this.handleOpts.size/2}},{key:"onImageLoad",value:function(){this.autoSizeRegionAndNotify()}},{key:"setAspectRatio",value:function(t){this.selection.aspectRatio=t,this.autoSizeRegionAndNotify()}},{key:"autoSizeRegionAndNotify",value:function(){var t=this.selection.autoSizeRegion();t&&this.listeners.notify("change",this.selection.region)}},{key:"revalidate",value:function(){this.selection.updateBoundsFromRegion()}},{key:"paint",value:function(){this.selection.boundsPx.copy(this.selection.bounds).round(),this.paintOutside(),this.paintInside()}},{key:"paintOutside",value:function(){var t=this.selection.boundsPx,e=this.context,i=this.target,n=i.bounds.x,o=i.bounds.y,s=i.bounds.width,h=i.bounds.right,r=i.bounds.bottom,u=t.x,a=t.y,c=t.height,l=t.right,d=t.bottom;e.fillStyle="rgba(0, 0, 0, 0.5)",e.fillRect(n,o,s,a-o),e.fillRect(n,a,u-n,c),e.fillRect(l,a,h-l,c),e.fillRect(n,d,s,r-d)}},{key:"paintInside",value:function(){var t=this.context,e=this.selection.boundsPx,i=this.activeRegion,n=this.handleOpts,o=Math.min(n.length,.5*e.width),s=Math.min(n.length,.5*e.height),h=n.depth,r=n.color,u=n.activeColor,a=0;t.fillStyle="rgba(255, 255, 255, 0.3)",t.fillRect(e.x+a,e.y,e.width-2*a,h),t.fillRect(e.x+a,e.bottom-h,e.width-2*a,h),t.fillRect(e.x,e.y+a,h,e.height-2*a),t.fillRect(e.right-h,e.y+a,h,e.height-2*a);var c="move"===i;t.fillStyle=c||"nw-resize"===i?u:r,t.fillRect(e.x,e.y,o,h),t.fillRect(e.x,e.y+h,h,s-h),t.fillStyle=c||"ne-resize"===i?u:r,t.fillRect(e.right-o,e.y,o,h),t.fillRect(e.right-h,e.y+h,h,s-h),t.fillStyle=c||"sw-resize"===i?u:r,t.fillRect(e.x,e.bottom-h,o,h),t.fillRect(e.x,e.bottom-s,h,s-h),t.fillStyle=c||"se-resize"===i?u:r,t.fillRect(e.right-o,e.bottom-h,o,h),t.fillRect(e.right-h,e.bottom-s,h,s-h),t.strokeStyle="rgba(255, 255, 255, 0.6)",t.setLineDash([2,3]),t.lineWidth=1,t.beginPath();var l=e.width/3,d=e.height/3;t.moveTo(e.x+l,e.y),t.lineTo(e.x+l,e.y+e.height),t.moveTo(e.x+2*l,e.y),t.lineTo(e.x+2*l,e.y+e.height),t.moveTo(e.x,e.y+d),t.lineTo(e.x+e.width,e.y+d),t.moveTo(e.x,e.y+2*d),t.lineTo(e.x+e.width,e.y+2*d),t.stroke(),t.closePath()}}]),t}();g.create=function(t){return new g(t)},e["default"]=g},function(t,e){"use strict";function i(t,e,i){var n=void 0;return function(){var o=this,s=arguments;clearTimeout(n),n=setTimeout(function(){n=null,i||t.apply(o,s)},e),i&&!n&&t.apply(o,s)}}e.__esModule=!0,e["default"]=i},function(t,e){"use strict";function i(t,e){if(!t.nodeName||"img"!==t.nodeName.toLowerCase())return e(Error("First argument must an image element"));if(t.src&&t.complete&&void 0!==t.naturalWidth)return e(null,!0);if(t.addEventListener("load",function(){e(null,!1)}),t.addEventListener("error",function(i){e(Error("Failed to load image '"+(t.src||"")+"'"))}),t.complete){var i=t.src;t.src=n,t.src=i}}e.__esModule=!0;var n="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";e["default"]=i}])}); \ No newline at end of file diff --git a/es/.keep b/es/.keep new file mode 100644 index 0000000..e69de29 diff --git a/examples/react/bundle.js b/examples/react/bundle.js deleted file mode 100644 index 8526d72..0000000 --- a/examples/react/bundle.js +++ /dev/null @@ -1,22212 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o camelize('background-color') - * < "backgroundColor" - * - * @param {string} string - * @return {string} - */ -function camelize(string) { - return string.replace(_hyphenPattern, function (_, character) { - return character.toUpperCase(); - }); -} - -module.exports = camelize; -},{}],6:[function(require,module,exports){ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @typechecks - */ - -'use strict'; - -var camelize = require('./camelize'); - -var msPattern = /^-ms-/; - -/** - * Camelcases a hyphenated CSS property name, for example: - * - * > camelizeStyleName('background-color') - * < "backgroundColor" - * > camelizeStyleName('-moz-transition') - * < "MozTransition" - * > camelizeStyleName('-ms-transition') - * < "msTransition" - * - * As Andi Smith suggests - * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix - * is converted to lowercase `ms`. - * - * @param {string} string - * @return {string} - */ -function camelizeStyleName(string) { - return camelize(string.replace(msPattern, 'ms-')); -} - -module.exports = camelizeStyleName; -},{"./camelize":5}],7:[function(require,module,exports){ -'use strict'; - -/** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -var isTextNode = require('./isTextNode'); - -/*eslint-disable no-bitwise */ - -/** - * Checks if a given DOM node contains or is another DOM node. - */ -function containsNode(outerNode, innerNode) { - if (!outerNode || !innerNode) { - return false; - } else if (outerNode === innerNode) { - return true; - } else if (isTextNode(outerNode)) { - return false; - } else if (isTextNode(innerNode)) { - return containsNode(outerNode, innerNode.parentNode); - } else if ('contains' in outerNode) { - return outerNode.contains(innerNode); - } else if (outerNode.compareDocumentPosition) { - return !!(outerNode.compareDocumentPosition(innerNode) & 16); - } else { - return false; - } -} - -module.exports = containsNode; -},{"./isTextNode":20}],8:[function(require,module,exports){ -(function (process){ -'use strict'; - -/** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @typechecks - */ - -var invariant = require('./invariant'); - -/** - * Convert array-like objects to arrays. - * - * This API assumes the caller knows the contents of the data type. For less - * well defined inputs use createArrayFromMixed. - * - * @param {object|function|filelist} obj - * @return {array} - */ -function toArray(obj) { - var length = obj.length; - - // Some browsers builtin objects can report typeof 'function' (e.g. NodeList - // in old versions of Safari). - !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0; - - !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0; - - !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0; - - !(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0; - - // Old IE doesn't give collections access to hasOwnProperty. Assume inputs - // without method will throw during the slice call and skip straight to the - // fallback. - if (obj.hasOwnProperty) { - try { - return Array.prototype.slice.call(obj); - } catch (e) { - // IE < 9 does not support Array#slice on collections objects - } - } - - // Fall back to copying key by key. This assumes all keys have a value, - // so will not preserve sparsely populated inputs. - var ret = Array(length); - for (var ii = 0; ii < length; ii++) { - ret[ii] = obj[ii]; - } - return ret; -} - -/** - * Perform a heuristic test to determine if an object is "array-like". - * - * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" - * Joshu replied: "Mu." - * - * This function determines if its argument has "array nature": it returns - * true if the argument is an actual array, an `arguments' object, or an - * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). - * - * It will return false for other array-like objects like Filelist. - * - * @param {*} obj - * @return {boolean} - */ -function hasArrayNature(obj) { - return ( - // not null/false - !!obj && ( - // arrays are objects, NodeLists are functions in Safari - typeof obj == 'object' || typeof obj == 'function') && - // quacks like an array - 'length' in obj && - // not window - !('setInterval' in obj) && - // no DOM node should be considered an array-like - // a 'select' element has 'length' and 'item' properties on IE8 - typeof obj.nodeType != 'number' && ( - // a real array - Array.isArray(obj) || - // arguments - 'callee' in obj || - // HTMLCollection/NodeList - 'item' in obj) - ); -} - -/** - * Ensure that the argument is an array by wrapping it in an array if it is not. - * Creates a copy of the argument if it is already an array. - * - * This is mostly useful idiomatically: - * - * var createArrayFromMixed = require('createArrayFromMixed'); - * - * function takesOneOrMoreThings(things) { - * things = createArrayFromMixed(things); - * ... - * } - * - * This allows you to treat `things' as an array, but accept scalars in the API. - * - * If you need to convert an array-like object, like `arguments`, into an array - * use toArray instead. - * - * @param {*} obj - * @return {array} - */ -function createArrayFromMixed(obj) { - if (!hasArrayNature(obj)) { - return [obj]; - } else if (Array.isArray(obj)) { - return obj.slice(); - } else { - return toArray(obj); - } -} - -module.exports = createArrayFromMixed; -}).call(this,require('_process')) - -},{"./invariant":18,"_process":29}],9:[function(require,module,exports){ -(function (process){ -'use strict'; - -/** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @typechecks - */ - -/*eslint-disable fb-www/unsafe-html*/ - -var ExecutionEnvironment = require('./ExecutionEnvironment'); - -var createArrayFromMixed = require('./createArrayFromMixed'); -var getMarkupWrap = require('./getMarkupWrap'); -var invariant = require('./invariant'); - -/** - * Dummy container used to render all markup. - */ -var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; - -/** - * Pattern used by `getNodeName`. - */ -var nodeNamePattern = /^\s*<(\w+)/; - -/** - * Extracts the `nodeName` of the first element in a string of markup. - * - * @param {string} markup String of markup. - * @return {?string} Node name of the supplied markup. - */ -function getNodeName(markup) { - var nodeNameMatch = markup.match(nodeNamePattern); - return nodeNameMatch && nodeNameMatch[1].toLowerCase(); -} - -/** - * Creates an array containing the nodes rendered from the supplied markup. The - * optionally supplied `handleScript` function will be invoked once for each - *