Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>Шапка</header>
<div class="container">
  <div class="row">
    <div class="col-8">
      <div class="article__article">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minus recusandae, quae tenetur hic tempora ullam consectetur porro odit? Quidem autem sint in, debitis eligendi inventore qui quas explicabo doloremque quis.</p>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minus recusandae, quae tenetur hic tempora ullam consectetur porro odit? Quidem autem sint in, debitis eligendi inventore qui quas explicabo doloremque quis.</p>
      </div>
      <div id="get_article"></div>
    </div>   
     <div class="col-4">
       <div>
       <div id="aside-fixed">
         <div class="aside-fixed__red"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Non, autem similique ullam dolor corporis mollitia harum, dicta odio nobis accusamus facilis excepturi voluptate eum sunt cupiditate labore tempore. Voluptas, at!</p></div>
       </div>
         </div>
     </div>
  </div>
</div>
<footer>футер</footer>
              
            
!

CSS

              
                header {
  background: blue;
  height: 50px;
  text-align: center;
  color: white;
  position: fixed;
  width: 100%;
  z-index: 1;
  margin-bottom: 30px;
}

footer {
  background: red;
  height: 100px;
  text-align: center;
  color: white;
}

.article__article {
  height: 2000px;
  margin-top: 120px;
}

#aside-fixed {
  width: 150px;
  position: relative;
  height: 100%;
}

.aside-fixed__red {
  position: sticky;
  width: 450px;
  height: 800px;
  top: 120px;
  bottom: 0;
  transition: all .3s;
  background: green;
}
              
            
!

JS

              
                

'use strict';

var width = $(window).width();
var height = $(window).height();
var $article_list = $('#article_list');
var $article_aside = $('#aside-fixed');
var sticky = 0;
var send = true;
var page = {
    init: function init() {
        var top = page.getScrollTop();
       
    },
    
    getScrollTop: function () {
        if (typeof pageYOffset != 'undefined') {
            //most browsers except IE before #9
            return pageYOffset;
        } else {
            var B = document.body; //IE 'quirks'
            var D = document.documentElement; //IE with doctype
            D = D.clientHeight ? D : B;
            return D.scrollTop;
        }
    },
    scrollPage: function() {
        var topPos = $('#get_article').offset().top;
        var top = page.getScrollTop();
        var diff = topPos - top;
        // console.log( diff +'||'+ top +'||'+ topPos);

        if ( (diff <= (height- sticky)) && send) {
            
            var $last_article = $article_list.children().last()
            var _url = $last_article.attr('data-url');
            var _url_aside = $last_article.attr('data-aurl');
            send = false;
            if(_url){
                $.ajax({
                    url: _url, 
                    type: 'GET',
                    dataType: 'html',
                    beforeSend: function() {
                        // включение прелоудера
                        send = false;
                    },
                    complete: function() {
                        // отключение прелоудера
                    }, 
                    success: function(obj) {
                        send = true;
                        $article_list.append( obj );
                     
                        const players = Array.from(document.querySelectorAll('#videoPlay')).map(p => new Plyr(p));
                        const plyrs = Array.from(document.querySelectorAll('#plyrVideo')).map(plyrs => new Plyr(plyrs));
                        //добвляем обновление правого блока
                        page.getAsideHtml(_url_aside);

                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText + "\r\n" + xhr);
                    }
                });
            } 
        };

        if ($('.aside-fixed__red').length > 0) {
    
            if ($(window).width() > 991) { 
                var sc_topPos = $('.aside-fixed__red').offset().top; 
                var sc_top = page.getScrollTop(); 
                var sc_diff = sc_topPos - sc_top; 
                console.log( sc_diff +'||'+ sc_top +'||'+ sc_topPos); 
                if ( (sc_diff <= 240) && (sc_top >= 240 ) ) { 
                    $('.aside-fixed__red').addClass('aside-fixed__blue'); 
                }else{ 
                    $('.aside-fixed__red').removeClass('aside-fixed__blue'); 
                } 
            } 

        };
    },
    getAsideHtml:function(_url_aside){
      send = true;
      if(_url_aside){
          $.ajax({
              url: _url_aside, 
              type: 'GET',
              dataType: 'html',
              beforeSend: function() {
                  // включение прелоудера
                  send = false;
              },
              complete: function() {
                  // отключение прелоудера
              },
              success: function(obj) {
                send = true;
                //добвляем обновление правого блока
                $('.aside-fixed__red').html(obj)
              },
              error: function(xhr, ajaxOptions, thrownError) {
                  console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText + "\r\n" + xhr);
              }
          });
      } 
    }
};
/**
 * section init
 */
$(document).ready(function () { 
    page.init();
});
/**
 * section scroll animation
 */
$(document).on("scroll", function () {
    page.scrollPage();

});

$(window).resize(function () {
    page.resize();
});



              
            
!
999px

Console