vue-drag-resize-rotate
Version:
a vue2 component. Taking a cue from react-resizable and react-draggable.
3,061 lines • 83.1 kB
JavaScript
(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["VueDragResizeRotate"] = factory();
else
root["VueDragResizeRotate"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // 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__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _vueDragResizeRotate = __webpack_require__(1);
var _vueDragResizeRotate2 = _interopRequireDefault(_vueDragResizeRotate);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = _vueDragResizeRotate2.default;
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
var __vue_exports__, __vue_options__
var __vue_styles__ = {}
/* styles */
__webpack_require__(2)
/* script */
__vue_exports__ = __webpack_require__(6)
/* template */
var __vue_template__ = __webpack_require__(65)
__vue_options__ = __vue_exports__ = __vue_exports__ || {}
if (
typeof __vue_exports__.default === "object" ||
typeof __vue_exports__.default === "function"
) {
if (Object.keys(__vue_exports__).some(function (key) { return key !== "default" && key !== "__esModule" })) {console.error("named exports are not supported in *.vue files.")}
__vue_options__ = __vue_exports__ = __vue_exports__.default
}
if (typeof __vue_options__ === "function") {
__vue_options__ = __vue_options__.options
}
__vue_options__.__file = "/Users/tigerlove/vue/vue-drag-resize-rotate/src/vue-drag-resize-rotate.vue"
__vue_options__.render = __vue_template__.render
__vue_options__.staticRenderFns = __vue_template__.staticRenderFns
__vue_options__._scopeId = "data-v-b85935aa"
/* hot reload */
if (false) {(function () {
var hotAPI = require("vue-hot-reload-api")
hotAPI.install(require("vue"), false)
if (!hotAPI.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotAPI.createRecord("data-v-b85935aa", __vue_options__)
} else {
hotAPI.reload("data-v-b85935aa", __vue_options__)
}
})()}
if (__vue_options__.functional) {console.error("[vue-loader] vue-drag-resize-rotate.vue: functional components are not supported and should be defined in plain js files using render functions.")}
module.exports = __vue_exports__
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(3);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(5)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!./../node_modules/css-loader/index.js!./../node_modules/vue-loader/lib/style-rewriter.js?id=data-v-b85935aa&scoped=true!./../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./vue-drag-resize-rotate.vue", function() {
var newContent = require("!!./../node_modules/css-loader/index.js!./../node_modules/vue-loader/lib/style-rewriter.js?id=data-v-b85935aa&scoped=true!./../node_modules/vue-loader/lib/selector.js?type=styles&index=0!./vue-drag-resize-rotate.vue");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(4)();
// imports
// module
exports.push([module.id, "\n.dragable[data-v-b85935aa] {\n position: relative;\n border: 1px solid black;\n text-align: center;\n padding: 10px;\n background: #fff;\n box-sizing: border-box;\n overflow: hidden;\n float: left;\n margin: 10px;\n}\n.scale[data-v-b85935aa] {\n position: absolute;\n width: 20px;\n height: 20px;\n bottom: 0;\n right: 0;\n background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pg08IS0tIEdlbmVyYXRvcjogQWRvYmUgRmlyZXdvcmtzIENTNiwgRXhwb3J0IFNWRyBFeHRlbnNpb24gYnkgQWFyb24gQmVhbGwgKGh0dHA6Ly9maXJld29ya3MuYWJlYWxsLmNvbSkgLiBWZXJzaW9uOiAwLjYuMSAgLS0+DTwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DTxzdmcgaWQ9IlVudGl0bGVkLVBhZ2UlMjAxIiB2aWV3Qm94PSIwIDAgNiA2IiBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjojZmZmZmZmMDAiIHZlcnNpb249IjEuMSINCXhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbDpzcGFjZT0icHJlc2VydmUiDQl4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjZweCIgaGVpZ2h0PSI2cHgiDT4NCTxnIG9wYWNpdHk9IjAuMzAyIj4NCQk8cGF0aCBkPSJNIDYgNiBMIDAgNiBMIDAgNC4yIEwgNCA0LjIgTCA0LjIgNC4yIEwgNC4yIDAgTCA2IDAgTCA2IDYgTCA2IDYgWiIgZmlsbD0iIzAwMDAwMCIvPg0JPC9nPg08L3N2Zz4=');\n background-position: bottom right;\n padding: 0 3px 3px 0;\n background-repeat: no-repeat;\n background-origin: content-box;\n box-sizing: border-box;\n cursor: se-resize;\n}\n.rotate[data-v-b85935aa] {\n position: absolute;\n width: 20px;\n height: 20px;\n top: 0;\n right: 0;\n background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjYiIGhlaWdodD0iNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz4KICA8dGl0bGU+YmFja2dyb3VuZDwvdGl0bGU+CiAgPHJlY3QgZmlsbD0ibm9uZSIgaWQ9ImNhbnZhc19iYWNrZ3JvdW5kIiBoZWlnaHQ9IjQwMiIgd2lkdGg9IjU4MiIgeT0iLTEiIHg9Ii0xIi8+CiA8L2c+CiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPGcgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDMuMDAwMDAwMDAwMDAwMDAwNCwzKSAiIGlkPSJzdmdfMSIgb3BhY2l0eT0iMC4zMDIiPgogICA8cGF0aCBpZD0ic3ZnXzIiIGZpbGw9IiMwMDAwMDAiIGQ9Im02LDZsLTYsMGwwLC0xLjhsNCwwbDAuMiwwbDAsLTQuMmwxLjgsMGwwLDZsMCwweiIvPgogIDwvZz4KIDwvZz4KPC9zdmc+');\n background-position: top right;\n padding: 3px 3px 0px 0;\n background-repeat: no-repeat;\n background-origin: content-box;\n box-sizing: border-box;\n cursor: se-resize;\n}\n", ""]);
// exports
/***/ },
/* 4 */
/***/ function(module, exports) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function() {
var list = [];
// return the list of modules as css string
list.toString = function toString() {
var result = [];
for(var i = 0; i < this.length; i++) {
var item = this[i];
if(item[2]) {
result.push("@media " + item[2] + "{" + item[1] + "}");
} else {
result.push(item[1]);
}
}
return result.join("");
};
// import a list of modules into the list
list.i = function(modules, mediaQuery) {
if(typeof modules === "string")
modules = [[null, modules, ""]];
var alreadyImportedModules = {};
for(var i = 0; i < this.length; i++) {
var id = this[i][0];
if(typeof id === "number")
alreadyImportedModules[id] = true;
}
for(i = 0; i < modules.length; i++) {
var item = modules[i];
// skip already imported module
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
if(mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if(mediaQuery) {
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
}
list.push(item);
}
}
};
return list;
};
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var stylesInDom = {},
memoize = function(fn) {
var memo;
return function () {
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
return memo;
};
},
isOldIE = memoize(function() {
return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
}),
getHeadElement = memoize(function () {
return document.head || document.getElementsByTagName("head")[0];
}),
singletonElement = null,
singletonCounter = 0,
styleElementsInsertedAtTop = [];
module.exports = function(list, options) {
if(false) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
options = options || {};
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (typeof options.singleton === "undefined") options.singleton = isOldIE();
// By default, add <style> tags to the bottom of <head>.
if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
var styles = listToStyles(list);
addStylesToDom(styles, options);
return function update(newList) {
var mayRemove = [];
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
domStyle.refs--;
mayRemove.push(domStyle);
}
if(newList) {
var newStyles = listToStyles(newList);
addStylesToDom(newStyles, options);
}
for(var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if(domStyle.refs === 0) {
for(var j = 0; j < domStyle.parts.length; j++)
domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
}
function addStylesToDom(styles, options) {
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
if(domStyle) {
domStyle.refs++;
for(var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
}
for(; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j], options));
}
} else {
var parts = [];
for(var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j], options));
}
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
}
}
}
function listToStyles(list) {
var styles = [];
var newStyles = {};
for(var i = 0; i < list.length; i++) {
var item = list[i];
var id = item[0];
var css = item[1];
var media = item[2];
var sourceMap = item[3];
var part = {css: css, media: media, sourceMap: sourceMap};
if(!newStyles[id])
styles.push(newStyles[id] = {id: id, parts: [part]});
else
newStyles[id].parts.push(part);
}
return styles;
}
function insertStyleElement(options, styleElement) {
var head = getHeadElement();
var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
if (options.insertAt === "top") {
if(!lastStyleElementInsertedAtTop) {
head.insertBefore(styleElement, head.firstChild);
} else if(lastStyleElementInsertedAtTop.nextSibling) {
head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
} else {
head.appendChild(styleElement);
}
styleElementsInsertedAtTop.push(styleElement);
} else if (options.insertAt === "bottom") {
head.appendChild(styleElement);
} else {
throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
}
}
function removeStyleElement(styleElement) {
styleElement.parentNode.removeChild(styleElement);
var idx = styleElementsInsertedAtTop.indexOf(styleElement);
if(idx >= 0) {
styleElementsInsertedAtTop.splice(idx, 1);
}
}
function createStyleElement(options) {
var styleElement = document.createElement("style");
styleElement.type = "text/css";
insertStyleElement(options, styleElement);
return styleElement;
}
function addStyle(obj, options) {
var styleElement, update, remove;
if (options.singleton) {
var styleIndex = singletonCounter++;
styleElement = singletonElement || (singletonElement = createStyleElement(options));
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
} else {
styleElement = createStyleElement(options);
update = applyToTag.bind(null, styleElement);
remove = function() {
removeStyleElement(styleElement);
};
}
update(obj);
return function updateStyle(newObj) {
if(newObj) {
if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
return;
update(obj = newObj);
} else {
remove();
}
};
}
var replaceText = (function () {
var textStore = [];
return function (index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
})();
function applyToSingletonTag(styleElement, index, remove, obj) {
var css = remove ? "" : obj.css;
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = styleElement.childNodes;
if (childNodes[index]) styleElement.removeChild(childNodes[index]);
if (childNodes.length) {
styleElement.insertBefore(cssNode, childNodes[index]);
} else {
styleElement.appendChild(cssNode);
}
}
}
function applyToTag(styleElement, obj) {
var css = obj.css;
var media = obj.media;
var sourceMap = obj.sourceMap;
if (media) {
styleElement.setAttribute("media", media);
}
if (sourceMap) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */';
// http://stackoverflow.com/a/26603875
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
while(styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild);
}
styleElement.appendChild(document.createTextNode(css));
}
}
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _slicedToArray2 = __webpack_require__(7);
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
var _victor = __webpack_require__(64);
var _victor2 = _interopRequireDefault(_victor);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var findInArray = function findInArray(array, callback) {
for (var i = 0, length = array.length; i < length; i++) {
if (callback.apply(callback, [array[i], i, array])) return array[i];
}
};
var isFunction = function isFunction(func) {
return typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]';
};
var isNum = function isNum(num) {
return typeof num === 'number' && !isNaN(num);
};
var int = function int(a) {
return parseInt(a, 10);
};
var outerHeight = function outerHeight(node) {
var height = node.clientHeight;
var computedStyle = window.getComputedStyle(node);
height += int(computedStyle.borderTopWidth);
height += int(computedStyle.borderBottomWidth);
return height;
};
var outerWidth = function outerWidth(node) {
var width = node.clientWidth;
var computedStyle = window.getComputedStyle(node);
width += int(computedStyle.borderLeftWidth);
width += int(computedStyle.borderRightWidth);
return width;
};
var innerHeight = function innerHeight(node) {
var height = node.clientHeight;
var computedStyle = window.getComputedStyle(node);
height -= int(computedStyle.paddingTop);
height -= int(computedStyle.paddingBottom);
return height;
};
var innerWidth = function innerWidth(node) {
var width = node.clientWidth;
var computedStyle = window.getComputedStyle(node);
width -= int(computedStyle.paddingLeft);
width -= int(computedStyle.paddingRight);
return width;
};
var matchesSelectorFunc = '';
var matchesSelector = function matchesSelector(el, selector) {
if (!matchesSelectorFunc) {
matchesSelectorFunc = findInArray(['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'], function (method) {
return isFunction(el[method]);
});
}
return el[matchesSelectorFunc].call(el, selector);
};
var getBoundPosition = function getBoundPosition(bounds, node, clientX, clientY) {
if (!bounds) return [clientX, clientY];
var parent = node.parentNode;
if (bounds.parent) {
var nodeStyle = window.getComputedStyle(node);
var parentStyle = window.getComputedStyle(parent);
bounds = {
left: -node.offsetLeft + int(parentStyle.paddingLeft) + int(nodeStyle.borderLeftWidth) + int(nodeStyle.marginLeft),
top: -node.offsetTop + int(parentStyle.paddingTop) + int(nodeStyle.borderTopWidth) + int(nodeStyle.marginTop),
right: innerWidth(parent) - node.offsetLeft - outerWidth(node),
bottom: innerHeight(parent) - outerHeight(node) - node.offsetTop
};
}
if (isNum(bounds.right)) clientX = Math.min(clientX, bounds.right);
if (isNum(bounds.bottom)) clientY = Math.min(clientY, bounds.bottom);
if (isNum(bounds.left)) clientX = Math.max(clientX, bounds.left);
if (isNum(bounds.top)) clientY = Math.max(clientY, bounds.top);
return [clientX, clientY];
};
exports.default = {
replace: true,
name: 'dragable',
props: {
w: {
type: Number,
default: 200
},
h: {
type: Number,
default: 200
},
x: {
type: Number,
default: 0
},
y: {
type: Number,
default: 0
},
r: {
type: Number,
default: 0
},
rotatable: {
type: Boolean,
default: false
},
axis: {
type: String,
default: 'both'
},
handle: {
type: String,
default: ''
},
cancel: {
type: String,
default: ''
},
grid: {
type: Array,
default: function _default() {
return [0, 0];
}
},
bounds: {
type: Object,
default: null
}
},
mounted: function mounted() {
var el = document.documentElement;
var event = 'mousemove';
var handler = this.handleMove;
if (el.attachEvent) {
el.attachEvent('on' + event, handler);
} else if (el.addEventListener) {
el.addEventListener(event, handler, true);
} else {
el['on' + event] = handler;
}
if (!this.rotatable) {
this.$el.getElementsByClassName('rotate')[0].className = '';
} else {
this.rotate = this.r;
}
},
beforeDestroy: function beforeDestroy() {
var el = document.documentElement;
var event = 'mousemove';
var handler = this.handleMove;
if (el.detachEvent) {
el.detachEvent('on' + event, handler);
} else if (el.removeEventListener) {
el.removeEventListener(event, handler, true);
} else {
el['on' + event] = null;
}
},
methods: {
getRotateAngle: function getRotateAngle(x, y) {
var rCenter = this._getCenter();
var vStart = new _victor2.default(this.rotateStartX - rCenter.x, this.rotateStartY - rCenter.y);
var vEnd = new _victor2.default(x - rCenter.x, y - rCenter.y);
return vEnd.angleDeg() - vStart.angleDeg();
},
_getCenter: function _getCenter() {
var rect = this.$el.getBoundingClientRect();
return {
x: (rect.left + rect.right) / 2,
y: (rect.bottom + rect.top) / 2
};
},
rotateStart: function rotateStart(e) {
if (this.rotatable) {
this.rotateStartX = e.clientX;
this.rotateStartY = e.clientY;
this.rotating = true;
}
},
resizeStart: function resizeStart(e) {
this.resizeStartX = e.clientX;
this.resizeStartY = e.clientY;
this.resizing = true;
this.lastW = this.localw;
this.lastH = this.localh;
},
handleDown: function handleDown(e) {
if (this.handle && !matchesSelector(e.target, this.handle)) {
return;
}
if (this.cancel && matchesSelector(e.target, this.cancel)) {
return;
}
if (!this.lastX) {
this.lastX = e.clientX;
this.lastY = e.clientY;
}
this.dragging = true;
},
handleUp: function handleUp(e) {
this.dragging = false;
this.resizing = false;
this.rotating = false;
this.$emit('handleUp', {
x: this.localx,
y: this.localy,
w: this.localw,
h: this.localh,
r: this.localr
});
},
handleMove: function handleMove(e) {
if (e.stopPropagation) e.stopPropagation();
if (e.preventDefault) e.preventDefault();
if (this.dragging) {
var deltax = e.clientX - this.lastX;
var deltay = e.clientY - this.lastY;
var deltaxround = Math.round(deltax / this.grid[0]) * this.grid[0];
var deltayround = Math.round(deltay / this.grid[1]) * this.grid[1];
var thisx = this.localx;
var thisy = this.localy;
if (this.grid[0] > 0 && this.grid[1] > 0) {
if (this.axis === 'both') {
thisx = deltaxround;
thisy = deltayround;
} else if (this.axis === 'x') {
thisx = deltaxround;
} else if (this.axis === 'y') {
thisy = deltayround;
}
} else {
if (this.axis === 'both') {
thisx = e.clientX - this.lastX;
thisy = e.clientY - this.lastY;
} else if (this.axis === 'x') {
thisx = e.clientX - this.lastX;
} else if (this.axis === 'y') {
thisy = e.clientY - this.lastY;
}
}
if (this.bounds) {
var _getBoundPosition = getBoundPosition(this.bounds, this.$el, thisx, thisy);
var _getBoundPosition2 = (0, _slicedToArray3.default)(_getBoundPosition, 2);
thisx = _getBoundPosition2[0];
thisy = _getBoundPosition2[1];
}
this.localx = thisx;
this.localy = thisy;
}
if (this.resizing) {
this.localw = parseInt(this.lastW) + parseInt(e.clientX) - parseInt(this.resizeStartX);
this.localh = parseInt(this.lastH) + parseInt(e.clientY) - parseInt(this.resizeStartY);
}
if (this.rotating) {
this.localr = parseInt(this.r) + this.getRotateAngle(e.clientX, e.clientY);
}
}
},
data: function data() {
return {
localx: this.x,
localy: this.y,
localw: this.w,
localh: this.h,
localr: this.r,
lastX: 0,
lastY: 0,
dragging: false,
rotate: 0,
resizeStartX: 0,
resizeStartY: 0,
rotateStartX: 0,
rotateStartY: 0,
resizing: false
};
},
computed: {
boxStyle: function boxStyle() {
return {
width: this.localw + 'px',
height: this.localh + 'px',
transform: 'translate(' + this.localx + 'px,' + this.localy + 'px) rotate(' + this.localr + 'deg)'
};
}
}
};
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _isIterable2 = __webpack_require__(8);
var _isIterable3 = _interopRequireDefault(_isIterable2);
var _getIterator2 = __webpack_require__(60);
var _getIterator3 = _interopRequireDefault(_getIterator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if ((0, _isIterable3.default)(Object(arr))) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(9), __esModule: true };
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(10);
__webpack_require__(56);
module.exports = __webpack_require__(58);
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(11);
var global = __webpack_require__(22)
, hide = __webpack_require__(26)
, Iterators = __webpack_require__(14)
, TO_STRING_TAG = __webpack_require__(53)('toStringTag');
for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
var NAME = collections[i]
, Collection = global[NAME]
, proto = Collection && Collection.prototype;
if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
Iterators[NAME] = Iterators.Array;
}
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var addToUnscopables = __webpack_require__(12)
, step = __webpack_require__(13)
, Iterators = __webpack_require__(14)
, toIObject = __webpack_require__(15);
// 22.1.3.4 Array.prototype.entries()
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
module.exports = __webpack_require__(19)(Array, 'Array', function(iterated, kind){
this._t = toIObject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
}, function(){
var O = this._t
, kind = this._k
, index = this._i++;
if(!O || index >= O.length){
this._t = undefined;
return step(1);
}
if(kind == 'keys' )return step(0, index);
if(kind == 'values')return step(0, O[index]);
return step(0, [index, O[index]]);
}, 'values');
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
Iterators.Arguments = Iterators.Array;
addToUnscopables('keys');
addToUnscopables('values');
addToUnscopables('entries');
/***/ },
/* 12 */
/***/ function(module, exports) {
module.exports = function(){ /* empty */ };
/***/ },
/* 13 */
/***/ function(module, exports) {
module.exports = function(done, value){
return {value: value, done: !!done};
};
/***/ },
/* 14 */
/***/ function(module, exports) {
module.exports = {};
/***/ },
/* 15 */
/***/ function(module, exports, __webpack_require__) {
// to indexed object, toObject with fallback for non-array-like ES3 strings
var IObject = __webpack_require__(16)
, defined = __webpack_require__(18);
module.exports = function(it){
return IObject(defined(it));
};
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
// fallback for non-array-like ES3 and non-enumerable old V8 strings
var cof = __webpack_require__(17);
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
return cof(it) == 'String' ? it.split('') : Object(it);
};
/***/ },
/* 17 */
/***/ function(module, exports) {
var toString = {}.toString;
module.exports = function(it){
return toString.call(it).slice(8, -1);
};
/***/ },
/* 18 */
/***/ function(module, exports) {
// 7.2.1 RequireObjectCoercible(argument)
module.exports = function(it){
if(it == undefined)throw TypeError("Can't call method on " + it);
return it;
};
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var LIBRARY = __webpack_require__(20)
, $export = __webpack_require__(21)
, redefine = __webpack_require__(36)
, hide = __webpack_require__(26)
, has = __webpack_require__(37)
, Iterators = __webpack_require__(14)
, $iterCreate = __webpack_require__(38)
, setToStringTag = __webpack_require__(52)
, getPrototypeOf = __webpack_require__(54)
, ITERATOR = __webpack_require__(53)('iterator')
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
, FF_ITERATOR = '@@iterator'
, KEYS = 'keys'
, VALUES = 'values';
var returnThis = function(){ return this; };
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
$iterCreate(Constructor, NAME, next);
var getMethod = function(kind){
if(!BUGGY && kind in proto)return proto[kind];
switch(kind){
case KEYS: return function keys(){ return new Constructor(this, kind); };
case VALUES: return function values(){ return new Constructor(this, kind); };
} return function entries(){ return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator'
, DEF_VALUES = DEFAULT == VALUES
, VALUES_BUG = false
, proto = Base.prototype
, $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
, $default = $native || getMethod(DEFAULT)
, $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
, $anyNative = NAME == 'Array' ? proto.entries || $native : $native
, methods, key, IteratorPrototype;
// Fix native
if($anyNative){
IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
if(IteratorPrototype !== Object.prototype){
// Set @@toStringTag to native iterators
setToStringTag(IteratorPrototype, TAG, true);
// fix for some old engines
if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
}
}
// fix Array#{values, @@iterator}.name in V8 / FF
if(DEF_VALUES && $native && $native.name !== VALUES){
VALUES_BUG = true;
$default = function values(){ return $native.call(this); };
}
// Define iterator
if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
hide(proto, ITERATOR, $default);
}
// Plug for library
Iterators[NAME] = $default;
Iterators[TAG] = returnThis;
if(DEFAULT){
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if(FORCED)for(key in methods){
if(!(key in proto))redefine(proto, key, methods[key]);
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
/***/ },
/* 20 */
/***/ function(module, exports) {
module.exports = true;
/***/ },
/* 21 */
/***/ function(module, exports, __webpack_require__) {
var global = __webpack_require__(22)
, core = __webpack_require__(23)
, ctx = __webpack_require__(24)
, hide = __webpack_require__(26)
, PROTOTYPE = 'prototype';
var $export = function(type, name, source){
var IS_FORCED = type & $export.F
, IS_GLOBAL = type & $export.G
, IS_STATIC = type & $export.S
, IS_PROTO = type & $export.P
, IS_BIND = type & $export.B
, IS_WRAP = type & $export.W
, exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
, expProto = exports[PROTOTYPE]
, target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
, key, own, out;
if(IS_GLOBAL)source = name;
for(key in source){
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if(own && key in exports)continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function(C){
var F = function(a, b, c){
if(this instanceof C){
switch(arguments.length){
case 0: return new C;
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if(IS_PROTO){
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ },
/* 22 */
/***/ function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
/***/ },
/* 23 */
/***/ function(module, exports) {
var core = module.exports = {version: '2.4.0'};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(25);
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
}
return function(/* ...args */){
return fn.apply(that, arguments);
};
};
/***/ },
/* 25 */
/***/ function(module, exports) {
module.exports = function(it){
if(typeof it != 'function')throw TypeError(it + ' is not a function!');
return it;
};
/***/ },
/* 26 */
/***/ function(module, exports, __webpack_require__) {
var dP = __webpack_require__(27)
, createDesc = __webpack_require__(35);
module.exports = __webpack_require__(31) ? function(object, key, value){
return dP.f(object, key, createDesc(1, value));
} : function(object, key, value){
object[key] = value;
return object;
};
/***/ },
/* 27 */
/***/ function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(28)
, IE8_DOM_DEFINE = __webpack_require__(30)
, toPrimitive = __webpack_require__(34)
, dP = Object.defineProperty;
exports.f = __webpack_require__(31) ? Object.defineProperty : function defineProperty(O, P, Attributes){
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if(IE8_DOM_DEFINE)try {
return dP(O, P, Attributes);
} catch(e){ /* empty */ }
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
if('value' in Attributes)O[P] = Attributes.value;
return O;
};
/***/ },
/* 28 */
/***/ function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(29);
module.exports = function(it){
if(!isObject(it))throw TypeError(it + ' is not an object!');
return it;
};
/***/ },
/* 29 */
/***/ function(module, exports) {
module.exports = function(it){
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ },
/* 30 */
/***/ function(module, exports, __webpack_require__) {
module.exports = !__webpack_require__(31) && !__webpack_require__(32)(function(){
return Object.defineProperty(__webpack_require__(33)('div'), 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ },
/* 31 */
/***/ function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(32)(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ },
/* 32 */
/***/ function(module, exports) {
module.exports = function(exec){
try {
return !!exec();
} catch(e){
return true;
}
};
/***/ },
/* 33 */
/***/ function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(29)
, document = __webpack_require__(22).document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
return is ? document.createElement(it) : {};
};
/***/ },
/* 34 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(29);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function(it, S){
if(!isObject(it))return it;
var fn, val;
if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ },
/* 35 */
/***/ function(module, exports) {
module.exports = function(bitmap, value){
return {
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
};
};
/***/ },
/* 36 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(26);
/***/ },
/* 37 */
/***/ function(module, exports) {
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function(it, key){
return hasOwnProperty.call(it, key);
};
/***/ },
/* 38 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var create = __webpack_require__(39)
, descriptor = __webpack_require__(35)
, setToStringTag = __webpack_require__(52)
, IteratorPrototype = {};
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
__webpack_require__(26)(IteratorPrototype, __webpack_require__(53)('iterator'), function(){ return this; });
module.exports = function(Constructor, NAME, next){
Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
setToStringTag(Constructor, NAME + ' Iterator');
};
/***/ },
/* 39 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var anObject = __webpack_require__(28)
, dPs = __webpack_require__(40)
, enumBugKeys = __webpack_require__(50)
, IE_PROTO = __webpack_require__(47)('IE_PROTO')
, Empty = function(){ /* empty */ }
, PROTOTYPE = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function(){
// Thrash, waste and sodomy: IE GC bug
var iframe = __webpack_require__(33)('iframe')
, i = enumBugKeys.length
, lt = '<'
, gt = '>'
, iframeDocument;
iframe.style.display = 'none';
__webpack_require__(51).appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
return createDict();
};
module.exports = Object.create || function create(O, Properties){
var result;
if(O !== null){
Empty[PROTOTYPE] = anObject(O);
result = new Empty;
Empty[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : dPs(result, Properties);
};
/***/ },
/* 40 */
/***/ function(module, exports, __webpack_require__) {
var dP = __webpack_require__(27)
, anObject = __webpack_require__(28)
, getKeys = __webpack_require__(41);
module.exports = __webpack_require__(31) ? Object.defineProperties : function defineProperties(O, Properties){
anObject(O);
var keys = getKeys(Properties)
, length = keys.length
, i = 0
, P;
while(length > i)dP.f(O, P = keys[i++], Properties[P]);
return O;
};
/***/ },
/* 41 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
var $keys = __webpack_require__(42)
, enumBugKeys = __webpack_require__(50);
module.exports = Object.keys || function keys(O){
return $keys(O, enumBugKeys);
};
/***/ },
/* 42 */
/***/ function(module, exports, __webpack_require__) {
var has = __webpack_require__(37)
, toIObject = __webpack_require__(15)
, arrayIndexOf = __webpack_require__(43)(false)
, IE_PROTO = __webpack_require__(47)('IE_PROTO');
module.exports = function(object, names){
var O = toIObject(object)
, i = 0
, result = []
, key;
for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
// Don't enum bug & hidden keys
while(names.length > i)if(has(O, key = names[i++])){
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
/***/ },
/* 43 */
/***/ function(module, exports, __webpack_require__) {
// false -> Array#indexOf
// true -> Array#includes
var toIObject = __webpack_require__(15)
, toLength = __webpack_require__(44)
, toIndex = __webpack_require__(46);
module.exports = function(IS_INCLUDES){
return function($this, el, fromIndex){
var O = toIObject($this)
, length = toLength(O.length)
, index = toIndex(fromIndex, length)
, value;
// Array#includes uses SameValueZero equality algorithm
if(IS_INCLUDES && el != el)while(length > index){
value = O[index++];
if(value != value)return true;
// Array#toIndex ignores holes, Array#includes - not
} else for(;length > index; index++)if(IS_INCLUDES || index in O){
if(O[index] === el)return IS_INCLUDES || index || 0;
} return !IS_INCLUDES && -1;
};
};
/***/ },
/* 44 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.15 ToLength
var toInteger = __webpack_require__(45)
, min = Math.min;
module.exports = function(it){
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};
/***/ },
/* 45 */
/***/ function(module, exports) {
// 7.1.4 ToInteger
var ceil = Math.ceil
, floor = Math.floor;
module.exports = function(it){
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
/***/ },
/* 46 */
/***/ function(module, exports, __webpack_require__) {
var toInteger = __webpack_require__(45)
, max = Math.max
, min = Math.min;
module.exports = function(index, length){
index = toInteger(index);
return index < 0 ? max(index + length, 0) : min(index, length);
};
/***/ },
/* 47 */
/***/ function(module, exports, __webpack_require__) {
var shared = __webpack_require__(48)('keys')
, uid = __webpack_require__(49);
module.exports = function(key){
return shared[key] || (shared[key] = uid(key));
};
/***/ },
/* 48 */
/***/ function(module, exports, __webpack_require__) {
var global = __webpack_require__(22)
, SHARED = '__core-js_shared__'
, store = global[SHARED] || (global[SHARED] = {});
module.exports = function(key){
return store[key] || (store[key] = {});
};
/***/ },
/* 49 */
/***/ function(module, exports) {
var id = 0
, px = Math.random();
module.exports = function(key){
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
/***/ },
/* 50 */
/***/ function(module, exports) {
// IE 8- don't enum bug keys
module.exports = (
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
).split(',');
/***/ },
/* 51 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(22).document && document.documentElement;
/***/ },
/* 52 */
/***/ function(module, exports, __webpack_require__) {
var def = __webpack_require__(27).f
, has = __webpack_require__(37)
, TAG = __webpack_require__(53)('toStringTag');
module.exports = function(it, tag, stat){
if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
};
/***/ },
/* 53 */
/***/ function(module, exports, __webpack_require__) {
var store = __webpack_require__(48)('wks')
, uid = __webpack_require__(49)
, Symbol = __webpack_require__(22).Symbol
, USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function(name){
return store[name] || (store[name] =
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
};
$exports.store = store;
/***/ },
/* 54 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
var has = __webpack_require__(37)
, toObject = __webpack_require__(55)
, IE_PROTO = __webpack_require__(47)('IE_PROTO')
, ObjectProto = Object.prototype;
module.exports = Object.getPrototypeOf || function(O){
O = toObject(O);
if(has(O, IE_PROTO))return O[IE_PROTO];
if(typeof O.constructor == 'function' && O instanceof O.constructor){
return O.constructor.prototype;
} return O instanceof Object ? ObjectProto : null;
};
/***/ },
/* 55 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.13 ToObject(argument)
var defined = __webpack_require__(18);
module.exports = function(it){
return Object(defined(it));
};
/***/ },
/* 56 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $at = __webpack_require__(57)(true);
// 21.1.3.27 String.prototype[@@iterator]()
__webpack_require__(19)(String, 'String', function(iterated){
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
}, function(){
var O = this._t
, index = this._i
, point;
if(index >= O.length)return {value: undefined, done: true};
point = $at(O, index);
this._i += point.length;
return {value: point, done: false};
});
/***/ },
/* 57 */
/***/ function(module, exports, __webpack_require__) {
var toInteger = __webpack_require__(45)
, defined = __webpack_require__(18);
// true -> String#at
// false -> String#codePointAt
module.exports = function(TO_STRING){
return function(that, pos){
var s = String(defined(that))
, i = toInteger(pos)
, l = s.length
, a, b;
if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
? TO_STRING ? s.charAt(i) : a
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
/***/ },
/* 58 */
/***/ function(module, exports, __webpack_require__) {
var classof = __webpack_require__(59)
, ITERATOR = __webpack_require__(53)('iterator')
, Iterators = __webpack_require__(14);
module.exports = __webpack_require__(23).isIterable = function(it){
var O = Object(it);
return O[ITERATOR] !== undefined
|| '@@iterator' in O
|| Iterators.hasOwnProperty(classof(O));
};
/***/ },
/* 59 */
/***/ function(module, exports, __webpack_require__) {
// getting tag from 19.1.3.6 Object.prototype.toString()
var cof = __webpack_require__(17)
, TAG = __webpack_require__(53)('toStringTag')
// ES3 wrong here
, ARG = cof(function(){ return arguments; }()) == 'Arguments';
// fallback for IE11 Script Access Denied error
var tryGet = function(it, key){
try {
return it[key];
} catch(e){ /* empty */ }
};
module.exports = function(it){
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null'
// @@toStringTag case
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
// builtinTag case
: ARG ? cof(O)
// ES3 arguments fallback
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
/***/ },
/* 60 */
/***/ function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(61), __esModule: true };
/***/ },
/* 61 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(10);
__webpack_require__(56);
module.exports = __webpack_require__(62);
/***/ },
/* 62 */
/***/ function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(28)
, get = __webpack_require__(63);
module.exports = __webpack_require__(23).getIterator = function(it){
var iterFn = get(it);
if(typeof iterFn != 'function')throw TypeError(it + ' is not iterable!');
return anObject(iterFn.call(it));
};
/***/ },
/* 63 */
/***/ function(module, exports, __webpack_require__) {
var classof = __webpack_require__(59)
, ITERATOR = __webpack_require__(53)('iterator')
, Iterators = __webpack_require__(14);
module.exports = __webpack_require__(23).getIteratorMethod = function(it){
if(it != undefined)return it[ITERATOR]
|| it['@@iterator']
|| Iterators[classof(it)];
};
/***/ },
/* 64 */
/***/ function(module, exports) {
exports = module.exports = Victor;
/**
* # Victor - A JavaScript 2D vector class with methods for common vector operations
*/
/**
* Constructor. Will also work without the `new` keyword
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = Victor(42, 1337);
*
* @param {Number} x Value of the x axis
* @param {Number} y Value of the y axis
* @return {Victor}
* @api public
*/
function Victor (x, y) {
if (!(this instanceof Victor)) {
return new Victor(x, y);
}
/**
* The X axis
*
* ### Examples:
* var vec = new Victor.fromArray(42, 21);
*
* vec.x;
* // => 42
*
* @api public
*/
this.x = x || 0;
/**
* The Y axis
*
* ### Examples:
* var vec = new Victor.fromArray(42, 21);
*
* vec.y;
* // => 21
*
* @api public
*/
this.y = y || 0;
};
/**
* # Static
*/
/**
* Creates a new instance from an array
*
* ### Examples:
* var vec = Victor.fromArray([42, 21]);
*
* vec.toString();
* // => x:42, y:21
*
* @name Victor.fromArray
* @param {Array} array Array with the x and y values at index 0 and 1 respectively
* @return {Victor} The new instance
* @api public
*/
Victor.fromArray = function (arr) {
return new Victor(arr[0] || 0, arr[1] || 0);
};
/**
* Creates a new instance from an object
*
* ### Examples:
* var vec = Victor.fromObject({ x: 42, y: 21 });
*
* vec.toString();
* // => x:42, y:21
*
* @name Victor.fromObject
* @param {Object} obj Object with the values for x and y
* @return {Victor} The new instance
* @api public
*/
Victor.fromObject = function (obj) {
return new Victor(obj.x || 0, obj.y || 0);
};
/**
* # Manipulation
*
* These functions are chainable.
*/
/**
* Adds another vector's X axis to this one
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var vec2 = new Victor(20, 30);
*
* vec1.addX(vec2);
* vec1.toString();
* // => x:30, y:10
*
* @param {Victor} vector The other vector you want to add to this one
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.addX = function (vec) {
this.x += vec.x;
return this;
};
/**
* Adds another vector's Y axis to this one
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var vec2 = new Victor(20, 30);
*
* vec1.addY(vec2);
* vec1.toString();
* // => x:10, y:40
*
* @param {Victor} vector The other vector you want to add to this one
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.addY = function (vec) {
this.y += vec.y;
return this;
};
/**
* Adds another vector to this one
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var vec2 = new Victor(20, 30);
*
* vec1.add(vec2);
* vec1.toString();
* // => x:30, y:40
*
* @param {Victor} vector The other vector you want to add to this one
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.add = function (vec) {
this.x += vec.x;
this.y += vec.y;
return this;
};
/**
* Adds the given scalar to both vector axis
*
* ### Examples:
* var vec = new Victor(1, 2);
*
* vec.addScalar(2);
* vec.toString();
* // => x: 3, y: 4
*
* @param {Number} scalar The scalar to add
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.addScalar = function (scalar) {
this.x += scalar;
this.y += scalar;
return this;
};
/**
* Adds the given scalar to the X axis
*
* ### Examples:
* var vec = new Victor(1, 2);
*
* vec.addScalarX(2);
* vec.toString();
* // => x: 3, y: 2
*
* @param {Number} scalar The scalar to add
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.addScalarX = function (scalar) {
this.x += scalar;
return this;
};
/**
* Adds the given scalar to the Y axis
*
* ### Examples:
* var vec = new Victor(1, 2);
*
* vec.addScalarY(2);
* vec.toString();
* // => x: 1, y: 4
*
* @param {Number} scalar The scalar to add
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.addScalarY = function (scalar) {
this.y += scalar;
return this;
};
/**
* Subtracts the X axis of another vector from this one
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(20, 30);
*
* vec1.subtractX(vec2);
* vec1.toString();
* // => x:80, y:50
*
* @param {Victor} vector The other vector you want subtract from this one
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.subtractX = function (vec) {
this.x -= vec.x;
return this;
};
/**
* Subtracts the Y axis of another vector from this one
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(20, 30);
*
* vec1.subtractY(vec2);
* vec1.toString();
* // => x:100, y:20
*
* @param {Victor} vector The other vector you want subtract from this one
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.subtractY = function (vec) {
this.y -= vec.y;
return this;
};
/**
* Subtracts another vector from this one
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(20, 30);
*
* vec1.subtract(vec2);
* vec1.toString();
* // => x:80, y:20
*
* @param {Victor} vector The other vector you want subtract from this one
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.subtract = function (vec) {
this.x -= vec.x;
this.y -= vec.y;
return this;
};
/**
* Subtracts the given scalar from both axis
*
* ### Examples:
* var vec = new Victor(100, 200);
*
* vec.subtractScalar(20);
* vec.toString();
* // => x: 80, y: 180
*
* @param {Number} scalar The scalar to subtract
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.subtractScalar = function (scalar) {
this.x -= scalar;
this.y -= scalar;
return this;
};
/**
* Subtracts the given scalar from the X axis
*
* ### Examples:
* var vec = new Victor(100, 200);
*
* vec.subtractScalarX(20);
* vec.toString();
* // => x: 80, y: 200
*
* @param {Number} scalar The scalar to subtract
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.subtractScalarX = function (scalar) {
this.x -= scalar;
return this;
};
/**
* Subtracts the given scalar from the Y axis
*
* ### Examples:
* var vec = new Victor(100, 200);
*
* vec.subtractScalarY(20);
* vec.toString();
* // => x: 100, y: 180
*
* @param {Number} scalar The scalar to subtract
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.subtractScalarY = function (scalar) {
this.y -= scalar;
return this;
};
/**
* Divides the X axis by the x component of given vector
*
* ### Examples:
* var vec = new Victor(100, 50);
* var vec2 = new Victor(2, 0);
*
* vec.divideX(vec2);
* vec.toString();
* // => x:50, y:50
*
* @param {Victor} vector The other vector you want divide by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.divideX = function (vector) {
this.x /= vector.x;
return this;
};
/**
* Divides the Y axis by the y component of given vector
*
* ### Examples:
* var vec = new Victor(100, 50);
* var vec2 = new Victor(0, 2);
*
* vec.divideY(vec2);
* vec.toString();
* // => x:100, y:25
*
* @param {Victor} vector The other vector you want divide by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.divideY = function (vector) {
this.y /= vector.y;
return this;
};
/**
* Divides both vector axis by a axis values of given vector
*
* ### Examples:
* var vec = new Victor(100, 50);
* var vec2 = new Victor(2, 2);
*
* vec.divide(vec2);
* vec.toString();
* // => x:50, y:25
*
* @param {Victor} vector The vector to divide by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.divide = function (vector) {
this.x /= vector.x;
this.y /= vector.y;
return this;
};
/**
* Divides both vector axis by the given scalar value
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.divideScalar(2);
* vec.toString();
* // => x:50, y:25
*
* @param {Number} The scalar to divide by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.divideScalar = function (scalar) {
if (scalar !== 0) {
this.x /= scalar;
this.y /= scalar;
} else {
this.x = 0;
this.y = 0;
}
return this;
};
/**
* Divides the X axis by the given scalar value
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.divideScalarX(2);
* vec.toString();
* // => x:50, y:50
*
* @param {Number} The scalar to divide by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.divideScalarX = function (scalar) {
if (scalar !== 0) {
this.x /= scalar;
} else {
this.x = 0;
}
return this;
};
/**
* Divides the Y axis by the given scalar value
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.divideScalarY(2);
* vec.toString();
* // => x:100, y:25
*
* @param {Number} The scalar to divide by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.divideScalarY = function (scalar) {
if (scalar !== 0) {
this.y /= scalar;
} else {
this.y = 0;
}
return this;
};
/**
* Inverts the X axis
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.invertX();
* vec.toString();
* // => x:-100, y:50
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.invertX = function () {
this.x *= -1;
return this;
};
/**
* Inverts the Y axis
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.invertY();
* vec.toString();
* // => x:100, y:-50
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.invertY = function () {
this.y *= -1;
return this;
};
/**
* Inverts both axis
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.invert();
* vec.toString();
* // => x:-100, y:-50
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.invert = function () {
this.invertX();
this.invertY();
return this;
};
/**
* Multiplies the X axis by X component of given vector
*
* ### Examples:
* var vec = new Victor(100, 50);
* var vec2 = new Victor(2, 0);
*
* vec.multiplyX(vec2);
* vec.toString();
* // => x:200, y:50
*
* @param {Victor} vector The vector to multiply the axis with
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.multiplyX = function (vector) {
this.x *= vector.x;
return this;
};
/**
* Multiplies the Y axis by Y component of given vector
*
* ### Examples:
* var vec = new Victor(100, 50);
* var vec2 = new Victor(0, 2);
*
* vec.multiplyX(vec2);
* vec.toString();
* // => x:100, y:100
*
* @param {Victor} vector The vector to multiply the axis with
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.multiplyY = function (vector) {
this.y *= vector.y;
return this;
};
/**
* Multiplies both vector axis by values from a given vector
*
* ### Examples:
* var vec = new Victor(100, 50);
* var vec2 = new Victor(2, 2);
*
* vec.multiply(vec2);
* vec.toString();
* // => x:200, y:100
*
* @param {Victor} vector The vector to multiply by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.multiply = function (vector) {
this.x *= vector.x;
this.y *= vector.y;
return this;
};
/**
* Multiplies both vector axis by the given scalar value
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.multiplyScalar(2);
* vec.toString();
* // => x:200, y:100
*
* @param {Number} The scalar to multiply by
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.multiplyScalar = function (scalar) {
this.x *= scalar;
this.y *= scalar;
return this;
};
/**
* Multiplies the X axis by the given scalar
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.multiplyScalarX(2);
* vec.toString();
* // => x:200, y:50
*
* @param {Number} The scalar to multiply the axis with
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.multiplyScalarX = function (scalar) {
this.x *= scalar;
return this;
};
/**
* Multiplies the Y axis by the given scalar
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.multiplyScalarY(2);
* vec.toString();
* // => x:100, y:100
*
* @param {Number} The scalar to multiply the axis with
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.multiplyScalarY = function (scalar) {
this.y *= scalar;
return this;
};
/**
* Normalize
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.normalize = function () {
var length = this.length();
if (length === 0) {
this.x = 1;
this.y = 0;
} else {
this.divide(Victor(length, length));
}
return this;
};
Victor.prototype.norm = Victor.prototype.normalize;
/**
* If the absolute vector axis is greater than `max`, multiplies the axis by `factor`
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.limit(80, 0.9);
* vec.toString();
* // => x:90, y:50
*
* @param {Number} max The maximum value for both x and y axis
* @param {Number} factor Factor by which the axis are to be multiplied with
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.limit = function (max, factor) {
if (Math.abs(this.x) > max){ this.x *= factor; }
if (Math.abs(this.y) > max){ this.y *= factor; }
return this;
};
/**
* Randomizes both vector axis with a value between 2 vectors
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.randomize(new Victor(50, 60), new Victor(70, 80`));
* vec.toString();
* // => x:67, y:73
*
* @param {Victor} topLeft first vector
* @param {Victor} bottomRight second vector
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.randomize = function (topLeft, bottomRight) {
this.randomizeX(topLeft, bottomRight);
this.randomizeY(topLeft, bottomRight);
return this;
};
/**
* Randomizes the y axis with a value between 2 vectors
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.randomizeX(new Victor(50, 60), new Victor(70, 80`));
* vec.toString();
* // => x:55, y:50
*
* @param {Victor} topLeft first vector
* @param {Victor} bottomRight second vector
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.randomizeX = function (topLeft, bottomRight) {
var min = Math.min(topLeft.x, bottomRight.x);
var max = Math.max(topLeft.x, bottomRight.x);
this.x = random(min, max);
return this;
};
/**
* Randomizes the y axis with a value between 2 vectors
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.randomizeY(new Victor(50, 60), new Victor(70, 80`));
* vec.toString();
* // => x:100, y:66
*
* @param {Victor} topLeft first vector
* @param {Victor} bottomRight second vector
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.randomizeY = function (topLeft, bottomRight) {
var min = Math.min(topLeft.y, bottomRight.y);
var max = Math.max(topLeft.y, bottomRight.y);
this.y = random(min, max);
return this;
};
/**
* Randomly randomizes either axis between 2 vectors
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.randomizeAny(new Victor(50, 60), new Victor(70, 80));
* vec.toString();
* // => x:100, y:77
*
* @param {Victor} topLeft first vector
* @param {Victor} bottomRight second vector
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.randomizeAny = function (topLeft, bottomRight) {
if (!! Math.round(Math.random())) {
this.randomizeX(topLeft, bottomRight);
} else {
this.randomizeY(topLeft, bottomRight);
}
return this;
};
/**
* Rounds both axis to an integer value
*
* ### Examples:
* var vec = new Victor(100.2, 50.9);
*
* vec.unfloat();
* vec.toString();
* // => x:100, y:51
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.unfloat = function () {
this.x = Math.round(this.x);
this.y = Math.round(this.y);
return this;
};
/**
* Rounds both axis to a certain precision
*
* ### Examples:
* var vec = new Victor(100.2, 50.9);
*
* vec.unfloat();
* vec.toString();
* // => x:100, y:51
*
* @param {Number} Precision (default: 8)
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.toFixed = function (precision) {
if (typeof precision === 'undefined') { precision = 8; }
this.x = this.x.toFixed(precision);
this.y = this.y.toFixed(precision);
return this;
};
/**
* Performs a linear blend / interpolation of the X axis towards another vector
*
* ### Examples:
* var vec1 = new Victor(100, 100);
* var vec2 = new Victor(200, 200);
*
* vec1.mixX(vec2, 0.5);
* vec.toString();
* // => x:150, y:100
*
* @param {Victor} vector The other vector
* @param {Number} amount The blend amount (optional, default: 0.5)
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.mixX = function (vec, amount) {
if (typeof amount === 'undefined') {
amount = 0.5;
}
this.x = (1 - amount) * this.x + amount * vec.x;
return this;
};
/**
* Performs a linear blend / interpolation of the Y axis towards another vector
*
* ### Examples:
* var vec1 = new Victor(100, 100);
* var vec2 = new Victor(200, 200);
*
* vec1.mixY(vec2, 0.5);
* vec.toString();
* // => x:100, y:150
*
* @param {Victor} vector The other vector
* @param {Number} amount The blend amount (optional, default: 0.5)
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.mixY = function (vec, amount) {
if (typeof amount === 'undefined') {
amount = 0.5;
}
this.y = (1 - amount) * this.y + amount * vec.y;
return this;
};
/**
* Performs a linear blend / interpolation towards another vector
*
* ### Examples:
* var vec1 = new Victor(100, 100);
* var vec2 = new Victor(200, 200);
*
* vec1.mix(vec2, 0.5);
* vec.toString();
* // => x:150, y:150
*
* @param {Victor} vector The other vector
* @param {Number} amount The blend amount (optional, default: 0.5)
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.mix = function (vec, amount) {
this.mixX(vec, amount);
this.mixY(vec, amount);
return this;
};
/**
* # Products
*/
/**
* Creates a clone of this vector
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var vec2 = vec1.clone();
*
* vec2.toString();
* // => x:10, y:10
*
* @return {Victor} A clone of the vector
* @api public
*/
Victor.prototype.clone = function () {
return new Victor(this.x, this.y);
};
/**
* Copies another vector's X component in to its own
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var vec2 = new Victor(20, 20);
* var vec2 = vec1.copyX(vec1);
*
* vec2.toString();
* // => x:20, y:10
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.copyX = function (vec) {
this.x = vec.x;
return this;
};
/**
* Copies another vector's Y component in to its own
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var vec2 = new Victor(20, 20);
* var vec2 = vec1.copyY(vec1);
*
* vec2.toString();
* // => x:10, y:20
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.copyY = function (vec) {
this.y = vec.y;
return this;
};
/**
* Copies another vector's X and Y components in to its own
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var vec2 = new Victor(20, 20);
* var vec2 = vec1.copy(vec1);
*
* vec2.toString();
* // => x:20, y:20
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.copy = function (vec) {
this.copyX(vec);
this.copyY(vec);
return this;
};
/**
* Sets the vector to zero (0,0)
*
* ### Examples:
* var vec1 = new Victor(10, 10);
* var1.zero();
* vec1.toString();
* // => x:0, y:0
*
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.zero = function () {
this.x = this.y = 0;
return this;
};
/**
* Calculates the dot product of this vector and another
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(200, 60);
*
* vec1.dot(vec2);
* // => 23000
*
* @param {Victor} vector The second vector
* @return {Number} Dot product
* @api public
*/
Victor.prototype.dot = function (vec2) {
return this.x * vec2.x + this.y * vec2.y;
};
Victor.prototype.cross = function (vec2) {
return (this.x * vec2.y ) - (this.y * vec2.x );
};
/**
* Projects a vector onto another vector, setting itself to the result.
*
* ### Examples:
* var vec = new Victor(100, 0);
* var vec2 = new Victor(100, 100);
*
* vec.projectOnto(vec2);
* vec.toString();
* // => x:50, y:50
*
* @param {Victor} vector The other vector you want to project this vector onto
* @return {Victor} `this` for chaining capabilities
* @api public
*/
Victor.prototype.projectOnto = function (vec2) {
var coeff = ( (this.x * vec2.x)+(this.y * vec2.y) ) / ((vec2.x*vec2.x)+(vec2.y*vec2.y));
this.x = coeff * vec2.x;
this.y = coeff * vec2.y;
return this;
};
Victor.prototype.horizontalAngle = function () {
return Math.atan2(this.y, this.x);
};
Victor.prototype.horizontalAngleDeg = function () {
return radian2degrees(this.horizontalAngle());
};
Victor.prototype.verticalAngle = function () {
return Math.atan2(this.x, this.y);
};
Victor.prototype.verticalAngleDeg = function () {
return radian2degrees(this.verticalAngle());
};
Victor.prototype.angle = Victor.prototype.horizontalAngle;
Victor.prototype.angleDeg = Victor.prototype.horizontalAngleDeg;
Victor.prototype.direction = Victor.prototype.horizontalAngle;
Victor.prototype.rotate = function (angle) {
var nx = (this.x * Math.cos(angle)) - (this.y * Math.sin(angle));
var ny = (this.x * Math.sin(angle)) + (this.y * Math.cos(angle));
this.x = nx;
this.y = ny;
return this;
};
Victor.prototype.rotateDeg = function (angle) {
angle = degrees2radian(angle);
return this.rotate(angle);
};
Victor.prototype.rotateTo = function(rotation) {
return this.rotate(rotation-this.angle());
};
Victor.prototype.rotateToDeg = function(rotation) {
rotation = degrees2radian(rotation);
return this.rotateTo(rotation);
};
Victor.prototype.rotateBy = function (rotation) {
var angle = this.angle() + rotation;
return this.rotate(angle);
};
Victor.prototype.rotateByDeg = function (rotation) {
rotation = degrees2radian(rotation);
return this.rotateBy(rotation);
};
/**
* Calculates the distance of the X axis between this vector and another
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(200, 60);
*
* vec1.distanceX(vec2);
* // => -100
*
* @param {Victor} vector The second vector
* @return {Number} Distance
* @api public
*/
Victor.prototype.distanceX = function (vec) {
return this.x - vec.x;
};
/**
* Same as `distanceX()` but always returns an absolute number
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(200, 60);
*
* vec1.absDistanceX(vec2);
* // => 100
*
* @param {Victor} vector The second vector
* @return {Number} Absolute distance
* @api public
*/
Victor.prototype.absDistanceX = function (vec) {
return Math.abs(this.distanceX(vec));
};
/**
* Calculates the distance of the Y axis between this vector and another
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(200, 60);
*
* vec1.distanceY(vec2);
* // => -10
*
* @param {Victor} vector The second vector
* @return {Number} Distance
* @api public
*/
Victor.prototype.distanceY = function (vec) {
return this.y - vec.y;
};
/**
* Same as `distanceY()` but always returns an absolute number
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(200, 60);
*
* vec1.distanceY(vec2);
* // => 10
*
* @param {Victor} vector The second vector
* @return {Number} Absolute distance
* @api public
*/
Victor.prototype.absDistanceY = function (vec) {
return Math.abs(this.distanceY(vec));
};
/**
* Calculates the euclidean distance between this vector and another
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(200, 60);
*
* vec1.distance(vec2);
* // => 100.4987562112089
*
* @param {Victor} vector The second vector
* @return {Number} Distance
* @api public
*/
Victor.prototype.distance = function (vec) {
return Math.sqrt(this.distanceSq(vec));
};
/**
* Calculates the squared euclidean distance between this vector and another
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(200, 60);
*
* vec1.distanceSq(vec2);
* // => 10100
*
* @param {Victor} vector The second vector
* @return {Number} Distance
* @api public
*/
Victor.prototype.distanceSq = function (vec) {
var dx = this.distanceX(vec),
dy = this.distanceY(vec);
return dx * dx + dy * dy;
};
/**
* Calculates the length or magnitude of the vector
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.length();
* // => 111.80339887498948
*
* @return {Number} Length / Magnitude
* @api public
*/
Victor.prototype.length = function () {
return Math.sqrt(this.lengthSq());
};
/**
* Squared length / magnitude
*
* ### Examples:
* var vec = new Victor(100, 50);
*
* vec.lengthSq();
* // => 12500
*
* @return {Number} Length / Magnitude
* @api public
*/
Victor.prototype.lengthSq = function () {
return this.x * this.x + this.y * this.y;
};
Victor.prototype.magnitude = Victor.prototype.length;
/**
* Returns a true if vector is (0, 0)
*
* ### Examples:
* var vec = new Victor(100, 50);
* vec.zero();
*
* // => true
*
* @return {Boolean}
* @api public
*/
Victor.prototype.isZero = function() {
return this.x === 0 && this.y === 0;
};
/**
* Returns a true if this vector is the same as another
*
* ### Examples:
* var vec1 = new Victor(100, 50);
* var vec2 = new Victor(100, 50);
* vec1.isEqualTo(vec2);
*
* // => true
*
* @return {Boolean}
* @api public
*/
Victor.prototype.isEqualTo = function(vec2) {
return this.x === vec2.x && this.y === vec2.y;
};
/**
* # Utility Methods
*/
/**
* Returns an string representation of the vector
*
* ### Examples:
* var vec = new Victor(10, 20);
*
* vec.toString();
* // => x:10, y:20
*
* @return {String}
* @api public
*/
Victor.prototype.toString = function () {
return 'x:' + this.x + ', y:' + this.y;
};
/**
* Returns an array representation of the vector
*
* ### Examples:
* var vec = new Victor(10, 20);
*
* vec.toArray();
* // => [10, 20]
*
* @return {Array}
* @api public
*/
Victor.prototype.toArray = function () {
return [ this.x, this.y ];
};
/**
* Returns an object representation of the vector
*
* ### Examples:
* var vec = new Victor(10, 20);
*
* vec.toObject();
* // => { x: 10, y: 20 }
*
* @return {Object}
* @api public
*/
Victor.prototype.toObject = function () {
return { x: this.x, y: this.y };
};
var degrees = 180 / Math.PI;
function random (min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function radian2degrees (rad) {
return rad * degrees;
}
function degrees2radian (deg) {
return deg / degrees;
}
/***/ },
/* 65 */
/***/ function(module, exports, __webpack_require__) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('div', {
staticClass: "dragable",
style: (_vm.boxStyle),
on: {
"mousedown": _vm.handleDown,
"mouseup": _vm.handleUp
}
}, [_vm._t("default"), _vm._v(" "), _c('div', {
staticClass: "rotate",
on: {
"mousedown": function($event) {
$event.stopPropagation();
_vm.rotateStart($event)
}
}
}), _vm._v(" "), _c('div', {
staticClass: "scale",
on: {
"mousedown": function($event) {
$event.stopPropagation();
_vm.resizeStart($event)
}
}
})], 2)
},staticRenderFns: []}
module.exports.render._withStripped = true
if (false) {
module.hot.accept()
if (module.hot.data) {
require("vue-hot-reload-api").rerender("data-v-b85935aa", module.exports)
}
}
/***/ }
/******/ ])
});
;
//# sourceMappingURL=vue-drag-resize-rotate.js.map