Skip to content

Commit

Permalink
Always scale to fit after we switch from fullscreen to device
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbok committed Nov 26, 2014
1 parent e33a47b commit 24de214
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
46 changes: 12 additions & 34 deletions extras/CactusFramer/static/app.coffee
@@ -1,37 +1,15 @@
Framer.Device = new Framer.DeviceView()
Framer.Device.setupContext()


selectionLayer = null

ctx = new Framer.Context name:"highlight"
ctx.run ->
selectionLayer = new Layer

selectionLayer.style =
border: "1px solid red"
zIndex: 1000

# Welcome to Framer

# Learn how to prototype: http://framerjs.com/learn
# Drop an image on the device, or import a design from Sketch or Photoshop

iconLayer = new Layer width:256, height:256
iconLayer.center()

# Define a set of states with names (the original state is 'default')
iconLayer.states.add
second: {y:100, scale:0.6, rotationZ:100}
third: {y:300, scale:1.3, blur:4}
fourth: {y:200, scale:0.9, blur:2, rotationZ:200}

# Set the default animation options
iconLayer.states.animationOptions =
curve: "spring(500,12,0)"

# On a click, go to the next state
iconLayer.on Events.Click, ->
iconLayer.states.next()

selectionLayer.frame = iconLayer.screenScaledFrame()
Framer.Device.deviceType = "desktop-browser-1440"

f = false
l = new Layer

l.on Events.Click, ->
if f is true
Framer.Device.deviceType = "desktop-browser-1440"
f = false
else
Framer.Device.deviceType = "fullscreen"
f = true
6 changes: 6 additions & 0 deletions framer/DeviceView.coffee
Expand Up @@ -237,6 +237,9 @@ class exports.DeviceView extends BaseClass
if @_device is device
return

# If we switch from fullscreen to a device, we should zoom to fit
shouldZoomToFit = @_deviceType is "fullscreen"

@_device = device
@_deviceType = deviceType
@fullscreen = false
Expand All @@ -246,6 +249,9 @@ class exports.DeviceView extends BaseClass
@_positionKeyboard()
@emit("change:deviceType")

if shouldZoomToFit
@deviceScale = "fit"

_updateDeviceImage: =>
if @_shouldRenderFullScreen()
@phone.image = ""
Expand Down

0 comments on commit 24de214

Please sign in to comment.