Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

angular-vs-repeat

kamilkp46.9kMIT2.0.14

Virtual Scroll for AngularJS ngRepeat directive

readme

angular-vs-repeat v2.0.9

Looking for a version for Angular 2?

Check out https://github.com/kamilkp/ng2-vs-for


Breaking changes in v2.x

  • API changes for passing options. Options are now passed as an object to the vs-repeat attribute instead of using separate attributes for each option (except for vs-repeat-container)

Major changes in v1.0.0-beta.0

  • elements are no longer absolutely positioned
  • no need for a mousewheel helper dummy element on MacOS (to preserve inertia scrolling)
  • no need for top updating directives - even better performance

Build Status NPM version Bower version

Virtual Scroll for AngularJS ngRepeat directive

Demo: http://kamilkp.github.io/angular-vs-repeat/

You can find the source code for this demo on branch "gh-pages".

Changelog: https://github.com/kamilkp/angular-vs-repeat/blob/master/CHANGELOG.md

DESCRIPTION:

vsRepeat directive stands for Virtual Scroll Repeat. It turns a standard ngRepeated set of elements in a scrollable container into a component, where the user thinks he has all the elements rendered and all he needs to do is scroll (without any kind of pagination - which most users loath) and at the same time the browser isn't overloaded by that many elements/angular bindings etc. The directive renders only so many elements that can fit into current container's clientHeight/clientWidth.

LIMITATIONS:

  • current version only supports an Array as a right-hand-side object for ngRepeat
  • all rendered elements must have the same height/width or the sizes of the elements must be known up front

USAGE:

First include vs-repeat as a module dependency in your app. In order to use the vsRepeat directive you need to place a vs-repeat attribute on a direct parent of an element with ng-repeat example:

<div vs-repeat="options">
    <div ng-repeat="item in someArray">
        <!-- content -->
    </div>
</div>

or:

<div vs-repeat="options">
     <div ng-repeat-start="item in someArray">
         <!-- content -->
     </div>
     <div>
        <!-- something in the middle -->
     </div>
     <div ng-repeat-end>
         <!-- content -->
     </div>
</div>

You can also measure the single element's height/width (including all paddings and margins), and then speficy it as a value of the options' size property. This can be used if one wants to override the automatically computed element size. example:

<div vs-repeat="{size: 50}">    <!-- the specified element height is 50px -->
    <div ng-repeat="item in someArray">
        <!-- content -->
    </div>
</div>
  • the vsRepeat directive must be applied to a direct parent of an element with ngRepeat
  • the library also supports ng-repeat-start/ng-repeat-end syntax
  • the value of vsRepeat attribute is the single element's height/width measured in pixels. If none provided, the directive will compute it automatically

OPTIONAL PARAMETERS (attributes):

  • vs-repeat-container="selector" - selector for element containing ng-repeat. (defaults to the current element)

OPTIONS:

Options shall be passed as an object to the vs-repeat attribute e.g.:

<div vs-repeat="{scrollParent: 'window', size: 20}"></div>

Available options:

  • horizontal - boolean; stack repeated elements horizontally instead of vertically (defaults to false)
  • offset-before - top/left offset in pixels (defaults to 0)
  • offset-after - bottom/right offset in pixels (defaults to 0)
  • scroll-margin - how many pixels ahead should elements be rendered while scrolling (defaults to 0)
  • latch - if true, elements will be rendered gradually but won't be removed when scrolled away (defaults to false)

  • size - an angular expression evaluating to the element's size (in pixels) - it is possible to use the ngRepeat's local repeaing variable in this expression

  • autoresize - use this attribute without vs-size and without specifying element's size. The automatically computed element style will
            readjust upon window resize if the size is dependable on the viewport size
  • scrolled-to-end - callback will be called when the last item of the list is rendered
  • scrolled-to-end-offset - set this number to trigger the scrolledToEnd callback n items before the last gets rendered
  • scrolled-to-beginning - callback will be called when the first item of the list is rendered
  • scrolled-to-beginning-offset - set this number to trigger the scrolledToBeginning callback n items before the first gets rendered

EVENTS:

  • vsRepeatTrigger - an event the directive listens for to manually trigger reinitialization
  • vsRepeatResize - an event the directive listens for to manually trigger the autosizing algorithm
  • vsRepeatReinitialized - an event the directive emits upon reinitialization done; the listener may accepts three arguments: event, startIndex and endIndex

changelog

Version 2.0.9 (2018/04/02)

  • support for with flex layouts

Version 2.0.7 (2018/03/20)

  • fixed bower.json and added license fields to package.json

Version 2.0.3 (2018/03/16)

  • BREAKING CHANGE: options are now passed as an object to the vs-repeat attribute
  • binary search algorithm to find which portion or the original collection should be rendered
  • scope variables like startIndex, endIndex etc. are now stored under vsRepeat object

Version 1.1.11 (2018/03/09)

  • vs-scroll-margin option (documentation on that will come shortly)

Version 1.1.10 (2017/03/07)

  • added some logging when there is size mismatch

Version 1.1.7 (2016/03/08)

  • memory leak fixed when using vs-scroll-parent

Version 1.1.6 (2016/03/01)

  • table fill content element fix

Version 1.1.5 (2016/02/27)

  • bugfixes and PRs merged
  • use vs-repeat-container to specify another repeat conainer (see readme)
  • use vs-scrolled-to-end to do something when last element gets rendered (see readme)

Version 1.1.4 (2016/01/17)

  • bugfixes

Version 1.1.2 (2015/12/06)

  • bugfix

Version 1.1.0 (2015/12/04)

Version 1.0.1-beta.2 (2015/12/04)

  • support for ng-repeat-start/ng-repeat-end

Version 1.0.0-beta.1 (2015/12/04)

  • bugfixes

Version 1.0.0-beta.0 (2015/12/04)

Major changes

  • elements are no longer absolutely positioned
  • no need for a mousewheel helper dummy element on MacOS (to preserve inertia scrolling)
  • no need for top updating directives - even better performance

Version 1.0.0-rc12 (2015/08/03)

  • general improvements

Version 1.0.0-rc11 (2015/06/05)

  • important bugfix

Version 1.0.0-rc10 (2015/06/03)

  • You can now specify an attribute vs-options="{latch: true}" to enable latching mode - elements once rendered are not being removed when scrolled away (improves scrolling performance when the rendering of each element is time consuming)
  • bugfixes

Version 1.0.0-rc9 (2015/05/25)

  • bugfixes

Version 1.0.0-rc8 (2015/05/25)

  • support for vs-scroll-parent="window"
  • bugfixes

Version 1.0.0-rc7 (2015/05/25)

bugfixes

Version 1.0.0-rc6 (2014/09/29)

FEATURES

  • added support for resizing items by changing the item size property and then $broadcasting()ing the vsRepeatTrigger event.

Version 1.0.0-rc5 (2014/08/01)

FEATURES

  • added an optional vs-autoresize attribute. You can use it without vs-size-property and without specifying element's size. The automatically computed element style will readjust upon window resize if the size is dependable on the viewport size.

Version 1.0.0-rc4 (2014/07/15)

FEATURES

  • added support for filters in the ngRepeat expression
  • added support for variable items sizes (if they are known up front)

Version 1.0.0-rc3 (2014/06/24)

Fixed a bug on Safari and optimized layout recalculations

Version 1.0.0-rc2 (2014/06/09)

Semver compatible version name

Version 1.0.0rc1 (2014/06/02)

FEATURES

  • added travis-ci integration
  • added unit tests
  • added minified version of the library
  • fixed some minor bugs
  • updated the DEMO that now also address the performance benefits of using the library

Version 0.3 (2014/05/30)

FEATURES

  • support for automatic computation of repeated elements' height/width

BREAKING CHANGE:

  • specifying the single element's size as a value of the vs-repeat attribute is no longer required. If it isn't provided the directive will calculate it automatically (once, the first time it renders at least one element). If for some reason you want to override that size, you can still provide is as a value of the vs-repeat attribute.

Version 0.2 (2014/05/25)

FEATURES

  • support for horizontally stacked elements (a vs-horizontal attribute must be placed on the element)
  • no need to use jQuery, vsRepeat can now work with angular (jqLite) only
  • support for before/after offsets (in pixels) via vs-offset-before and vs-offset-after
  • full support for nested vsRepeats and scrolling in both directions even within the same container

BREAKING CHANGE:

  • vs-top-offset attribute is now called vs-offset-before

Version 0.1

FEATURES

  • support for vertically stacked elements