dispatch:scrollview

v0.0.3Published 10 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

dispatch:scrollview

This package adds a high performance infinite scrollview. It uses Blaze and Meteors reactive data.

Limits at the moment / todo:

  • List have to be infinite - theres currently no way of limiting scroll
  • Still not user friendly - it should be safely contained as a ui block helper
  • Data cells have to be uniform in size - this will not change
  • Currently only support horisontal scrolling

Example

1  var list = new ScrollView({
2
3    // Where scroll view will be injected
4    container: container,
5
6    // Template to render { index: 0 } - can be positive and negative
7    template: Template.dateListItem,
8
9    // Offset if any percent or pixels
10    offset: [-0.5, 0],
11
12    // Width, Height - percent/pixels/undefined
13    size: [65, undefined],
14
15    // 'spring', [250, 15], 'ease' etc... Read docs for dispatch:interpolator
16    ease: 'iosScroll',
17
18    // Preload pages on each invisible side (ajust when using offset)
19    preload: {
20      x: 2,
21      y: 0
22    },
23
24    // Set initial index
25    index: {
26      x: 0,
27      y: 0
28    }
29
30    // Scroll parameters
31    resistance: 0.001,
32    pagePeriod: 200,
33    scrollWeight: 10,
34    minimumDuration: 200,
35    maximumDuration: 1000,
36
37
38    debug: false
39  });

API:

1  list.on
2  list.emit
3  list.disableEvents
4  list.enableEvents
5  list.currentIndex
6  list.destroy
7
8  // Move to coordinate
9  list.moveTo({ x, y });
10
11  // Scroll to coordinate
12  list.scrollTo({ x, y }, duration);
13
14  // Simply scrolls from one index to another - use carefully, mind the speed
15  list.scrollToIndex({ x, y }, duration);
16
17  // Jump will scroll directly into the new sequence if
18  // far away
19  list.jumpToIndex({ x, y }, duration);