This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Johannes Eckert
Posted Aug 13 - Read on Facebook

if I just want to quickly test an assumption or simply see where a view is positioned while writing code, in the browser I entered layer.x into the console. in Studio, the console does not know about these objects. what's the easiest way to debug this way?

6 Comments

Seoh Char

window.layer = new Layer # declare a variable on global

Alex Hazel

Here is some more helpful info on globals in coffeescript and node.js

http://stackoverflow.com/questions/4214731/coffeescript-global-variables

Johannes Eckert

ok, attaching it to the window, the variable I import on I add to the window just so I can experiment with it inthe console…

sketch = Framer.Importer.load "imported/XYZ"
window.sketch = sketch

Alex Hazel

Technically, if you are doing everything correctly, you don't REALLY need to use a global variable. That is why Coffeescript does everything in its power to stop you from clouding the global namespace with them. Also that is the point of closures. Very rarely are globals justified.

And instead of logging the values to the console, what if you just display the values in the preview window of Framer and have the coordinates update automatically each time Framer recompiles.

item = new Layer
height:100
width:100
x:this.x #-When you move the item it will always report it's location
y:this.y
item.center()

display = new Layer
x:0
y:0
height: 40
width: 170
display.html = "x: #{item.x}, y: #{item.y}"

Johannes Eckert

hank you Alex Hazel! that is a very good explanation. in that case, I just wanted to test an assumption like a math calculation at a certain point during the time of the prototype… like

layer.x - otherlayer.height

I wouldn't need that permanently and just want to debug a certain situatuion to see if what I am seeing is correct or if my math was off

Johannes Eckert

I am using "print layer.x" sometimes, but it creates a weird debug window right in the middle of my prototype …

Read the entire post on Facebook