-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.js
43 lines (35 loc) · 1.27 KB
/
create.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
import { $ } from "./src/utility";
(async function () {
$('.main-paste').addEventListener('paste', function (evt) {
console.log(evt);
});
let pinMoving;
document.addEventListener('mousedown', function (evt) {
if(!evt.target.classList.contains('pin-move')) return;
pinMoving = evt.target.parentElement;
});
document.addEventListener('mousemove', function (evt) {
if(pinMoving) {
pinMoving.style.left = `${evt.clientX}px`;
}
});
document.addEventListener('mouseup', function (evt) {
pinMoving = null;
});
$('button').addEventListener('click', function () {
const img = $('.main-paste').querySelector("img");
const icw = img.clientWidth;
const ich = img.clientHeight;
const object = {
url: img.src,
name: decodeURI(img.src.match(/.*\/(.*)\//)[1] || ''),
title: decodeURI(img.src.match(/.*\/.*\/([^[.]*)/)[1] || '').trim(),
clamps: [
$('#pin-0').getBoundingClientRect().x * 100 / icw,
$('#pin-1').getBoundingClientRect().x * 100 / icw,
$('#pin-2').getBoundingClientRect().x * 100 / icw
]
}
console.log(JSON.stringify(object));
});
})();