WordPress.org

Make WordPress Core

Ticket #30359: 30359.patch

File 30359.patch, 1.1 KB (added by ajensen, 3 years ago)
  • src/wp-admin/js/widgets.js

     
    739739        }
    740740};
    741741
     742
     743
     744var elmnt1 = document.querySelector(".widget-liquid-right");
     745var elmnt2 = document.querySelector(".widget-liquid-left");
     746
     747var isInViewport = function (elmnt1) {
     748    var bounding = elmnt1.getBoundingClientRect();
     749    return (
     750        bounding.top >= 0 &&
     751        bounding.left >= 0 &&
     752        bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
     753        bounding.right <= (window.innerWidth || document.documentElement.clientWidth)
     754    );
     755};
     756
     757if (isInViewport(elmnt1)) {
     758    elmnt1.style.position = "sticky";
     759        elmnt1.style.position = "-webkit-sticky";
     760        elmnt1.style.top = "42px";
     761}
     762
     763
     764
     765window.onscroll = function scrollBottom(){
     766    if(elmnt1.getBoundingClientRect().bottom <= window.innerHeight) {           
     767                ////
     768          }
     769
     770    if(elmnt2.getBoundingClientRect().bottom <= window.innerHeight) {           
     771                ////
     772          }
     773}
     774
     775
    742776$document.ready( function(){ wpWidgets.init(); } );
    743777
    744778})(jQuery);