Framer and CoffeeScript 1 Flashcards

1
Q

What does @ symbol mean in CoffeeScript?

A

CoffeeScript has a few nice features related to the this keyword.

  • First, CoffeeScript uses the @ symbol as shorthand for “this.”. For example, @foo is equivalent to this.foo.
  • Second, if you use the @ symbol in the parameters of a function, CoffeeScript will automatically assign those values as properties of the object.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to import (from Sketch into Framer) an asset with some transparent padding? (2 techniques)

A
  • Export it manually in the images folder with the transparency (using “slices” for example)
  • Use a mask in Sketch that is bigger than the element to mask (so that it will generate the padding around the element). Then, the Framer import function will consider this layer as a whole (need to be a group in Sketch).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to print the properties of myObject?

A

for… of (“key” and “value” are just conventional words that you can change)

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

Illustrate what are x and y for an object

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

Illustrate what is midX

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

Illustrate what is midY

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

Illustrate what are minX and minY

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

Illustrate what are maxX and maxY

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

Another keyword can be used for that

A

unless

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

What should be the value for the else condition to work?

A

==21

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

Which property allows you to set or capture the x, and y values of a layer?

A

layer.point

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

Which property allows you to set or capture the width and height values of a layer?

A

layer.size

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

Which property allows you to set or capture the x, y, width and height values of a layer?

A

layer.frame

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

Which property gets or sets all properties for a layer?

A

layer.props

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

Which shortcut to quickly display documentation in Framer?

A

cmd + d

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

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

A

if not scroll.isMoving

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
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

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

How does Framer handle Sketch’s artboards?

A

Based on the most left artboard.

The x and y properties of the most left artboard on your canvas will be set to 0, 0. All other artboards are positioned relative to this one.

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

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

(Can cause a slight blur rendering)

A

Framer.Device.contentScale = 2

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

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

A

Yes. We can add these lines:

Before/outside the loop, we declare the array

myArray = []

(…)

We add to the array
myArray.push(nameOfInstance)

or see below capture for more options

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

How to easily get/edit most of the CSS properties of layers ?

(-> which layer member is it and which naming convention for the properties?)

A

layer.style
Next to the standard CSS property names (string) you can also camelCase naming.

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

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

A
  • layerA.style[“border”] = “1px solid red”
  • layerA.style.border = “1px solid red”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Give two ways to edit the border color of layerA

A
  • layerA.style[“border-color”] =
  • layerA.style.borderColor =
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

How to edit several style properties of layerA?

A

layerA.style =

“outline”: “1px solid red”,
“padding”: “10px”

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

How to print a specific style property ?

(like layerA’s outline or box-shadow)

A
  • print layerA.style[“outline”]
  • print layerA.style.outline
  • print layerA.style[“box-shadow”]
  • print layerA.style.boxShadow
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

When crafting animations, why is it often better to base a function on a layer.property expression (ex: sth = layerA.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.

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

What allows you to set or capture the absolute position of a layer on the screen, ignoring the inherited position from its parents ?

A

layer.screenFrame <object></object>

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

What type of data do we get if we print layer.subLayers?

A

An array

layer.subLayers <array></array>

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

What is the difference between the first technique and the 2 others?

A

In the first case, items created inside the loop just get assigned a name and some properties but aren’t stored inside a variable, so we cannot play with them separately afterwards and do something like print(item1)

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

What is this:

layer.draggable.speedX <number></number>

A

Modify the horizontal dragging speed. The value is in pixels per mouse moved pixels. The default value is 1. When set lower then 1 dragging will be slower than mouse movement and vice versa. You can set the value to 0 to disable horizontal dragging.

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

What is this:

page.snapToPage(page, animate, animationOptions)

A

Snap to a specific page. Takes three arguments:

  • a page.content layer
  • animate (true or false)
  • animation options

By default, animate is set to true and the animationCurve use a spring curve.

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

layerA = new BackgroundLayer

What is the specificity about BackgroundLayers concerning the fill ?

A

BackgroundLayers always fill the entire canvas no matter where they’re displayed

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

How to set the constraints of a draggable layer ?

A

Ex. 1:

layerA.draggable.constraints = { x: 0, y: 0, width: 200, height: 200 }

Ex. 2 (relative to another element):

layerA.draggable.constraints = layerB.frame

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

How to declare that a layer cannot be dragged over the constraints defined previously?

A

layerA.draggable.overdrag = false

Note that the layer can still get over the constraints with momentum.

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

How to declare that a layer cannot go over his constraints even with momentum ?

A

layerA.draggable.bounce = false

37
Q

How to deactivate the default drag momentum ?

A

layerA.draggable.momentum = false

38
Q

How to configure the momentum options of a draggable layer ?

A

With draggable.momentumOptions (a configuration object).

Ex:

layerA.draggable.momentumOptions = {friction: 2, tolerance: 1}

39
Q

How to configure the bounce options of a draggable layer ?

A

With draggable.bounceOptions (a configuration object).

Ex:

layerA.draggable.bounceOptions = {friction: 40, tension: 200, velocity: 1}

40
Q

How to print the velocity of a layer while we are dragging it ? (doesn’t take into account the momentum after layer has been dropped)

A

layerA.on Events.DragMove, ->

print layerA.draggable.velocity

41
Q

How to print the velocity of a draggable layer while it’s moving ? (taking into account velocity when it’s beeing dragged but also after with momentum)

A

layerA.on Events.Move, ->

print layerA.draggable.velocity

42
Q

Which event relates to the moment when the drag action of a layer is stopped (user stops touching the layer) and the layer is going to move thanks to momentum and bounce animations?

A

Events.DragAnimationDidStart

Could be used for example when we pull to refresh : when we stop dragging, the animation starts.

43
Q

Which event relates to the moment when a dragged layer has stopped to move with momentum and bounce animations?

A

Events.DragAnimationDidEnd

Could be used for example when we pull to refresh : when the loader animation stops, the elements get their initial position.

44
Q

When we create a collection of states for a layer, we kind of create an…

A

array

45
Q

When using layer.stateCycle() can we loop inside a specific range, ignoring some states ?

A

Yes.

Ex:

layer.stateCycle( [“state1”, “state5”, “state44”] )

46
Q

What does appending an asterisk (*) to a layer group or artboard in Sketch result into when importing in Framer ?

A

It will flatten its subLayers.

Large design files can contain a lot of nested layers. If you’re leaving these static, you could flatten them before importing. This improves the loading times of your prototypes, especially when shared online. Flattened layers can’t be selected in Framer, they’re merged with their superLayer. Appending an asterisk (*) to a layer group or artboard will flatten its subLayers.

47
Q

By defalut which format of image is created when importing in Framer ?

A

PNG

48
Q

Since 22th December of 2015, what are the two other formats of image we can generate from Sketch ?

A

JPG & PDF

49
Q

What is the advantage of having PDF assets in Framer ?

A

With PDF support, you’re able to use vector graphics that can be infinitely scaled, by adjusting the width and height properties

50
Q

How to specify in Sketch which image format should be generated ?

A

Simply add the file format to the layer name, and Framer will take care of the rest. The extension is automatically removed after importing.

51
Q

Since 22th December of 2015, artboards are imported differently in Framer. Could you explain?

A

Previously, Framer stacked all artboards on top of eachother, and all but the first one was hidden. Now, the x and y positions of your artboards are respected, and they’re all visible by default. The most left artboard on your canvas in Sketch is set to 0,0. All others are positioned relative to this.

52
Q

Since 22th December of 2015, there’s a huge improvement about scale when importing in Framer. Could you explain ?

A

If you’re used to designing at @1x resolution — you don’t have to scale your designs before importing. Within the import sheet, you can specify at which scale to import. Design for high-density displays without having to work in native resolutions. Framer makes sure your assets are always crisp.

53
Q

Since 22th December of 2015, in Framer, every color is now…

A

an animatable property

54
Q

You can define colors in Framer with […] values. What are these 4 kind of values ?

A
  • CSS names
  • HEX
  • RGB & RGBA
  • HSL & HSLA
55
Q

Can we animate #28AFFA to rgb(210,80,10)?

A

Yes. Framer will take care of the conversion between these two types of values.

56
Q

From color A to color B, Framer will create a smooth transition with other intermediate colors. This color transition depends on…

A

… the colorModel

57
Q

There are 3 colorModel to choose from in Framer. Which are they ?

A

RGB, HSL and HUSL

58
Q

Which color model is used by default in Framer ?

A

By default, Framer uses HUSL because it gives you smoother transitions, but you can easily change it with the following property:

59
Q

Thanks to brand new Color Class, colors can now easily be stored in a…

A

…variable

60
Q

What does « A » mean in HSBA, RGBA ?

A

Alpha (value between 0 and 1)

61
Q

You can also create new Color objects and pass in…

A

…strings, or objects:

62
Q

Which color method adds white and return a lightened color?

A

color.lighten(amount)

amount = a number, from 0 to 100. Set to 10 by default.

63
Q

Which color method adds black and return a darkened color?

A

color.darken(amount)

amount = a number, from 0 to 100. Set to 10 by default.

64
Q

Which color method increases the saturation of a color?

A

color.saturate(amount)

amount = a number, from 0 to 100. Set to 10 by default.

65
Q

Which color method decreases the saturation of a color?

A

color.desaturate(amount)

amount = a number, from 0 to 100. Set to 10 by default.

66
Q

Which color method returns a fully desaturated color ?

A

color.grayscale()

67
Q

Which color method blends two colors together ?

A

Color.mix(colorA, colorB, fraction, limit, model)

Blend two colors together, optionally based on user input. The fraction defines the distribution between the two colors, and is set to 0.5 by default.

The limit defines if the color can transition beyond its range. This is applicable when transitioning between colors, using Utils.modulate.

68
Q

Which color method returns a Color instance with a random color value set ?

A

Color.random()

69
Q

Which color method checks if the value is a valid color object or color string and returns true or false ?

A

Color.isColor(value)

value = an object or string, representing a color

70
Q

Which color method checks if the value is a valid color object and returns true or false ?

A

Color.isColorObject(value)

value = an object, representing a color

71
Q

Which color method checks if the value is a color string and returns true or false ?

A

Color.isColorString(value)

value = a string, representing a color

72
Q

Because it needs to redraw constantly, animating color can be…

A

intensive for the GPU. Combined with other transitions like rotation, animating shadows or perspective, you might experience some lag.

73
Q

If multiple elements have the same specific state names (like on/off/etc.), we can create a function to switch them all to the specific state we want. Let’s call this function switchState.

Create it for layerA / layerB / layerC

A
74
Q

What is missing in the loop below?

A

We’re missing the “i” to iterate with:

for layer, i in layers

If the loop works with the “i”, this “i” should be present in the “for” declaration.

When we add the “i” it’s because we’re going to use the index to iterate/work with.

75
Q

Animation/configuration objects manage animations that target a […] and […]

A

Animation/configuration objects manage animations that target a layer and properties

76
Q

An animation/configuration object will tween between a start and end value, with a […]

A

An animation/configuration object will tween between a start and end value, with a curve.

77
Q

Give some parameters that animation/configuration objects can work with.

A
78
Q

Which format can be used to import vector assets from Sketch and how to specify it in Sketch?

A

PDF format.

Just append the layer group’s name with the .pdf extension

79
Q

PDF vector assets are good to play with in Framer because […]. But we cannot […].

What other format enables more fiddling?

A

PDF vector assets are good to play with in Framer because we can resize them infinitely without quality loss. But we cannot tweak other properties like fill-color, stroke, etc.

For this we would need to resort to SVG

(Ex: http://share.framerjs.com/m0iqu4eyir66/)

80
Q

What is the specificity of fat arrows functions (=>)?

A

Fat Arrow functions (=>) gain the scope of the environment they’re defined in

81
Q
  • What does layer.properties output?
  • What does layer.style output?
  • What does layer.children output?
A
  • layer.properties outputs <object>
  • layer.style outputs <object>
  • layer.children outputs <array>

Taken from Koen Bok’s Github:

  • @_properties = {}
  • @_style = {}
  • @_children = []
82
Q

When starting a prototype, if I add a state to a layer, how many states does it have now?

A

Two! Indeed, you can now switch between this one and the “default” state.

83
Q

How to make a new layer by duplicating an existing one?

A

layer.copy()

This will copy a layer and all its children. The layers will have all the same properties as their copied counterparts (same position and looks). The event listeners will not be copied.

84
Q

When importing from Sketch to Framer, sub-Layer-groups will be stored as children in an […].

If necessary, we can print them this way: print layerA.[…]

As for indexing, if we look at the sketch layer pane, where would be the index 0? At the top or bottom?

A
  • When importing from Sketch to Framer, sub-Layer-groups will be stored as children in an array.
  • If necessary, we can print them this way: print layerA.children
  • Index 0 would be at the bottom
85
Q

How to trigger the an animation created with the animation constructor (see attached picture)?

A

animationName.start()

86
Q

Which method cycles through all the layer states of a given element?

What was the former (and now deprecated) method?

A

layer.stateCycle(states, options)

The former method was layer.states.next()

Cycle through all the layer states. Once we reach the end of the cycle we start at the beginning again. You can provide an array of state names for the ordering, if you don’t it will order based on when a state was added.

You can also add an animation options parameter to change the animation for a cycle.

Arguments:

  • *states** — An array of state names. (Optional)
  • *options** — An object with all the animation options like curve, time and more. (Optional)
87
Q

What is the new function to align elements?

A
88
Q

What is the shortcut to exit the fold when inside it ?

A

cmd + escape

Note that, when outside it and when the cursor is just in front of it, it will unfold the fold.

89
Q

How to add a curve to a state method (in case the layer wasn’t assigned an animatioOptions object)

A