Update mod.js

This commit is contained in:
Ryo Hilmawan 2020-11-03 18:47:39 +07:00 committed by GitHub
parent b671451261
commit 5f8e3cc332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,9 +43,14 @@ module.exports = {
'propertylayout-hidden'
);
const toggle = createElement(
'<button class="propertylayout-toggle" data-action="show">properties</button>'
'<button class="propertylayout-toggle" data-action="show">Properties</button>'
);
toggle.prepend(
createElement('<svg viewBox="0 0 100 100" class="triangle"><polygon points="5.9,88.2 50,11.8 94.1,88.2 "></polygon></svg>')
);
toggle.addEventListener('click', (event) => {
properties.style.maxHeight = properties.children[0].offsetHeight + 'px';
setTimeout(() => {
properties.classList.toggle('propertylayout-hidden');
toggle.setAttribute(
'data-action',
@ -53,6 +58,14 @@ module.exports = {
? 'show'
: 'hide'
);
}, 0);
});
const propObserver = new MutationObserver(() => {
properties.style.maxHeight = '';
});
propObserver.observe(properties, {
childList: true,
subtree: true,
});
if (properties.previousElementSibling) {
properties.previousElementSibling.append(toggle);