User:Monster Domosed/common.js: Difference between revisions

No edit summary
No edit summary
Line 1: Line 1:
document.querySelectorAll('model-viewer.model-viewer-dynsize').forEach(el => {
document.querySelectorAll('model-viewer').forEach(el => {
     const width = el.getBoundingClientRect().width;
     const wrapper = el.closest('[class*="model_size_"]');
     el.style.height = `${width}px`;
    if (!wrapper) {
        return;
    }
 
    const match = wrapper.className.match(/\bmodel_size_(\d+)\b/);
    if (!match) {
        return;
    }
 
    const size = parseInt(match[1], 10);
 
    el.style.width = `${size}px`;
     el.style.height = `${size}px`;
});
});