the latest code
This commit is contained in:
1 parent
d28bc1ed43
commit
9bbb24a52b
12226 files changed
+1455579
-21
No files matched your search
+77
@@ -0,0 +1,77 @@
|
||||
new Vue({
|
||||
el: "#app",
|
||||
data: {
|
||||
options: {},
|
||||
position: {},
|
||||
defaultOptions: {
|
||||
container: {
|
||||
width: '100%',
|
||||
height: 400
|
||||
},
|
||||
viewport: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
type: 'circle',
|
||||
border: {
|
||||
width: 2,
|
||||
enable: true,
|
||||
color: '#fff'
|
||||
}
|
||||
},
|
||||
zoom: {
|
||||
enable: true,
|
||||
mouseWheel: true,
|
||||
slider: true
|
||||
},
|
||||
rotation: {
|
||||
slider: true,
|
||||
enable: true,
|
||||
position: 'left'
|
||||
},
|
||||
transformOrigin: 'viewport',
|
||||
},
|
||||
cropme: {},
|
||||
el: {}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler: function(val) {
|
||||
this.cropme.reload(val)
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
created:function() {
|
||||
this.options = JSON.parse(JSON.stringify(this.defaultOptions))
|
||||
},
|
||||
mounted:function() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
init:function() {
|
||||
this.el = document.getElementById('cropme')
|
||||
this.cropme = new Cropme(this.el, this.options)
|
||||
this.cropme.bind({
|
||||
url: 'images/pic.jpeg',
|
||||
})
|
||||
},
|
||||
getPosition:function() {
|
||||
this.position = this.cropme.position()
|
||||
$('#cropmePosition').modal()
|
||||
},
|
||||
crop:function() {
|
||||
let img = document.getElementById('cropme-result')
|
||||
this.cropme.crop({
|
||||
width: 600
|
||||
}).then(function(res) {
|
||||
img.src = res
|
||||
$('#cropmeModal').modal()
|
||||
})
|
||||
},
|
||||
reset:function() {
|
||||
this.options = JSON.parse(JSON.stringify(this.defaultOptions))
|
||||
this.cropme.destroy()
|
||||
this.init()
|
||||
}
|
||||
}
|
||||
})
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
import { isObject } from './isObject';
|
||||
import { isArray } from './isArray';
|
||||
|
||||
export default function nestedObjectAssign(target, ...sources){
|
||||
if (!sources.length)
|
||||
return target;
|
||||
|
||||
const source = sources.shift();
|
||||
|
||||
if (!Object.assign) {
|
||||
Object.defineProperty(Object, 'assign', {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function(target) {
|
||||
'use strict';
|
||||
if (target === undefined || target === null) {
|
||||
throw new TypeError('Cannot convert first argument to object');
|
||||
}
|
||||
|
||||
var to = Object(target);
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var nextSource = arguments[i];
|
||||
if (nextSource === undefined || nextSource === null) {
|
||||
continue;
|
||||
}
|
||||
nextSource = Object(nextSource);
|
||||
|
||||
var keysArray = Object.keys(Object(nextSource));
|
||||
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
|
||||
var nextKey = keysArray[nextIndex];
|
||||
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
||||
if (desc !== undefined && desc.enumerable) {
|
||||
to[nextKey] = nextSource[nextKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
return to;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isObject(target) && isObject(source)){
|
||||
for (const key in source){
|
||||
if (isObject(source[key])){
|
||||
if (!target[key]) {
|
||||
Object.assign(target, {[key]: {}});
|
||||
}
|
||||
|
||||
nestedObjectAssign(target[key], source[key]);
|
||||
} else if (isArray(source[key])) {
|
||||
if (!target[key]) {
|
||||
Object.assign(target, {[key]: []});
|
||||
}
|
||||
|
||||
target[key] = target[key].concat(source[key]);
|
||||
} else {
|
||||
Object.assign(target, {[key]: source[key]});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nestedObjectAssign(target, ...sources);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export function isArray(item){
|
||||
return (item && Array.isArray(item));
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export function isObject(item){
|
||||
return (item && typeof item === 'object' && !Array.isArray(item));
|
||||
}
|
||||
Reference in new issue
Block a user