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

Commit

Permalink
Updated docs + readme
Browse files Browse the repository at this point in the history
  • Loading branch information
IjzerenHein committed Jan 15, 2015
1 parent 160c273 commit f43904b
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 64 deletions.
5 changes: 4 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ module.exports = function(grunt) {
{ src: 'src/ScrollController.js', dest: 'docs/ScrollController.md' },
{ src: 'src/FlexScrollView.js', dest: 'docs/FlexScrollView.md' },
{ src: 'src/LayoutUtility.js', dest: 'docs/LayoutUtility.md' },
{ src: 'src/VirtualViewSequence.js', dest: 'docs/VirtualViewSequence.md' },
// helpers
{ src: 'src/helpers/LayoutDockHelper.js', dest: 'docs/helpers/LayoutDockHelper.md' },
// layouts
{ src: 'src/layouts/CollectionLayout.js', dest: 'docs/layouts/CollectionLayout.md' },
{ src: 'src/layouts/GridLayout.js', dest: 'docs/layouts/GridLayout.md' },
{ src: 'src/layouts/ListLayout.js', dest: 'docs/layouts/ListLayout.md' },
{ src: 'src/layouts/HeaderFooterLayout.js', dest: 'docs/layouts/HeaderFooterLayout.md' },
{ src: 'src/layouts/NavBarLayout.js', dest: 'docs/layouts/NavBarLayout.md' }
{ src: 'src/layouts/NavBarLayout.js', dest: 'docs/layouts/NavBarLayout.md' },
{ src: 'src/layouts/WheelLayout.js', dest: 'docs/layouts/WheelLayout.md' },
{ src: 'src/layouts/ProportionalLayout.js', dest: 'docs/layouts/ProportionalLayout.md' }
]
}
}
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ of renderables using a `GridLayout`, and change that into a `ListLayout`. When u

### [Layouts](#standard-layouts)
- [GridLayout](docs/layouts/GridLayout.md)
- [ListLayout](docs/layouts/ListLayout.md)
- [CollectionLayout](docs/layouts/CollectionLayout.md)
- [ProportionalLayout](docs/layouts/ProportionalLayout.md)
- [HeaderFooterLayout](docs/layouts/HeaderFooterLayout.md)
- [NavBarLayout](docs/layouts/NavBarLayout.md)
- [ListLayout](docs/layouts/ListLayout.md) *(scrollable)*
- [CollectionLayout](docs/layouts/CollectionLayout.md) *(scrollable)*
- [WheelLayout](docs/layouts/WheelLayout.md) *(scrollable)*

### Resources
- [API reference](#api-reference)
Expand Down Expand Up @@ -249,10 +251,13 @@ custom layouts. Key features:
|Layout|DataSource|Scrollable|Description|
|---|---|---|---|
|[GridLayout](docs/layouts/GridLayout.md)|ViewSequence / Array|No|Grid-layout with fixed number of rows & columns.|
|[ListLayout](docs/layouts/ListLayout.md)|ViewSequence / Array|Yes|List layout with margins, spacing and optionally sticky headers.|
|[CollectionLayout](docs/layouts/CollectionLayout.md)|ViewSequence / Array|Yes|Lays out renderables with a specific width & height.|
|[ProportionalLayout](docs/layouts/ProportionalLayout.md)|ViewSequence / Array|No|Lays out renderables sequentially and sizes them proportionally.|
|[HeaderFooterLayout](docs/layouts/HeaderFooterLayout.md)|Id-based|No|Layout containing a top-header, bottom- footer and content.|
|[NavBarLayout](docs/layouts/NavBarLayout.md)|Id-based|No|Layout containing one or more left and right items and a title.|
|*Scrollable layouts:*|
|[ListLayout](docs/layouts/ListLayout.md)|ViewSequence / Array|Yes|List layout with margins, spacing and optionally sticky headers.|
|[CollectionLayout](docs/layouts/CollectionLayout.md)|ViewSequence / Array|Yes|Lays out renderables with a specific width & height.|
|[WheelLayout](docs/layouts/WheelLayout.md)|ViewSequence / Array|Yes|Lays out renderables in a wheel (slot-machine) formation.|


## API reference
Expand All @@ -264,6 +269,7 @@ custom layouts. Key features:
|[FlexScrollView](docs/FlexScrollView.md)|Flexible scroll-view with pull-to-refresh, margins & spacing and more good stuff.|
|[LayoutContext](docs/LayoutContext.md)|Context used for writing layout-functions.|
|[LayoutUtility](docs/LayoutUtility.md)|Utility class containing helper functions.|
|[VirtualViewSequence](docs/VirtualViewSequence.md)|Infinite view-sequence which uses a factory delegate to create renderables.|


## Roadmap
Expand Down
6 changes: 4 additions & 2 deletions docs/LayoutController.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Events:
* [layoutController.getLayoutOptions()](#module_LayoutController#getLayoutOptions)
* [layoutController.setDirection(direction)](#module_LayoutController#setDirection)
* [layoutController.getDirection([actual])](#module_LayoutController#getDirection)
* [layoutController.getSpec(node)](#module_LayoutController#getSpec)
* [layoutController.getSpec(node, normalize)](#module_LayoutController#getSpec)
* [layoutController.reflowLayout()](#module_LayoutController#reflowLayout)
* [layoutController.insert(indexOrId, renderable, [insertSpec])](#module_LayoutController#insert)
* [layoutController.push(renderable, [insertSpec])](#module_LayoutController#push)
Expand All @@ -45,6 +45,7 @@ Events:
- \[dataSource\] `Array` | `ViewSequence` | `Object` - Array, ViewSequence or Object with key/value pairs.
- \[direction\] `Utility.Direction` - Direction to layout into (e.g. Utility.Direction.Y) (when ommited the default direction of the layout is used)
- \[flow\] `Bool` - Enables flow animations when the layout changes (default: `false`).
- \[reflowOnResize\] `Bool` - Smoothly reflows renderables on resize (only used when flow = true) (default: `true`).
- \[insertSpec\] `Spec` - Size, transform, opacity... to use when inserting new renderables into the scene (default: `{}`).
- \[removeSpec\] `Spec` - Size, transform, opacity... to use when removing renderables from the scene (default: `{}`).
- \[alwaysLayout\] `Bool` - When set to true, always calls the layout function on every render-cycle (default: `false`).
Expand Down Expand Up @@ -143,13 +144,14 @@ never returns undefined.

**Returns**: `Utility.Direction` - Direction or undefined
<a name="module_LayoutController#getSpec"></a>
###layoutController.getSpec(node)
###layoutController.getSpec(node, normalize)
Get the spec (size, transform, etc..) for the given renderable or
Id.

**Params**

- node `Renderable` | `String` - Renderabe or Id to look for
- normalize `Bool` - When set to `true` normalizes the origin/align into the transform translation (default: `false`).

**Returns**: `Spec` - spec or undefined
<a name="module_LayoutController#reflowLayout"></a>
Expand Down
18 changes: 15 additions & 3 deletions docs/ScrollController.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Events:
|event |description|
|-----------|-----------|
|scrollstart|Emitted when scrolling starts.|
|scroll |Emitted as the content scrolls (once for each frame the visible offset has changed)|
|pagechange |Emitted whenever visible page changes and options.paging is set to true.|
|scroll |Emitted as the content scrolls (once for each frame the visible offset has changed).|
|pagechange |Emitted whenever the visible page changes.|
|scrollend |Emitted after scrolling stops (when the scroll particle settles).|

Inherited from: [LayoutController](./LayoutController.md)
Expand Down Expand Up @@ -49,14 +49,15 @@ Inherited from: [LayoutController](./LayoutController.md)
* [scrollController.applyScrollForce(delta)](#module_ScrollController#applyScrollForce)
* [scrollController.updateScrollForce(prevDelta, newDelta)](#module_ScrollController#updateScrollForce)
* [scrollController.releaseScrollForce(delta, [velocity])](#module_ScrollController#releaseScrollForce)
* [scrollController.getSpec(node, normalize)](#module_ScrollController#getSpec)

<a name="exp_new_module_ScrollController"></a>
###new ScrollController(options)
**Params**

- options `Object` - Configurable options (see LayoutController for all inherited options).
- \[useContainer\] `Bool` - Embeds the view in a ContainerSurface to hide any overflow and capture input events (default: `false`).
- \[useContainerOverflow\] `String` - Overflow mode that is used when the `useContainer` option is true (default: `hidden`).
- \[container\] `String` - Options that are passed to the ContainerSurface in case `useContainer` is true.
- \[paginated\] `Bool` - Enabled pagination when set to `true` (default: `false`).
- \[alignment\] `Number` - Alignment of the renderables (0 = top/left, 1 = bottom/right) (default: `0`).
- \[mouseMove\] `Bool` - Enables scrolling by holding the mouse-button down and moving the mouse (default: `false`).
Expand Down Expand Up @@ -267,3 +268,14 @@ the scroll offset and corresponds to the `touchend` event.
- \[velocity\] `Number` - Velocity to apply after which the view keeps scrolling

**Returns**: `ScrollController` - this
<a name="module_ScrollController#getSpec"></a>
###scrollController.getSpec(node, normalize)
Get the spec (size, transform, etc..) for the given renderable or
Id.

**Params**

- node `Renderable` | `String` - Renderabe or Id to look for.
- normalize `Bool` - When set to `true` normalizes the origin/align into the transform translation (default: `false`).

**Returns**: `Spec` - spec or undefined
105 changes: 105 additions & 0 deletions docs/VirtualViewSequence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<a name="module_VirtualViewSequence"></a>
#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:

```javascript
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
});
```

<a name="exp_module_VirtualViewSequence"></a>
##class: VirtualViewSequence ⏏
**Members**

* [class: VirtualViewSequence ⏏](#exp_module_VirtualViewSequence)
* [new VirtualViewSequence(options)](#exp_new_module_VirtualViewSequence)
* [virtualViewSequence.getPrevious()](#module_VirtualViewSequence#getPrevious)
* [virtualViewSequence.getNext()](#module_VirtualViewSequence#getNext)
* [virtualViewSequence.get()](#module_VirtualViewSequence#get)
* [virtualViewSequence.getIndex()](#module_VirtualViewSequence#getIndex)
* [virtualViewSequence.toString()](#module_VirtualViewSequence#toString)
* [virtualViewSequence.cleanup()](#module_VirtualViewSequence#cleanup)

<a name="exp_new_module_VirtualViewSequence"></a>
###new VirtualViewSequence(options)
**Params**

- options `Object` - Configurable options.
- factory `Object` - Factory delegate for creating new renderables.
- \[value\] `Renderable` - Renderable for this node (when omitted, `factory.create()` is called)
- \[index\] `Number` - Index of this node (default: 0).

<a name="module_VirtualViewSequence#getPrevious"></a>
###virtualViewSequence.getPrevious()
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.
<a name="module_VirtualViewSequence#getNext"></a>
###virtualViewSequence.getNext()
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.
<a name="module_VirtualViewSequence#get"></a>
###virtualViewSequence.get()
Get the value of this node.

**Returns**: `Renderable` - surface/view
<a name="module_VirtualViewSequence#getIndex"></a>
###virtualViewSequence.getIndex()
Get the index of the node.

**Returns**: `Number` - Index of node.
<a name="module_VirtualViewSequence#toString"></a>
###virtualViewSequence.toString()
Get human readable string verion of the node.

**Returns**: `String` - node as a human readable string
<a name="module_VirtualViewSequence#cleanup"></a>
###virtualViewSequence.cleanup()
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.
27 changes: 27 additions & 0 deletions docs/layouts/ProportionalLayout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<a name="module_ProportionalLayout"></a>
#ProportionalLayout
Lays-out renderables sequentially based on size-ratios (similar to the stock famo.us FlexibleLayout view).

|options|type|description|
|---|---|---|
|`ratios`|Array|Size-ratios of the renderables.|

Example:

```javascript
var ProportionalLayout = require('famous-flex/layouts/ProportionalLayout');

var layoutController = new LayoutController({
layout: ProportionalLayout,
layoutOptions: {
ratios: [1, 1, 2, 1], // total size: 5
},
dataSource: [
new Surface({content: 'item 1'}), // 20%
new Surface({content: 'item 2'}), // 20%
new Surface({content: 'item 3'}), // 40%
new Surface({content: 'item 4'}) // 20%
]
});
```

41 changes: 41 additions & 0 deletions docs/layouts/WheelLayout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<a name="module_WheelLayout"></a>
#WheelLayout
Lays out renderables in a spinner wheel (slot-machine wheel) formation.

|options|type|description|
|---|---|---|
|`itemSize`|Size|Size (width or height) of an item to layout.|
|`[diameter]`|Number|Diameter of the wheel in pixels (default: `3 x itemSize`).|
|`[radialOpacity]`|Number|Opacity (0..1) at the diameter edges of the wheel (default: 1).|

Example:

```javascript
var ContainerSurface = require('famous/surfaces/ContainerSurface');
var ScrollController = require('famous-flex/ScrollController');
var WheelLayout = require('famous-flex/layouts/WheelLayout');

// Create scroll-wheel
var scrollWheel = new ScrollController({
layout: WheelLayout,
layoutOptions: {
itemSize: 100, // item has height of 100 pixels
radialOpacity: 0.5 // make items at the edges more transparent
},
dataSource: [
new Surface({content: 'item 1'}),
new Surface({content: 'item 2'}),
new Surface({content: 'item 3'})
]
});

// Create a container-surface for clipping and give it a nice perspective
var container = new ContainerSurface({
properties: {
overflow: 'hidden'
}
});
container.context.setPerspective(1500);
container.add(scrollWheel);
```

Loading

0 comments on commit f43904b

Please sign in to comment.