Virtual ViewSequence for famo.us which creates & destroys nodes using a factory delegate. The factory class should support the following functions:
- create()
- createNext(prevRenderable)
- createPrevious(nextRenderable)
- destroy(renderable) (optional)
Example:
var VirtualViewSequence = require('famous-flex/VirtualViewSequence');
// Factory for creating surfaces
function MyFactory() {}
MyFactory.prototype.create = function(index) {
var surface = new Surface({
size: [undefined, 100],
classes: ['my-surface']
});
surface.index = index || 0; // add property to renderable
return surface;
};
MyFactory.prototype.createNext = function(renderable) {
return this.create(renderable.index + 1);
};
MyFactory.prototype.createPrevious = function(renderable) {
return this.create(renderable.index - 1);
};
// Create infinite scrollview
var viewSequence = new VirtualViewSequence({
factory: new MyFactory()
});
var scrollView = new FlexScrollView({
dataSource: viewSequence
});
- VirtualViewSequence
- VirtualViewSequence ⏏
- new VirtualViewSequence(options)
- .getPrevious() ⇒
VirtualViewSequence
- .getNext() ⇒
VirtualViewSequence
- .get() ⇒
Renderable
- .getIndex() ⇒
Number
- .toString() ⇒
String
- .cleanup() ⇒
VirtualViewSequence
- VirtualViewSequence ⏏
Param | Type | Description |
---|---|---|
options | Object |
Configurable options. |
options.factory | Object |
Factory delegate for creating new renderables. |
[options.value] | Renderable |
Renderable for this node (when omitted, factory.create() is called) |
[options.index] | Number |
Index of this node (default: 0). |
Get previous node.
When no previous node exists, the factory-delegate function createPrevious
is called to construct a renderable for the previous node. When createPrevious
returns undefined
, no previous-node will be created.
Kind: instance method of VirtualViewSequence
Returns: VirtualViewSequence
- previous node.
Get next node.
When no next node exists, the factory-delegate function createNext
is called to construct a renderable for the next node. When createNext
returns undefined
, no next-node will be created.
Kind: instance method of VirtualViewSequence
Returns: VirtualViewSequence
- next node.
Get the value of this node.
Kind: instance method of VirtualViewSequence
Returns: Renderable
- surface/view
Get the index of the node.
Kind: instance method of VirtualViewSequence
Returns: Number
- Index of node.
Get human readable string verion of the node.
Kind: instance method of VirtualViewSequence
Returns: String
- node as a human readable string
Cleans up any un-accessed nodes since the previous call to cleanup
.
This function cleans up any nodes that have not been accessed
since the last call to cleanup
. When a node is accessed
through a call to getNext
, getPrevious
, get
or getIndex
it is considered touched
and should not be cleaned up.
Kind: instance method of VirtualViewSequence
Returns: VirtualViewSequence
- this.