Giter Site home page Giter Site logo

knockout-js-infinite-scroll's Introduction

Knockout JS (KO) Infinite Scroll

Build Status Coverage Status

This is a KnockoutJS extender that provides infinite scroll functionality to an observable array by automatically filtering it down to only the items visible on screen. It was developed to display and scroll various long lists of complex items on OppositeofOpposite.com, such as the main items list, the friends list and the categories list.

###Example Fiddle: http://jsfiddle.net/thinkloop/7MqJ2/###

The example fiddle shows the simplest implmentation of this component, see the next sections for important in-practice tips.

###Scale to Thousands of Items### There is an important technique that allows this to scale to many thousands of complex items. Say we were working with a Pinterest style layout, where items with heavy content are floated next to each other forever. When items scroll out of view, we can unload their expensive contents (images, comments, styling, etc.), while keeping the top-level containers to maintain document structure:

<!-- ko foreach: filteredItems.infinitescroll.displayItems -->
   <article class="main-item">
      <!-- ko if: $index() >= $root.filteredItems.infinitescroll.firstVisibleIndex() -->
         <!-- * * complex expensive content * * -->
      <!-- /ko -->
   </article>
<!-- /ko -->

We compare $index to firstVisibleIndex and only render the contents of items that are actually visible on screen. This way users can scroll through many thousands of items without any performance issues, since the majority of the containers will be empty and light-weight.

###Bower

  • bower install git://github.com/thinkloop/knockout-js-infinite-scroll.git

###Run tests

Install dependencies:

  • install node.js
  • npm install -g bower
  • bower install
  • npm install

Run tests: npm test

coverage report in html is in coverage/


#####Don't hesitate to ask questions in issues, or star the repo if you like it!###

knockout-js-infinite-scroll's People

Contributors

julienaubert avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.