-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
resizable_dock_3.7.js
37 lines (31 loc) · 1.45 KB
/
resizable_dock_3.7.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
lizMap.events.on({
uicreated: function (e) {
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js';
script.type = 'text/javascript';
script.onload = function () {
// Script has been loaded and can be used now
console.log('interact.js has been loaded successfully!');
// Now you can safely use interact
interact('#dock')
.resizable({
edges: { left: false, right: true, bottom: false, top: false }
})
.on('resizemove', function (event) {
var target = event.target;
var x = (parseFloat(target.getAttribute('data-x')) || 0);
var y = (parseFloat(target.getAttribute('data-y')) || 0);
// Update the element's style
target.style.width = event.rect.width + 'px';
target.style.height = event.rect.height + 'px';
// Translate when resizing from top or left edges
x += event.deltaRect.left;
y += event.deltaRect.top;
target.style.transform = 'translate(' + x + 'px,' + y + 'px)';
target.setAttribute('data-x', x);
target.setAttribute('data-y', y);
});
};
document.head.appendChild(script);
}
});