MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 748: Line 748:




document.addEventListener('scroll', function() {
$(document).ready(function() {
     var specialChars = document.getElementById('editpage-specialchars');
     var $specialChars = $('#editpage-specialchars');
    var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
     var elementOffsetTop = $specialChars.offset().top;
     var elementOffsetTop = specialChars.offsetTop;


     if (scrollTop >= elementOffsetTop) {
     $(window).on('scroll', function() {
        specialChars.classList.add('sticky-sidebar');
        var scrollTop = $(window).scrollTop();
    } else {
 
        specialChars.classList.remove('sticky-sidebar');
        if (scrollTop >= elementOffsetTop) {
     }
            $specialChars.addClass('sticky-sidebar');
        } else {
            $specialChars.removeClass('sticky-sidebar');
        }
     });
});
});