View on GitHub

Heap-infinite-scroll

Download this project as a .zip file Download this project as a tar.gz file

Example custom description


          jQuery(function() {

              var search = new HeapGoogleSearch(),
                  callback = function(itm) {
                      return {
                          description: '<div class="custom-content"><a href="' +
                              itm.url + '" target="_blank">' +
                              itm.visibleUrl + '</a><br>' + itm.content + '</div>'
                      };
                  },
                  scroll = new HeapInfiniteScroll('.custom-description-panel', {
                      margin: 50,
                      height: 150,
                      frameWidth: 20,
                      downloadIcon: '<i class="fa fa-refresh fa-spin"></i>',
                      url: search,
                      oncallback: callback,
                      onframeshow: function (content) {
                          var thumb = content.closest('.thumb'),
                              palet = content.closest('.scroll-pallet'),
                              custom = content.children('.custom-content');

                          if (content.offset().top + 20 + custom.outerHeight() >
                              palet.offset().top + palet.height()
                          ) {
                              custom.css({
                                  top: - (thumb.height() +
                                      custom.outerHeight() + 20) + 'px',
                                  width: content.width() + 'px'
                              })
                          } else {
                              custom.css({
                                  top: '20px',
                                  width: content.width() + 'px'
                              })
                          }
                      }
                  });

                  $('a[role="menuitem"]').click(function() {
                      var val = $(this).html();

                      $('#search-value').text(val);
                      search.setQuery('"' + val + '"');

                      scroll.load();
                  });

                  setTimeout(function() {
                      search.setQuery($('#search-value').text());
                      scroll.load();
                  }, 1000);
                });
          

© Vladimir Neginskiy 2015