Jump to content

MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
document.addEventListener('input', function (e) {
    var el = e.target;
    if (el && el.type === 'radio' && el.name && el.name.toLowerCase().indexOf('font-size') !== -1) {
        var oldScrollY = window.scrollY;
        var oldHeight = document.documentElement.scrollHeight;
        setTimeout(function () {
            var newHeight = document.documentElement.scrollHeight;
            var ratio = oldScrollY / oldHeight;
            window.scrollTo(0, ratio * newHeight);
        }, 50);
    }
});