Framer-CoffeeScript-Javascript-FlashCards

1
Q

Which character do we use for decimal numbers?

A

The point (not the comma)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to insert a string

A

Strings come in quotation marks.
“This is a string”
‘This is also a string’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to concatenate strings?

A

Using a + sign:

"My name is " + "Tessa"
# => "My name is Tessa
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which type of data is this:

“40”

A

This is a string (because inside quotation marks)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

“50” + “50”

A

=> “5050”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to assign a variable?

A

Variables are assigned using the = operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a variable?

A

Variables let you assign a value to an arbitrary symbol for later reference. A variable is a box you can put values into. Any kind of value, like a string or a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Variables can’t…

A

Variables
• can’t contain spaces
• can’t start with numbers
• can’t contain punctuation or symbols other than _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the common naming convention for variable names?

A

CamelCase

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do we make a string interpolation?

a variable inside a string

A

We can embed the variable right in the string if we surround it with #{}

print “my favorite color is #{color}, what’s yours?”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are boolean values?

A

Booleans are values that are either true or false. They’re indicated with just the words true or false without quotation marks.

myBoolean = true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which operator do we use to indicate that two values are the same?

A

is or ==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What do we use to negate a condition?

A

To negate a condition you use the keyword “is not”. In place of “is not” you can use the shortform “isnt”.

num = 5
num isnt 10
# => true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which syntax for conditional statements?

A

if/else

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

CoffeeScript avoids using symbols like semi-colons and parentheses. But in return, we need to follow certains rules about…

A

… indentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do we insert comments in Coffee Script?

A

Using #

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

myObjectA =

name: “Framer”
age: 12

How to target the name property here?

A

2 options:

myObjectA.name
myObjectA[“name”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How do we indicate that we’re putting a function in CoffeeScript?

A

Using the -> arrow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

checkAge()

What do the brackets mean?

A

The () part basically means “go”. It tells the computer “run the function in the checkAge variable”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Functions can be even more useful if we can give them values to work with. These values are called…

A

Parameters when creating the function.

Arguments when calling the function and assigning values to those parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

In CoffeeScript, we can give a function the ability to accept arguments. How do we do that?

A

By adding parenthesis containing the argument name before the -> sign

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are arrays?

A

Arrays are lists or collections of multiple items

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Arrays have some built in methods (functions that they can use) for finding out information about them, like length.
fruits = [“apples”, “oranges”, “bananas”]
How to get the length of this array?

A

fruits.length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

You can access elements in an array by their index. The index is the element’s position within the array.
But there’s a warning! Which one?

A

Arrays are zero-indexed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How do we access an element in an array?
We use square brackets containing the index of the element we’re looking for. Ex: fruits [1]
26
How do we add to arrays?
You can add new items to an array with the method push. push adds the item you specify to the end of the array. Ex: fruits.push("kiwis")
27
Why arrays can be very powerful in CoffeeScript?
Because they let you repeat certain functionality over and over with different items by using loops. Loops let you do something for every item in an array.
28
Which method would we use to uppercase the first string elements of our fruits array?
fruits [0]. toUpperCase ()
29
How would we uppercase all our string elements inside our fruits array?
for fruit in fruits | fruit.toUpperCase()
30
What is an object?
An object is a collection of properties. In programming, a property is an association between a name and a value. If something has properties, you can store them in an object.
31
Can we store arrays and booleans in objects?
Yes
32
Can we store objects inside objects?
Yes
33
``` book = Author: name: "Kurt Vonnegut" born: 1922 died: 2007 ``` What is this? And what is the difference between = and :
This is an object inside another object. Note that we use = and : in the above example. Note the difference: "=" assigns a variable name (book) to an object, and ":" matches up names and values. "author" is the name, and the object containing name, born, and died is the value.
34
What punctuation sign do we use to access properties in an object?
We use dots. | Ex: book.title
35
``` book = author: name: "Kurt Vonnegut" born: 1922 died: 2007 ``` How to print the date of birth?
print book.author.born => 1922
36
book = pages: 256 genres: ["Science Fiction", "Satire"] fiction: true How to print "Satire" ?
print book.genres[1] => "Satire"
37
What is a method?
Since we can store any kind of data in an object’s properties, we can also store functions as properties. When a function is the property of an object, it is called a method.
38
book = title: "Slaugherhouse Five" read: -> print "All this happened, more or less." What is the read property and how to call it?
The read property is a method (a function that is the property of an object) that belongs to our book object. We can call itlike we would any function: book.read() ``` # => "All this happened, more or less." This is how the toUpperCase method works. It’s a method that belongs to allstring objects. ```
39
What is new Layer() ?
This is a special kind of function that creates an object. square = new Layer () By default, in Framer it will create a 100*100 square with semi transparent blue color: rgba(0, 124, 255, .5)
40
``` square = new Layer( width: 200 height: 200 x: 100 y: 100 ) What's inside the brackets? ```
An argument (of the new Layer function). And this argument is a configuration object. And the properties inside this configuration object are the attributes like width, height, x, y, etc.). To make that code a bit easier to read, we can get rid of the parentheses
41
How can we modify a layer's appearance using CSS properties in Framer ? (simple way)
You can modify a layer’s coordinates (x, y), as well as appearance by using camel-cased (camelCased) versions of most CSS properties, as well as some built-in framer properties. For example, color is just color but border-radius becomes borderRadius. If you want to rotate an element, you can modify the rotation property framer provides.
42
Which method do we use to animate a layer ?
layer.animate()
43
What do we need to specify so that the animate method will do something ?
By itself, .animate() isn’t goint to do anything. We need to pass it a configuration object to tell it what to animate, and how to animate it. A configuration object will follow this format: ``` configObject = properties: property: value property: value time: 1 curve: "ease" delay: 2 ```
44
Time-related properties (delay and time), are specified in seconds. By default, animations in Framer take...
1 second
45
``` layer.animate properties: opacity: 0 Time: .2 What do you see here ? ```
Whitespace is significant here. "properties" is an object (it’s an object nested inside an object). opacity is a property, so it’s indented one level further than "properties" to indicate the relationship. Time is a property of the animation, not a property of the object animating. Hence the outdent
46
How do we add repeat and delay properties to our layer animation ?
``` layer.animate properties: opacity: 0 repeat: 4 Delay: 2 ```
47
Which method do we use to “listen” for events triggered by the user ?
We use the « on » method
48
Does the « on method » takes arguments ? If yes, which ones ?
This is actually a method being called with two arguments, though it may not look like it. The format for the on method is on(eventName, function), where the function is the code that gets run when the event is triggered. It might make more sense if we leave on the parentheses: button.on(Events.Click , →)
49
When you use a function as an argument (like in the « on method »), it’s called a...
...callback
50
In plain english, calling the on method with a callback is like saying...
...“listen for and do”, and the two arguments are the thing that you’re listening for, and the thing that you should then do.
51
What is the syntax in CoffeeScript to indicate a function ? Let's say we want to declare functioName as a function
FunctionName = →
52
When we give the « on method » a function as an argument, it doesn’t need...
...a name or an equals sign. We just need the -> part
53
button.on(Events.Click , →) | Why the comma ?
The comma is the separation between the first argument (the name of the event), and the second (the function).
54
How do we access the properties of the screen we’re working with in Framer?
Framer.Device.screen Ex: Framer.Device.screen.width Framer.Device.screen.height
55
When we specify the value of curve property, what is the data type expected in Framer ?
A string. Therefore it is specified in quotation marks. | Ex : "ease-in"
56
How to trigger something after one animation is finished ?
Layer.on Events.AnimationEnd, →
57
As for Animation Curves, Spring is an alias for...
spring-rk4
58
How many arguments does the spring function take ?
``` The spring function takes 4 arguments (the last one is optional): 1 tension (Strength of the spring) 2 friction (Weight of the spring) 3 velocity (Velocity at the start) 4 tolerance (Minimal threshold before the animation ends. (Optional)) ```
59
Which symbol means not in CoffeeScript ?
!
60
How do we set a value to its opposite ?
We do = ! | Ex : is_open = ! is_open
61
Which method do we use to add states to a layer ?
layer.states.add()
62
Each state consists of...
...a name (string) and property pair(s). States are configuration objects.
63
Which method enables to switch to the next state(s) ?
layer.states.next()
64
Which shortcut to quickly display documentation in Framer?
cmd + d
65
How to deactivate click when scrolling on elements that are clickable otherwise? (because we touch elements when scrolling)
if not scroll.isMoving
66
How to prevent a draggable element which also contains a scroll from doing both interaction at the same time? Usually, we don't scroll while dragging
layer.draggable.directionLock = true
67
Are invisible/hidden Sketch layers imported into Framer?
Yes, as long as they're inside a group. Their visibility is set to false inside Framer
68
How does Framer handle Sketch's artboards?
Only the first Artboard will be visible by default. All other Artboards are hidden, and positioned on top of each other. The x and y properties of imported Artboards are always set to 0.
69
There is a set of 3 keys for editing colors. Which are they?
layer. hueRotate (number btw 0 and 360) layer. saturate (number btw 0 and 100) layer. brightness ( number btw 0 and -> it depends on initial color or image)
70
How to simulate a @2x rendering from a @1x Sketch import? | Can cause a slight blur rendering
Framer.Device.contentScale = 2
71
Inside a loop, each time an element is created, can we store it inside an array?
Yes. We can add these lines: myArray = [ ] myArray.push(nameOfInstance)
72
What is the other way to get/edit CSS properties of layers ?
layer.style Next to the standard CSS property names you can also camelCase naming. For example, layer.style["border-color"] is the same as layer.style.borderColor
73
How to edit the border of layerA ? (2 ways)
``` layerA.style["border"] = "1px solid red" layerA.style.border = "1px solid red" ```
74
How to edit several style properties of layerA?
layerA.style = "outline": "1px solid red", "padding": "10px"
75
How to print a specific style property ? (like layerA's outline)
print layerA.style["outline"]
76
When crafting animations, why is it often better to base a function on a layer property (ex : layer.height) instead of on the actual value of this property ?
Because if we update the layer (in Sketch or by overwriting later in the code), the actual value will be outdated. Relative values are often better.