-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
49 lines (42 loc) · 1.24 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import SimpleCropper from './SimpleCropper.js';
const zoomIn = document.getElementById('zoomIn');
const zoomOut = document.getElementById('zoomOut');
const zoom100 = document.getElementById('zoom100');
const zoom0 = document.getElementById('zoom0');
const json = document.getElementById('json');
const currentZoom = document.getElementById('currentZoom');
const cropper = new SimpleCropper(document.getElementById('cropper'), {
className: 'simple-cropper',
cropper: '.demo__cropper',
preview: '.demo__preview',
position: {
x: 50,
y: 50
},
size: {
w: 700,
h: 466
},
zoom: 0.2,
steps: 0.05,
onReady: function (element) {
element.className += ' demo--ready';
currentZoom.innerHTML = Math.round(this.cropper.z * 100) + '%';
},
onUpdate: function () {
currentZoom.innerHTML = Math.round(this.cropper.z * 100) + '%';
console.log(this.toJSON());
}
});
zoomOut.addEventListener('click', function () {
cropper.zoomOut();
});
zoomIn.addEventListener('click', function () {
cropper.zoomIn();
});
zoom0.addEventListener('click', function () {
cropper.zoom(0);
});
zoom100.addEventListener('click', function () {
cropper.zoom(1);
});