Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Latest commit

 

History

History
106 lines (89 loc) · 4.56 KB

VirtualViewSequence.md

File metadata and controls

106 lines (89 loc) · 4.56 KB

##VirtualViewSequence 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
});

###class: VirtualViewSequence ⏏ ####new VirtualViewSequence(options)

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).

####virtualViewSequence.getPrevious() ⇒ VirtualViewSequence 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.

Returns: VirtualViewSequence - previous node.
####virtualViewSequence.getNext() ⇒ VirtualViewSequence 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.

Returns: VirtualViewSequence - next node.
####virtualViewSequence.get() ⇒ Renderable Get the value of this node.

Returns: Renderable - surface/view
####virtualViewSequence.getIndex() ⇒ Number Get the index of the node.

Returns: Number - Index of node.
####virtualViewSequence.toString() ⇒ String Get human readable string verion of the node.

Returns: String - node as a human readable string
####virtualViewSequence.cleanup() ⇒ VirtualViewSequence 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.

Returns: VirtualViewSequence - this.