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
Q

How do we access an element in an array?

A

We use square brackets containing the index of the element we’re looking for.
Ex: fruits [1]

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

How do we add to arrays?

A

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”)

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

Why arrays can be very powerful in CoffeeScript?

A

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.

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

Which method would we use to uppercase the first string elements of our fruits array?

A

fruits [0]. toUpperCase ()

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

How would we uppercase all our string elements inside our fruits array?

A

for fruit in fruits

fruit.toUpperCase()

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

What is an object?

A

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.

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

Can we store arrays and booleans in objects?

A

Yes

32
Q

Can we store objects inside objects?

A

Yes

33
Q
book =
Author:
name: "Kurt Vonnegut"
born: 1922
died: 2007

What is this?
And what is the difference between = and :

A

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
Q

What punctuation sign do we use to access properties in an object?

A

We use dots.

Ex: book.title

35
Q
book =
author:
name: "Kurt Vonnegut"
born: 1922
died: 2007

How to print the date of birth?

A

print book.author.born

=> 1922

36
Q

book =

pages: 256
genres: [“Science Fiction”, “Satire”]
fiction: true

How to print “Satire” ?

A

print book.genres[1]

=> “Satire”

37
Q

What is a method?

A

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
Q

book =

title: “Slaugherhouse Five”
read: -> print “All this happened, more or less.”

What is the read property and how to call it?

A

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
Q

What is new Layer() ?

A

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
Q
square = new Layer(
width: 200
height: 200
x: 100
y: 100
)
What's inside the brackets?
A

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
Q

How can we modify a layer’s appearance using CSS propertiesin Framer? (simple way)

A

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
Q

Which method do we use to animate a layer?

A

layer.animate()

43
Q

What do we need to specify so that the animate method will do something?

A

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
Q

Time-related properties (delay and time), are specified in seconds. By default, animations in Framer take…

A

1 second

45
Q
layer.animate
	properties:
		opacity: 0
	Time: .2
What do you see here?
A

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
Q

How do we add repeat and delay properties to our layer animation?

A
layer.animate
	properties:
		opacity: 0
	repeat: 4
	Delay: 2
47
Q

Which method do we use to “listen” for events triggered by the user?

A

We use the «on» method

48
Q

Does the «on method» takes arguments? If yes, which ones?

A

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
Q

When you use a function as an argument (like in the «on method»), it’s called a…

A

…callback

50
Q

In plain english, calling the on method with a callback is like saying…

A

…“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
Q

What is the syntax in CoffeeScript to indicate a function? Let’s say we want to declare functioName as a function

A

FunctionName = →

52
Q

When we give the «on method» a function as an argument, it doesn’t need…

A

…a name or an equals sign. We just need the -> part

53
Q

button.on(Events.Click , →)

Why the comma?

A

The comma is the separation between the first argument (the name of the event), and the second (the function).

54
Q

How do we access the properties of the screen we’re working with in Framer?

A

Framer.Device.screen

Ex:
Framer.Device.screen.width
Framer.Device.screen.height

55
Q

When we specify the value of curve property, what is the data type expected in Framer?

A

A string. Therefore it is specified in quotation marks.

Ex: “ease-in”

56
Q

How to trigger something after one animation is finished?

A

Layer.on Events.AnimationEnd, →

57
Q

As for Animation Curves, Spring is an alias for…

A

spring-rk4

58
Q

How many arguments does the spring function take?

A
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
Q

Which symbol means not in CoffeeScript?

A

!

60
Q

How do we set a value to its opposite?

A

We do =!

Ex: is_open = ! is_open

61
Q

Which method do we use to add states to a layer?

A

layer.states.add()

62
Q

Each state consists of…

A

…a name (string) and property pair(s). States are configuration objects.

63
Q

Which method enables to switch to the next state(s)?

A

layer.states.next()

64
Q

Which shortcut to quickly display documentation in Framer?

A

cmd + d

65
Q

How to deactivate click when scrolling on elements that are clickable otherwise?
(because we touch elements when scrolling)

A

if not scroll.isMoving

66
Q

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

A

layer.draggable.directionLock = true

67
Q

Are invisible/hidden Sketch layers imported into Framer?

A

Yes, as long as they’re inside a group. Their visibility is set to false inside Framer

68
Q

How does Framer handle Sketch’s artboards?

A

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
Q

There is a set of 3 keys for editing colors. Which are they?

A

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
Q

How to simulate a @2x rendering from a @1x Sketch import?

Can cause a slight blur rendering

A

Framer.Device.contentScale = 2

71
Q

Inside a loop, each time an element is created, can we store it inside an array?

A

Yes. We can add these lines:
myArray = [ ]
myArray.push(nameOfInstance)

72
Q

What is the other way to get/edit CSS properties of layers?

A

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
Q

How to edit the border of layerA? (2 ways)

A
layerA.style["border"] = "1px solid red"
layerA.style.border  = "1px solid red"
74
Q

How to edit several style propertiesof layerA?

A

layerA.style =
“outline”: “1px solid red”,
“padding”: “10px”

75
Q

How to print a specific style property? (like layerA’s outline)

A

print layerA.style[“outline”]

76
Q

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?

A

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.