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
50
51
52
53
54
export const valCanvasHTML = `<!DOCTYPE html>
<html>
<head>
<style>
#movableBox {
position: absolute;
width: 300px;
height: 200px;
border: 1px solid black;
}
</style>
</head>
<body>
<div id="movableBox">
<iframe src="https://example.com" width="100%" height="100%" frameborder="0"></iframe>
</div>
<script src="https://daybrush.com/movable/release/latest/dist/movable.min.js"></script>
<script>
const element = document.getElementById('movableBox');
const movable = new Movable.default(element, {
target: element,
draggable: true,
resizable: true,
throttleDrag: 0,
throttleResize: 0,
});
movable.on('dragStart', ({inputEvent}) => {
console.log('Drag started');
inputEvent.preventDefault();
}).on('drag', ({target, left, top, inputEvent}) => {
console.log('Dragging');
target.style.left = left + "px";
target.style.top = top + "px";
}).on('dragEnd', () => {
console.log('Drag ended');
}).on('resizeStart', ({inputEvent}) => {
console.log('Resize started');
inputEvent.preventDefault();
}).on('resize', ({width, height, target, inputEvent}) => {
console.log('Resizing');
target.style.width = width + "px";
target.style.height = height + "px";
}).on('resizeEnd', () => {
console.log('Resize ended');
});
</script>
</body>
</html>
`;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023