User:WelpThatWorked/vector.js

From Celeste Wiki
Revision as of 15:56, 19 January 2024 by WelpThatWorked (talk | contribs) (Debounce)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$.bodyBorderResize = mw.util.debounce(0, function() {
    var $body = $("#content");
    var $lnav = $("#left-navigation");
    var $rnav = $("#right-navigation");
    $body.css("--p1", $lnav.outerWidth() + "px");
    if( ($lnav.outerWidth()+$rnav.outerWidth()) > $body.outerWidth()){
        $body.css("--p2", $body.outerWidth() + "px");
    } else {
    $body.css("--p2", $body.outerWidth() + parseFloat($body.css("margin-right")) - $rnav.outerWidth(true) + "px");
    $body.css("--p3", $body.outerWidth() + parseFloat($body.css("margin-right")) - $("#p-search").outerWidth(true) + "px");
    }
});
$(window).on("resize", $.bodyBorderResize);
var obs = new MutationObserver($.bodyBorderResize);
obs.observe(document.querySelector("#right-navigation"), { subtree: true, attributes: true });
console.warn("test");