Skip to content

Commit

Permalink
Support for count in showPrevious
Browse files Browse the repository at this point in the history
nav.showPrevious(count: 2)
  • Loading branch information
koenbok committed Nov 30, 2016
1 parent 13e72ba commit a65ffb2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions extras/Studio.framer/app.coffee
Expand Up @@ -9,17 +9,20 @@ class Card extends Layer


c1 = new Card() c1 = new Card()
c2 = new Card() c2 = new Card()
c3 = new Card(size: 400) c3 = new Card()


nav = new NavComponent(c1) nav = new NavComponent(c1)


nav.header = new Layer nav.header = new Layer
height: 80 height: 80
width: Screen.width width: Screen.width


nav.header.onClick -> nav.showPrevious() nav.header.onClick ->
nav.showPrevious(animate: false)


Utils.labelLayer(nav.header, "Header") Utils.labelLayer(nav.header, "Header")


c1.onClick -> nav.showNext(c2) c1.onClick -> nav.showNext(c2)
c2.onClick -> nav.showOverlayCenter(c3) c2.onClick -> nav.showNext(c3)

c3.onTap -> nav.showPrevious(count: 2)
7 changes: 6 additions & 1 deletion framer/Components/NavComponent.coffee
Expand Up @@ -173,7 +173,12 @@ class exports.NavComponent extends Layer
showPrevious: (options={}) => showPrevious: (options={}) =>
return unless @previous return unless @previous
return if @isTransitioning return if @isTransitioning
options = _.defaults({}, options, {animate: true}) options = _.defaults({}, options, {count: 1, animate: true})

if options.count > 1
count = options.count
@showPrevious(animate: false, count: 1) for n in [2..count]

previous = @_stack.pop() previous = @_stack.pop()
@_runTransition(previous?.transition, "back", options.animate, @current, previous.layer) @_runTransition(previous?.transition, "back", options.animate, @current, previous.layer)


Expand Down

0 comments on commit a65ffb2

Please sign in to comment.