Home

Awesome

Framer ViewStack Module

This is a module for the prototyping tool Framer. It helps you create and control views that stack on top of each other. You can swipe to dismiss them, or fan out the stack and select one to bring forward.

Swipe to dismissTap to fan outScroll
<img src="http://dickinson.is/viewstack/vs-swipe-exp.gif" width="200px"/><img src="http://dickinson.is/viewstack/vs-fan-out-sm.gif" width="200px"/><img src="http://dickinson.is/viewstack/vs-scrolling-exp.gif" width="200px"/>

Installation

Usage

Setup

Create the view stack, and then add a view to it using the addView method.

stack = new ViewStack.Manager

myview = stack.addView
  contents: myLayer

contents is required and can be a layer or an array of layers. These will get added to the view's ScrollView in the order they appear in the array, so list the elements from bottom to top. The ScrollView allows vertical scrolling, and its content layer is sized to fit the content you pass into it.

The view gets added but is kept off screen. To display it, use the presentView method.

All addView Options

myview = stack.addView
  contents: myLayer
  title: "My View"    # default: no title
  tintColor: "#fff"   # defualt: "#000"
  arrowColor: "#000"  # default: "rgba(0,0,0,0.4)"

Presenting Views

Use the presentView method to display a view on screen.

stack.presentView(myview)

When more than one view has been presented, they will stack.

Example

# create content layers
one = new Layer
  frame: Screen.frame
  backgroundColor: "rgba(0,128,255,1)"
two = new Layer
  frame: Screen.frame
  backgroundColor: "rgba(255,128,0,1)"

# create stack manager
ViewStack = require "viewstack"
stack = new ViewStack.Manager

# add views to the stack, passing in sketch layers with the contents parameter
view_one = stack.addView
	contents: one
	title: "One"
	tintColor: "#000"
view_two = stack.addView
	contents: two
	title: "Two"
	tintColor: "#000"

# add tap events to present views
one.on Events.Tap, ->
	stack.presentView(view_two)

# present first view
stack.presentView(view_one)

Fanning Out

When views are stacked onscreen tapping the top area will fan all of them out and let you select one. This is enabled by default, but you can turn it off by setting the fanOut parameter to false when you create the view stack.

stack = new ViewStack.Manager
  fanOut: false

You can also fan out the current stack of views programmatically with stack.fanOut() -- If there's more than one view on screen and the feature hasn't been disabled.

Managing Views

Changing Views

Helpers

Views have helper methods you can use to get access to specific layers.


To do