From f0c8ed7e8c7144b0ea30e29234b8157fcd724b95 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 11:04:50 +0100 Subject: [PATCH 01/13] Improve arrow spacing --- coffeelint.json | 2 +- framer/Animator.coffee | 2 +- framer/Canvas.coffee | 2 +- framer/Layer.coffee | 2 +- framer/Simulation.coffee | 2 +- framer/Utils.coffee | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index 88151121b..d07cd6576 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -1,6 +1,6 @@ { "arrow_spacing": { - "level": "ignore" + "level": "warn" }, "braces_spacing": { "level": "ignore", diff --git a/framer/Animator.coffee b/framer/Animator.coffee index 3226edf5b..31e28a556 100644 --- a/framer/Animator.coffee +++ b/framer/Animator.coffee @@ -22,7 +22,7 @@ class exports.Animator finished: -> throw Error "Not implemented" - values: (delta=1/60, limit=100)-> + values: (delta=1/60, limit=100) -> values = [] for i in [0..limit] values.push(@next(delta)) diff --git a/framer/Canvas.coffee b/framer/Canvas.coffee index ef22a8fe1..265e23539 100644 --- a/framer/Canvas.coffee +++ b/framer/Canvas.coffee @@ -20,7 +20,7 @@ class Canvas extends BaseClass get: -> Framer.Device.background.image set: (value) -> Framer.Device.background.image = value - constructor: (options={})-> + constructor: (options={}) -> super options Events.wrap(window).addEventListener("resize", @_handleResize) diff --git a/framer/Layer.coffee b/framer/Layer.coffee index 6fb3e339d..81a0cdae0 100644 --- a/framer/Layer.coffee +++ b/framer/Layer.coffee @@ -940,7 +940,7 @@ class exports.Layer extends BaseClass return @animate(stateName, options) if options.animate is true return @animate(stateName, _.defaults({}, options, {instant:true})) - animations: (includePending=false)-> + animations: (includePending=false) -> # Current running animations on this layer _.filter @_context.animations, (animation) => return false unless (animation.layer is @) diff --git a/framer/Simulation.coffee b/framer/Simulation.coffee index d433e7993..10e13393d 100644 --- a/framer/Simulation.coffee +++ b/framer/Simulation.coffee @@ -69,7 +69,7 @@ class exports.Simulation extends BaseClass return true - stop: (emit=true)-> + stop: (emit=true) -> return unless @_running @_running = false diff --git a/framer/Utils.coffee b/framer/Utils.coffee index 0960f6abb..7f822a8e5 100644 --- a/framer/Utils.coffee +++ b/framer/Utils.coffee @@ -736,7 +736,7 @@ Utils.size = (input) -> return result -Utils.sizeZero = (n=0)-> +Utils.sizeZero = (n=0) -> return {width:n, height:n} Utils.sizeMin = -> From ae6278f9918e48e73a254bb551bd70fd184aa060 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 11:06:38 +0100 Subject: [PATCH 02/13] Proper braces spacing --- coffeelint.json | 2 +- framer/Animators/BezierCurveAnimator.coffee | 6 +++--- framer/Color.coffee | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index d07cd6576..49d5f6093 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -3,7 +3,7 @@ "level": "warn" }, "braces_spacing": { - "level": "ignore", + "level": "warn", "spaces": 0, "empty_object_spaces": 0 }, diff --git a/framer/Animators/BezierCurveAnimator.coffee b/framer/Animators/BezierCurveAnimator.coffee index 20c8223d8..ba6e401a7 100644 --- a/framer/Animators/BezierCurveAnimator.coffee +++ b/framer/Animators/BezierCurveAnimator.coffee @@ -13,15 +13,15 @@ class exports.BezierCurveAnimator extends Animator # Input is a one of the named bezier curves if _.isString(options) and BezierCurveDefaults.hasOwnProperty options.toLowerCase() - options = { values: BezierCurveDefaults[options.toLowerCase()] } + options = {values: BezierCurveDefaults[options.toLowerCase()]} # Input values is one of the named bezier curves if options.values and _.isString(options.values) and BezierCurveDefaults.hasOwnProperty options.values.toLowerCase() - options = { values: BezierCurveDefaults[options.values.toLowerCase()], time: options.time } + options = {values: BezierCurveDefaults[options.values.toLowerCase()], time: options.time} # Input is a single array of 4 values if _.isArray(options) and options.length is 4 - options = { values: options } + options = {values: options} @options = _.defaults options, values: BezierCurveDefaults["ease-in-out"] diff --git a/framer/Color.coffee b/framer/Color.coffee index 31f5a1d82..5d7a42e01 100644 --- a/framer/Color.coffee +++ b/framer/Color.coffee @@ -87,7 +87,7 @@ class exports.Color extends BaseClass if @_husl == undefined c = libhusl._conv husl = c.lch.husl c.luv.lch c.xyz.luv c.rgb.xyz([@r/255, @g/255, @b/255]) - @_husl = { h: husl[0], s: husl[1], l: husl[2] } + @_husl = {h: husl[0], s: husl[1], l: husl[2]} return _.clone(@_husl) @@ -339,8 +339,8 @@ rgbaFromHusl = (husl) -> # Functions inputData = (color, g, b, alpha) -> - rgb = { r:0, g:0, b:0 } - hsl = { h:0, s:0, l:0 } + rgb = {r:0, g:0, b:0} + hsl = {h:0, s:0, l:0} a = 1 ok = false type = ColorType.RGB @@ -452,7 +452,7 @@ rgbToHsl = (r, g, b) -> when g then h = (b - r) / d + 2 when b then h = (r - g) / d + 4 h /= 6 - return { h:h * 360, s:s, l:l } + return {h:h * 360, s:s, l:l} # HSL to RGB hslToRgb = (h, s, l) -> @@ -482,7 +482,7 @@ hslToRgb = (h, s, l) -> g = hue2rgb(p, q, h) b = hue2rgb(p, q, h - (1 / 3)) - return { r:r*255, g:g*255, b:b*255 } + return {r:r*255, g:g*255, b:b*255} # Utility Functions From b92b382b31f253ebd031e9a862fb2d661e3caaa8 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 11:33:42 +0100 Subject: [PATCH 03/13] Implement Colon assignment spacing linting --- coffeelint.json | 4 +- framer/Align.coffee | 2 +- framer/Color.coffee | 322 +++++++++--------- framer/Components/DeviceComponent.coffee | 76 ++--- framer/Components/NavComponent.coffee | 8 +- .../Components/NavComponentTransitions.coffee | 4 +- framer/Components/PageComponent.coffee | 8 +- framer/Components/ScrollComponent.coffee | 28 +- framer/Components/SliderComponent.coffee | 2 +- framer/Context.coffee | 2 +- framer/EventBuffer.coffee | 4 +- framer/Extras/ErrorDisplay.coffee | 10 +- framer/Extras/Hints.coffee | 2 +- framer/Extras/TouchEmulator.coffee | 6 +- framer/Framer.coffee | 4 +- framer/GestureInputRecognizer.coffee | 14 +- framer/Importer.coffee | 2 +- framer/Layer.coffee | 100 +++--- framer/LayerDraggable.coffee | 28 +- framer/LayerStates.coffee | 2 +- framer/Matrix.coffee | 2 +- framer/Print.coffee | 2 +- framer/Screen.coffee | 30 +- framer/Simulator.coffee | 2 +- framer/Utils.coffee | 44 +-- gulpfile.coffee | 2 +- scripts/site.coffee | 4 +- test/tests.coffee | 2 +- test/tests/AlignTest.coffee | 12 +- test/tests/BaseClassTest.coffee | 4 +- test/tests/ContextTest.coffee | 38 +-- test/tests/DeviceComponentTest.coffee | 12 +- test/tests/LayerAnimationTest.coffee | 26 +- test/tests/LayerStatesBackwardsTest.coffee | 8 +- test/tests/LayerStatesTest.coffee | 22 +- test/tests/ScrollComponentTest.coffee | 26 +- test/tests/UtilsTest.coffee | 94 ++--- test/tests/VideoLayerTest.coffee | 2 +- 38 files changed, 480 insertions(+), 480 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index 49d5f6093..43589e09b 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -14,10 +14,10 @@ "level": "error" }, "colon_assignment_spacing": { - "level": "ignore", + "level": "warn", "spacing": { "left": 0, - "right": 0 + "right": 1 } }, "cyclomatic_complexity": { diff --git a/framer/Align.coffee b/framer/Align.coffee index 6a28ebe92..5d882b056 100644 --- a/framer/Align.coffee +++ b/framer/Align.coffee @@ -13,7 +13,7 @@ center = (layer, property, offset=0) -> return x if property is "x" return y if property is "y" - return {x:x, y:y} if property is "point" + return {x: x, y: y} if property is "point" return 0 left = (layer, property, offset=0) -> diff --git a/framer/Color.coffee b/framer/Color.coffee index 5d7a42e01..2da6531ad 100644 --- a/framer/Color.coffee +++ b/framer/Color.coffee @@ -339,8 +339,8 @@ rgbaFromHusl = (husl) -> # Functions inputData = (color, g, b, alpha) -> - rgb = {r:0, g:0, b:0} - hsl = {h:0, s:0, l:0} + rgb = {r: 0, g: 0, b: 0} + hsl = {h: 0, s: 0, l: 0} a = 1 ok = false type = ColorType.RGB @@ -363,10 +363,10 @@ inputData = (color, g, b, alpha) -> if !color color = - r:0 - g:0 - b:0 - a:0 + r: 0 + g: 0 + b: 0 + a: 0 if color.hasOwnProperty("type") type = color.type @@ -452,7 +452,7 @@ rgbToHsl = (r, g, b) -> when g then h = (b - r) / d + 2 when b then h = (r - g) / d + 4 h /= 6 - return {h:h * 360, s:s, l:l} + return {h: h * 360, s: s, l: l} # HSL to RGB hslToRgb = (h, s, l) -> @@ -482,7 +482,7 @@ hslToRgb = (h, s, l) -> g = hue2rgb(p, q, h) b = hue2rgb(p, q, h - (1 / 3)) - return {r:r*255, g:g*255, b:b*255} + return {r: r*255, g: g*255, b: b*255} # Utility Functions @@ -565,10 +565,10 @@ stringToObject = (color) -> else if color == "transparent" return { - r:0 - g:0 - b:0 - a:0 + r: 0 + g: 0 + b: 0 + a: 0 type: ColorType.NAME } @@ -624,152 +624,152 @@ stringToObject = (color) -> # CSS Colors cssNames = - aliceblue:"f0f8ff" - antiquewhite:"faebd7" - aqua:"0ff" - aquamarine:"7fffd4" - azure:"f0ffff" - beige:"f5f5dc" - bisque:"ffe4c4" - black:"000" - blanchedalmond:"ffebcd" - blue:"00f" - blueviolet:"8a2be2" - brown:"a52a2a" - burlywood:"deb887" - burntsienna:"ea7e5d" - cadetblue:"5f9ea0" - chartreuse:"7fff00" - chocolate:"d2691e" - coral:"ff7f50" - cornflowerblue:"6495ed" - cornsilk:"fff8dc" - crimson:"dc143c" - cyan:"0ff" - darkblue:"00008b" - darkcyan:"008b8b" - darkgoldenrod:"b8860b" - darkgray:"a9a9a9" - darkgreen:"006400" - darkgrey:"a9a9a9" - darkkhaki:"bdb76b" - darkmagenta:"8b008b" - darkolivegreen:"556b2f" - darkorange:"ff8c00" - darkorchid:"9932cc" - darkred:"8b0000" - darksalmon:"e9967a" - darkseagreen:"8fbc8f" - darkslateblue:"483d8b" - darkslategray:"2f4f4f" - darkslategrey:"2f4f4f" - darkturquoise:"00ced1" - darkviolet:"9400d3" - deeppink:"ff1493" - deepskyblue:"00bfff" - dimgray:"696969" - dimgrey:"696969" - dodgerblue:"1e90ff" - firebrick:"b22222" - floralwhite:"fffaf0" - forestgreen:"228b22" - fuchsia:"f0f" - gainsboro:"dcdcdc" - ghostwhite:"f8f8ff" - gold:"ffd700" - goldenrod:"daa520" - gray:"808080" - green:"008000" - greenyellow:"adff2f" - grey:"808080" - honeydew:"f0fff0" - hotpink:"ff69b4" - indianred:"cd5c5c" - indigo:"4b0082" - ivory:"fffff0" - khaki:"f0e68c" - lavender:"e6e6fa" - lavenderblush:"fff0f5" - lawngreen:"7cfc00" - lemonchiffon:"fffacd" - lightblue:"add8e6" - lightcoral:"f08080" - lightcyan:"e0ffff" - lightgoldenrodyellow:"fafad2" - lightgray:"d3d3d3" - lightgreen:"90ee90" - lightgrey:"d3d3d3" - lightpink:"ffb6c1" - lightsalmon:"ffa07a" - lightseagreen:"20b2aa" - lightskyblue:"87cefa" - lightslategray:"789" - lightslategrey:"789" - lightsteelblue:"b0c4de" - lightyellow:"ffffe0" - lime:"0f0" - limegreen:"32cd32" - linen:"faf0e6" - magenta:"f0f" - maroon:"800000" - mediumaquamarine:"66cdaa" - mediumblue:"0000cd" - mediumorchid:"ba55d3" - mediumpurple:"9370db" - mediumseagreen:"3cb371" - mediumslateblue:"7b68ee" - mediumspringgreen:"00fa9a" - mediumturquoise:"48d1cc" - mediumvioletred:"c71585" - midnightblue:"191970" - mintcream:"f5fffa" - mistyrose:"ffe4e1" - moccasin:"ffe4b5" - navajowhite:"ffdead" - navy:"000080" - oldlace:"fdf5e6" - olive:"808000" - olivedrab:"6b8e23" - orange:"ffa500" - orangered:"ff4500" - orchid:"da70d6" - palegoldenrod:"eee8aa" - palegreen:"98fb98" - paleturquoise:"afeeee" - palevioletred:"db7093" - papayawhip:"ffefd5" - peachpuff:"ffdab9" - peru:"cd853f" - pink:"ffc0cb" - plum:"dda0dd" - powderblue:"b0e0e6" - purple:"800080" - rebeccapurple:"663399" - red:"f00" - rosybrown:"bc8f8f" - royalblue:"4169e1" - saddlebrown:"8b4513" - salmon:"fa8072" - sandybrown:"f4a460" - seagreen:"2e8b57" - seashell:"fff5ee" - sienna:"a0522d" - silver:"c0c0c0" - skyblue:"87ceeb" - slateblue:"6a5acd" - slategray:"708090" - slategrey:"708090" - snow:"fffafa" - springgreen:"00ff7f" - steelblue:"4682b4" - tan:"d2b48c" - teal:"008080" - thistle:"d8bfd8" - tomato:"ff6347" - turquoise:"40e0d0" - violet:"ee82ee" - wheat:"f5deb3" - white:"fff" - whitesmoke:"f5f5f5" - yellow:"ff0" - yellowgreen:"9acd32" + aliceblue: "f0f8ff" + antiquewhite: "faebd7" + aqua: "0ff" + aquamarine: "7fffd4" + azure: "f0ffff" + beige: "f5f5dc" + bisque: "ffe4c4" + black: "000" + blanchedalmond: "ffebcd" + blue: "00f" + blueviolet: "8a2be2" + brown: "a52a2a" + burlywood: "deb887" + burntsienna: "ea7e5d" + cadetblue: "5f9ea0" + chartreuse: "7fff00" + chocolate: "d2691e" + coral: "ff7f50" + cornflowerblue: "6495ed" + cornsilk: "fff8dc" + crimson: "dc143c" + cyan: "0ff" + darkblue: "00008b" + darkcyan: "008b8b" + darkgoldenrod: "b8860b" + darkgray: "a9a9a9" + darkgreen: "006400" + darkgrey: "a9a9a9" + darkkhaki: "bdb76b" + darkmagenta: "8b008b" + darkolivegreen: "556b2f" + darkorange: "ff8c00" + darkorchid: "9932cc" + darkred: "8b0000" + darksalmon: "e9967a" + darkseagreen: "8fbc8f" + darkslateblue: "483d8b" + darkslategray: "2f4f4f" + darkslategrey: "2f4f4f" + darkturquoise: "00ced1" + darkviolet: "9400d3" + deeppink: "ff1493" + deepskyblue: "00bfff" + dimgray: "696969" + dimgrey: "696969" + dodgerblue: "1e90ff" + firebrick: "b22222" + floralwhite: "fffaf0" + forestgreen: "228b22" + fuchsia: "f0f" + gainsboro: "dcdcdc" + ghostwhite: "f8f8ff" + gold: "ffd700" + goldenrod: "daa520" + gray: "808080" + green: "008000" + greenyellow: "adff2f" + grey: "808080" + honeydew: "f0fff0" + hotpink: "ff69b4" + indianred: "cd5c5c" + indigo: "4b0082" + ivory: "fffff0" + khaki: "f0e68c" + lavender: "e6e6fa" + lavenderblush: "fff0f5" + lawngreen: "7cfc00" + lemonchiffon: "fffacd" + lightblue: "add8e6" + lightcoral: "f08080" + lightcyan: "e0ffff" + lightgoldenrodyellow: "fafad2" + lightgray: "d3d3d3" + lightgreen: "90ee90" + lightgrey: "d3d3d3" + lightpink: "ffb6c1" + lightsalmon: "ffa07a" + lightseagreen: "20b2aa" + lightskyblue: "87cefa" + lightslategray: "789" + lightslategrey: "789" + lightsteelblue: "b0c4de" + lightyellow: "ffffe0" + lime: "0f0" + limegreen: "32cd32" + linen: "faf0e6" + magenta: "f0f" + maroon: "800000" + mediumaquamarine: "66cdaa" + mediumblue: "0000cd" + mediumorchid: "ba55d3" + mediumpurple: "9370db" + mediumseagreen: "3cb371" + mediumslateblue: "7b68ee" + mediumspringgreen: "00fa9a" + mediumturquoise: "48d1cc" + mediumvioletred: "c71585" + midnightblue: "191970" + mintcream: "f5fffa" + mistyrose: "ffe4e1" + moccasin: "ffe4b5" + navajowhite: "ffdead" + navy: "000080" + oldlace: "fdf5e6" + olive: "808000" + olivedrab: "6b8e23" + orange: "ffa500" + orangered: "ff4500" + orchid: "da70d6" + palegoldenrod: "eee8aa" + palegreen: "98fb98" + paleturquoise: "afeeee" + palevioletred: "db7093" + papayawhip: "ffefd5" + peachpuff: "ffdab9" + peru: "cd853f" + pink: "ffc0cb" + plum: "dda0dd" + powderblue: "b0e0e6" + purple: "800080" + rebeccapurple: "663399" + red: "f00" + rosybrown: "bc8f8f" + royalblue: "4169e1" + saddlebrown: "8b4513" + salmon: "fa8072" + sandybrown: "f4a460" + seagreen: "2e8b57" + seashell: "fff5ee" + sienna: "a0522d" + silver: "c0c0c0" + skyblue: "87ceeb" + slateblue: "6a5acd" + slategray: "708090" + slategrey: "708090" + snow: "fffafa" + springgreen: "00ff7f" + steelblue: "4682b4" + tan: "d2b48c" + teal: "008080" + thistle: "d8bfd8" + tomato: "ff6347" + turquoise: "40e0d0" + violet: "ee82ee" + wheat: "f5deb3" + white: "fff" + whitesmoke: "f5f5f5" + yellow: "ff0" + yellowgreen: "9acd32" diff --git a/framer/Components/DeviceComponent.coffee b/framer/Components/DeviceComponent.coffee index 030858441..dd8b0967d 100644 --- a/framer/Components/DeviceComponent.coffee +++ b/framer/Components/DeviceComponent.coffee @@ -77,11 +77,11 @@ class exports.DeviceComponent extends BaseClass @background.classList.add("DeviceBackground") @hands = new Layer - @handsImageLayer = new Layer parent:@hands - @phone = new Layer parent:@hands - @screen = new Layer parent:@phone - @viewport = new Layer parent:@screen - @content = new Layer parent:@viewport + @handsImageLayer = new Layer parent: @hands + @phone = new Layer parent: @hands + @screen = new Layer parent: @phone + @viewport = new Layer parent: @screen + @content = new Layer parent: @viewport @hands.backgroundColor = "transparent" @hands._alwaysUseImageCache = true @@ -109,7 +109,7 @@ class exports.DeviceComponent extends BaseClass for layer in [@background, @phone, @viewport, @content, @screen] layer.on "touchmove", (event) -> event.preventDefault() - @_context = new Framer.Context(parent:@content, name:"DeviceScreen") + @_context = new Framer.Context(parent: @content, name: "DeviceScreen") @_context.perspective = 1200 @_context.device = @ @@ -382,7 +382,7 @@ class exports.DeviceComponent extends BaseClass if animate @hands.animate _.extend @animationOptions, - properties: {scale:phoneScale} + properties: {scale: phoneScale} else @hands.scale = phoneScale @hands.center() @@ -655,10 +655,10 @@ iPhone7BaseDevice = minStudioVersion: 71 hands: "iphone-hands-2": - width: 2400 + width: 2400 height: 3740 "iphone-hands-1": - width: 2400 + width: 2400 height: 3740 iPhone7PlusBaseDevice = @@ -671,10 +671,10 @@ iPhone7PlusBaseDevice = minStudioVersion: 71 hands: "iphone-hands-2": - width: 3987 + width: 3987 height: 6212 "iphone-hands-1": - width: 3987 + width: 3987 height: 6212 iPhone6BaseDevice = @@ -687,10 +687,10 @@ iPhone6BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 2400 + width: 2400 height: 3740 "iphone-hands-1": - width: 2400 + width: 2400 height: 3740 iPhone6PlusBaseDevice = @@ -703,10 +703,10 @@ iPhone6PlusBaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 3987 + width: 3987 height: 6212 "iphone-hands-1": - width: 3987 + width: 3987 height: 6212 iPhone5BaseDevice = @@ -719,11 +719,11 @@ iPhone5BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 2098 + width: 2098 height: 3269 offset: 19 "iphone-hands-1": - width: 2098 + width: 2098 height: 3269 offset: 19 @@ -737,11 +737,11 @@ iPhone5CBaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 2098 + width: 2098 height: 3269 offset: 28 "iphone-hands-1": - width: 2098 + width: 2098 height: 3269 offset: 28 @@ -755,11 +755,11 @@ Nexus4BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 2362 + width: 2362 height: 3681 offset: -52 "iphone-hands-1": - width: 2362 + width: 2362 height: 3681 offset: -52 @@ -773,11 +773,11 @@ Nexus5BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 3292 + width: 3292 height: 5130 offset: 8 "iphone-hands-1": - width: 3292 + width: 3292 height: 5130 offset: 8 @@ -791,11 +791,11 @@ Nexus6BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 4304 + width: 4304 height: 6707 offset: 8 "iphone-hands-1": - width: 4304 + width: 4304 height: 6707 offset: 8 @@ -809,11 +809,11 @@ PixelBaseDevice = minStudioVersion: googlePixelReleaseVersion hands: "iphone-hands-2": - width: 3344 + width: 3344 height: 5211 offset: 23 "iphone-hands-1": - width: 3344 + width: 3344 height: 5211 offset: 23 @@ -836,11 +836,11 @@ HTCa9BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 3436 + width: 3436 height: 5354 offset: 36 "iphone-hands-1": - width: 3436 + width: 3436 height: 5354 offset: 36 @@ -854,11 +854,11 @@ HTCm8BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 3436 + width: 3436 height: 5354 offset: 12 "iphone-hands-1": - width: 3436 + width: 3436 height: 5354 offset: 12 @@ -872,11 +872,11 @@ MSFTLumia950BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 4494 + width: 4494 height: 7003 offset: -84 "iphone-hands-1": - width: 4494 + width: 4494 height: 7003 offset: -84 @@ -890,11 +890,11 @@ SamsungGalaxyNote5BaseDevice = minStudioVersion: newDeviceMinVersion hands: "iphone-hands-2": - width: 4279 + width: 4279 height: 6668 offset: -24 "iphone-hands-1": - width: 4279 + width: 4279 height: 6668 offset: -84 @@ -1164,7 +1164,7 @@ Devices = # iPhone 7 "apple-iphone-7-gold": _.clone(iPhone7BaseDevice) "apple-iphone-7-rose-gold": _.clone(iPhone7BaseDevice) - "apple-iphone-7-silver" : _.clone(iPhone7BaseDevice) + "apple-iphone-7-silver": _.clone(iPhone7BaseDevice) "apple-iphone-7-black": _.clone(iPhone7BaseDevice) "apple-iphone-7-jet-black": _.clone(iPhone7BaseDevice) @@ -1178,7 +1178,7 @@ Devices = # iPhone 6s "apple-iphone-6s-gold": _.clone(iPhone6BaseDevice) "apple-iphone-6s-rose-gold": _.clone(iPhone6BaseDevice) - "apple-iphone-6s-silver" : _.clone(iPhone6BaseDevice) + "apple-iphone-6s-silver": _.clone(iPhone6BaseDevice) "apple-iphone-6s-space-gray": _.clone(iPhone6BaseDevice) # iPhone 6s Plus @@ -1369,7 +1369,7 @@ Devices = # iPhone 5S "iphone-5s-spacegray": _.clone(old_iPhone5BaseDevice) - "iphone-5s-spacegray-hand":_.clone(old_iPhone5BaseDeviceHand) + "iphone-5s-spacegray-hand": _.clone(old_iPhone5BaseDeviceHand) "iphone-5s-silver": _.clone(old_iPhone5BaseDevice) "iphone-5s-silver-hand": _.clone(old_iPhone5BaseDeviceHand) "iphone-5s-gold": _.clone(old_iPhone5BaseDevice) diff --git a/framer/Components/NavComponent.coffee b/framer/Components/NavComponent.coffee index adb0f92ce..c456d61d5 100644 --- a/framer/Components/NavComponent.coffee +++ b/framer/Components/NavComponent.coffee @@ -98,7 +98,7 @@ class exports.NavComponent extends Layer transition = new TransitionType(@, @_wrappedLayer(@current), wrappedLayer) @_runTransition(transition, "forward", animate, @current, layer) - @_stack.push({layer:layer, transition:transition}) + @_stack.push({layer: layer, transition: transition}) dialog: (layer, animate) -> @push(layer, Transitions.dialog, animate, false) @@ -125,12 +125,12 @@ class exports.NavComponent extends Layer get: -> return @_stack[@_stack.length - 2]?.layer _runTransition: (transition, direction, animate, from, to) => - + @_isTransitioning = true @emit(Events.TransitionStart, from, to, direction) @emit(direction, from, to) - + transition[direction] animate, => @_isTransitioning = false @emit(Events.TransitionEnd, from, to, direction) - @emit(direction, from, to) \ No newline at end of file + @emit(direction, from, to) diff --git a/framer/Components/NavComponentTransitions.coffee b/framer/Components/NavComponentTransitions.coffee index 4f78addc3..40cf22725 100644 --- a/framer/Components/NavComponentTransitions.coffee +++ b/framer/Components/NavComponentTransitions.coffee @@ -25,7 +25,7 @@ class NavComponentTransition curve: "spring(300, 35, 0)" forward: (animate=true, callback) -> - options = _.extend(@animationOptions, {animate:animate}) + options = _.extend(@animationOptions, {animate: animate}) @statesA?.switch("a", options) @statesB?.switchInstant("b") @statesB?.switch("a", options) @@ -34,7 +34,7 @@ class NavComponentTransition callback?() back: (animate=true, callback) -> - options = _.extend(@animationOptions, {animate:animate}) + options = _.extend(@animationOptions, {animate: animate}) @layerA?.visible = true @statesA?.switch("b", options) @statesB?.switch("b", options) diff --git a/framer/Components/PageComponent.coffee b/framer/Components/PageComponent.coffee index 32ce766d0..6c1112453 100644 --- a/framer/Components/PageComponent.coffee +++ b/framer/Components/PageComponent.coffee @@ -26,7 +26,7 @@ class exports.PageComponent extends ScrollComponent constructor: (options) -> super _.defaults options, animationOptions: - curve:"spring(500, 50, 0)" + curve: "spring(500, 50, 0)" @content.draggable.momentum = false @content.draggable.bounce = false @@ -48,10 +48,10 @@ class exports.PageComponent extends ScrollComponent currentPage ?= @currentPage # Figure out the point from where to look for next layers in a direction - point = {x:0, y:0} + point = {x: 0, y: 0} point = Utils.framePointForOrigin(currentPage, @originX, @originY) if currentPage if !withoutCurrentPage - point = {x:@scrollX + (@originX * @width), y:@scrollY + (@originY * @height)} + point = {x: @scrollX + (@originX * @width), y: @scrollY + (@originY * @height)} layers = @content.childrenAbove(point, @originX, @originY) if direction in ["up", "top", "north"] layers = @content.childrenBelow(point, @originX, @originY) if direction in ["down", "bottom", "south"] @@ -130,7 +130,7 @@ class exports.PageComponent extends ScrollComponent if currentPage not in [_.last(@_previousPages), undefined] @_previousPages.push(currentPage) - @emit("change:currentPage", {old:@previousPage, new:currentPage}) + @emit("change:currentPage", {old: @previousPage, new: currentPage}) _scrollEnd: => diff --git a/framer/Components/ScrollComponent.coffee b/framer/Components/ScrollComponent.coffee index 489996e32..f8f69bd2b 100644 --- a/framer/Components/ScrollComponent.coffee +++ b/framer/Components/ScrollComponent.coffee @@ -102,7 +102,7 @@ class exports.ScrollComponent extends Layer return size = x: 0 y: 0 - width: Math.max(@width, contentFrame.x + contentFrame.width) + width: Math.max(@width, contentFrame.x + contentFrame.width) height: Math.max(@height, contentFrame.y + contentFrame.height) setContentLayer: (layer) -> @@ -130,7 +130,7 @@ class exports.ScrollComponent extends Layer @updateContent() - @scrollPoint = {x:0, y:0} + @scrollPoint = {x: 0, y: 0} @content.on(Events.AnimationStart, @_onAnimationStart) @content.on(Events.AnimationStop, @_onAnimationStop) @@ -157,7 +157,7 @@ class exports.ScrollComponent extends Layer constraintsFrame = x: -constraintsFrame.width + @width - @_contentInset.right y: -constraintsFrame.height + @height - @_contentInset.bottom - width: constraintsFrame.width + constraintsFrame.width - @width + + width: constraintsFrame.width + constraintsFrame.width - @width + @_contentInset.left + @_contentInset.right height: constraintsFrame.height + constraintsFrame.height - @height + @_contentInset.top + @_contentInset.bottom @@ -184,7 +184,7 @@ class exports.ScrollComponent extends Layer @scrollHorizontal = @scrollVertical = value _calculateContentPoint: (scrollPoint) -> - scrollPoint = _.defaults(scrollPoint, {x:0, y:0}) + scrollPoint = _.defaults(scrollPoint, {x: 0, y: 0}) scrollPoint.x -= @contentInset.left scrollPoint.y -= @contentInset.top point = @_pointInConstraints(scrollPoint) @@ -197,7 +197,7 @@ class exports.ScrollComponent extends Layer set: (value) -> return unless @content @content.draggable.animateStop() - @content.x = @_calculateContentPoint({x:value, y:0}).x + @content.x = @_calculateContentPoint({x: value, y: 0}).x @define "scrollY", get: -> @@ -206,7 +206,7 @@ class exports.ScrollComponent extends Layer set: (value) -> return unless @content @content.draggable.animateStop() - @content.y = @_calculateContentPoint({x:0, y:value}).y + @content.y = @_calculateContentPoint({x: 0, y: value}).y @define "scrollPoint", importable: true @@ -264,7 +264,7 @@ class exports.ScrollComponent extends Layer return 0 unless @content return -@content.draggable.angle - scrollToPoint: (point, animate=true, animationOptions={curve:"spring(500, 50, 0)"}) -> + scrollToPoint: (point, animate=true, animationOptions={curve: "spring(500, 50, 0)"}) -> # We never let you scroll to a point that does not make sense (out of bounds). If you still # would like to do that, access the .content.y directly. @@ -280,16 +280,16 @@ class exports.ScrollComponent extends Layer else @content.point = contentPoint - scrollToTop: (animate=true, animationOptions={curve:"spring(500, 50, 0)"}) -> - @scrollToPoint({x:0, y:0}, animate, animationOptions) + scrollToTop: (animate=true, animationOptions={curve: "spring(500, 50, 0)"}) -> + @scrollToPoint({x: 0, y: 0}, animate, animationOptions) - scrollToLayer: (contentLayer, originX=0, originY=0, animate=true, animationOptions={curve:"spring(500, 50, 0)"}) -> + scrollToLayer: (contentLayer, originX=0, originY=0, animate=true, animationOptions={curve: "spring(500, 50, 0)"}) -> if contentLayer and contentLayer.parent isnt @content throw Error("Can't scroll to this layer because it's not in the ScrollComponent. Add it to the content like layer.parent = scroll.content.") if not contentLayer or @content.children.length == 0 - scrollPoint = {x:0, y:0} + scrollPoint = {x: 0, y: 0} else scrollPoint = @_scrollPointForLayer(contentLayer, originX, originY) scrollPoint.x -= @width * originX @@ -299,13 +299,13 @@ class exports.ScrollComponent extends Layer return contentLayer - scrollToClosestLayer: (originX=0, originY=0, animate=true, animationOptions={curve:"spring(500, 50, 0)"}) -> + scrollToClosestLayer: (originX=0, originY=0, animate=true, animationOptions={curve: "spring(500, 50, 0)"}) -> closestLayer = @closestContentLayer(originX, originY, animate, animationOptions) if closestLayer @scrollToLayer(closestLayer, originX, originY) return closestLayer else - @scrollToPoint({x:0, y:0}) unless closestLayer + @scrollToPoint({x: 0, y: 0}) unless closestLayer return null closestContentLayer: (originX=0, originY=0) -> @@ -428,7 +428,7 @@ class exports.ScrollComponent extends Layer return wrapComponent(new @(options), layer, options) -wrapComponent = (instance, layer, options = {correct:true}) -> +wrapComponent = (instance, layer, options = {correct: true}) -> if not (layer instanceof Layer) throw new Error("ScrollComponent.wrap expects a layer, not #{layer}. Are you sure the layer exists?") diff --git a/framer/Components/SliderComponent.coffee b/framer/Components/SliderComponent.coffee index 832a716ae..3bc5f22cc 100644 --- a/framer/Components/SliderComponent.coffee +++ b/framer/Components/SliderComponent.coffee @@ -243,7 +243,7 @@ class exports.SliderComponent extends Layer else return Utils.modulate(value, [0, @height], [@min, @max], true) - animateToValue: (value, animationOptions={curve:"spring(300, 25, 0)"}) -> + animateToValue: (value, animationOptions={curve: "spring(300, 25, 0)"}) -> if @width > @height animationOptions.properties = {x: @pointForValue(value) - (@knob.width/2)} else diff --git a/framer/Context.coffee b/framer/Context.coffee index 7abb91d05..80a211722 100644 --- a/framer/Context.coffee +++ b/framer/Context.coffee @@ -306,7 +306,7 @@ class exports.Context extends BaseClass return @parent.height if @parent? return window.innerHeight - @define "frame", get: -> {x:0, y:0, width:@width, height:@height} + @define "frame", get: -> {x: 0, y: 0, width: @width, height: @height} @define "size", get: -> _.pick(@frame, ["width", "height"]) @define "point", get: -> _.pick(@frame, ["x", "y"]) @define "canvasFrame", diff --git a/framer/EventBuffer.coffee b/framer/EventBuffer.coffee index 6b2cf7821..973948a00 100644 --- a/framer/EventBuffer.coffee +++ b/framer/EventBuffer.coffee @@ -32,7 +32,7 @@ class exports.EventBuffer extends BaseClass @define "offset", get: -> - return {x:0, y:0} if events.length < 2 + return {x: 0, y: 0} if events.length < 2 current = events[events.length - 1] first = events[0] offset = @@ -56,7 +56,7 @@ class exports.EventBuffer extends BaseClass get: -> events = @events - return {x:0, y:0} if events.length < 2 + return {x: 0, y: 0} if events.length < 2 current = events[events.length - 1] first = events[0] diff --git a/framer/Extras/ErrorDisplay.coffee b/framer/Extras/ErrorDisplay.coffee index 0ea610ffc..5b2120b86 100644 --- a/framer/Extras/ErrorDisplay.coffee +++ b/framer/Extras/ErrorDisplay.coffee @@ -23,7 +23,7 @@ class ErrorDisplay extends BaseClass constructor: -> - @_context ?= new Context name:"ErrorDisplay" + @_context ?= new Context name: "ErrorDisplay" @_context.index = 1000 @_context.run => @@ -46,7 +46,7 @@ class ErrorDisplay extends BaseClass width: Canvas.width height: Config.height backgroundColor: "rgba(255, 0, 0, 1)" - + error.text = new Layer name: "text" parent: error @@ -54,14 +54,14 @@ class ErrorDisplay extends BaseClass point: Align.center backgroundColor: null clip: true - + error.text.style = font: "#{Config.fontSize}px/1em #{Utils.deviceFont()}" lineHeight: "#{parseInt(error.text.height - 2)}px" textAlign: "center" wordWrap: "break-word" textOverflow: "ellipsis" - + error.onTap => @_errorLayer?.destroy() @_errorLayer = null @@ -101,4 +101,4 @@ exports.enable = -> exports.disable = -> return unless _errorDisplay _errorDisplay.destroy() - _errorDisplay = null \ No newline at end of file + _errorDisplay = null diff --git a/framer/Extras/Hints.coffee b/framer/Extras/Hints.coffee index e193fe8f1..ff379c81c 100644 --- a/framer/Extras/Hints.coffee +++ b/framer/Extras/Hints.coffee @@ -4,7 +4,7 @@ class Hints constructor: -> - @_context = new Framer.Context(name:"Hints") + @_context = new Framer.Context(name: "Hints") @_context.index = 10000 @_context.run => diff --git a/framer/Extras/TouchEmulator.coffee b/framer/Extras/TouchEmulator.coffee index 15fa11c4d..85ae86f2e 100644 --- a/framer/Extras/TouchEmulator.coffee +++ b/framer/Extras/TouchEmulator.coffee @@ -1,7 +1,7 @@ Utils = require "../Utils" {BaseClass} = require "../BaseClass" -createTouch = (event, identifier, offset={x:0, y:0}) -> +createTouch = (event, identifier, offset={x: 0, y: 0}) -> return touch = identifier: identifier target: event.target @@ -42,12 +42,12 @@ class TouchEmulator extends BaseClass @touchPointerImage = "url('framer/images/cursor@2x.png')" @touchPointerImageActive = "url('framer/images/cursor-active@2x.png')" @touchPointerImageSize = 64 - @touchPointerInitialOffset = {x:0, y:0} + @touchPointerInitialOffset = {x: 0, y: 0} @keyPinchCode = 18 # Alt @keyPanCode = 91 # Command - @context = new Framer.Context(name:"TouchEmulator") + @context = new Framer.Context(name: "TouchEmulator") @context._element.style.zIndex = 10000 @wrap = @context.domEventManager.wrap diff --git a/framer/Framer.coffee b/framer/Framer.coffee index 91779b6af..2ca65b718 100644 --- a/framer/Framer.coffee +++ b/framer/Framer.coffee @@ -64,7 +64,7 @@ Framer.resetDefaults = Defaults.reset # Create the default context, set it to invisble by default so # the preloader can pick it up if it needs to. -Framer.DefaultContext = new Framer.Context(name:"Default") +Framer.DefaultContext = new Framer.Context(name: "Default") Framer.DefaultContext.backgroundColor = "white" Framer.DefaultContext.visible = false Framer.CurrentContext = Framer.DefaultContext @@ -83,4 +83,4 @@ Framer.Extras.Hints.enable() if not Utils.isFramerStudio() # action in the future, so we can't know wether that will happen or not. Framer.DefaultContext.visible = true unless Framer.Preloader -Utils.domComplete(Framer.Loop.start) \ No newline at end of file +Utils.domComplete(Framer.Loop.start) diff --git a/framer/GestureInputRecognizer.coffee b/framer/GestureInputRecognizer.coffee index e763fdaea..2c3bf8d88 100644 --- a/framer/GestureInputRecognizer.coffee +++ b/framer/GestureInputRecognizer.coffee @@ -322,7 +322,7 @@ class exports.GestureInputRecognizer _getEventPoint: (event) -> return @_getTouchPoint(event, 0) if event.touches?.length - return {x:event.pageX, y:event.pageY} + return {x: event.pageX, y: event.pageY} _getGestureEvent: (event) -> @@ -337,22 +337,22 @@ class exports.GestureInputRecognizer start: eventPoint # Start point √ previous: eventPoint # Previous point √ - offset: {x:0, y:0} # Offset since start √ + offset: {x: 0, y: 0} # Offset since start √ offsetTime: 0 # Time since start √ offsetAngle: 0 # Angle from start √ offsetDirection: null # Direction from start (up, down, left, right) √ - delta: {x:0, y:0} # Offset since last event √ + delta: {x: 0, y: 0} # Offset since last event √ deltaTime: 0 # Time since last event √ deltaAngle: 0 # Angle from last event √ deltaDirection: null # Direction from last event √ force: 0, # 3d touch or force touch, iOS/Mac only √ - velocity: {x:0, y:0} # Velocity average over the last few events √ + velocity: {x: 0, y: 0} # Velocity average over the last few events √ fingers: event.touches?.length or 0 # Number of fingers used √ touchCenter: eventPoint # Center between two fingers √ - touchOffset: {x:0, y:0} # Offset between two fingers √ + touchOffset: {x: 0, y: 0} # Offset between two fingers √ touchDistance: 0 # Distance between two fingers √ scale: 1 # Scale value from two fingers √ scaleDirection: null # Direction for scale: up or down √ @@ -407,7 +407,7 @@ class exports.GestureInputRecognizer if @session?.lastEvent # If we just switched fingers, we skip the delta event entirely if event.fingers isnt @session.lastEvent.fingers == 2 - event.delta = {x:0, y:0} + event.delta = {x: 0, y: 0} # If we are having two finger events, we use the touchCenter as base for delta if event.fingers == 2 and @session.lastEvent.fingers == 2 event.delta = Utils.pointSubtract(event.touchCenter, @session.lastEvent.touchCenter) @@ -480,7 +480,7 @@ class exports.GestureInputRecognizer _getVelocity: (events) -> - return {x:0, y:0} if events.length < 2 + return {x: 0, y: 0} if events.length < 2 current = events[events.length - 1] first = events[0] diff --git a/framer/Importer.coffee b/framer/Importer.coffee index 929a0d2ac..94e80fb03 100644 --- a/framer/Importer.coffee +++ b/framer/Importer.coffee @@ -164,7 +164,7 @@ class exports.Importer # If this is an artboard we retain the size, but set the coordinates to zero # because all coordinates within artboards are 0, 0 based. if info.kind is "artboard" - layer.point = {x:0, y:0} + layer.point = {x: 0, y: 0} # If this is not an artboard, and does not have an image or mask, we clip the # layer to its content size. diff --git a/framer/Layer.coffee b/framer/Layer.coffee index 81a0cdae0..0ca5f872f 100644 --- a/framer/Layer.coffee +++ b/framer/Layer.coffee @@ -160,7 +160,7 @@ class exports.Layer extends BaseClass @define "visible", layerProperty(@, "visible", "display", true, _.isBoolean) @define "opacity", layerProperty(@, "opacity", "opacity", 1, _.isNumber) - @define "index", layerProperty(@, "index", "zIndex", 0, _.isNumber, null, {importable:false, exportable:false}) + @define "index", layerProperty(@, "index", "zIndex", 0, _.isNumber, null, {importable: false, exportable: false}) @define "clip", layerProperty(@, "clip", "overflow", false, _.isBoolean) @define "scrollHorizontal", layerProperty @, "scrollHorizontal", "overflowX", false, _.isBoolean, null, {}, (layer, value) -> @@ -435,7 +435,7 @@ class exports.Layer extends BaseClass @frame = Utils.convertFrameFromContext(frame, @, false, false) contentFrame: -> - return {x:0, y:0, width:0, height:0} unless @children.length + return {x: 0, y: 0, width: 0, height: 0} unless @children.length return Utils.frameMerge(_.map(@children, "frame")) totalFrame: -> @@ -522,7 +522,7 @@ class exports.Layer extends BaseClass frame = x: 0 y: 0 - width: @width * @screenScaleX() + width: @width * @screenScaleX() height: @height * @screenScaleY() layers = @ancestors(context=true) @@ -751,15 +751,15 @@ class exports.Layer extends BaseClass if @_parent @_parent._children = _.without @_parent._children, @ @_parent._element.removeChild @_element - @_parent.emit "change:children", {added:[], removed:[@]} - @_parent.emit "change:subLayers", {added:[], removed:[@]} + @_parent.emit "change:children", {added: [], removed: [@]} + @_parent.emit "change:subLayers", {added: [], removed: [@]} # Either insert the element to the new parent element or into dom if layer layer._element.appendChild @_element layer._children.push @ - layer.emit "change:children", {added:[@], removed:[]} - layer.emit "change:subLayers", {added:[@], removed:[]} + layer.emit "change:children", {added: [@], removed: []} + layer.emit "change:subLayers", {added: [@], removed: []} else @_insertElement() @@ -938,7 +938,7 @@ class exports.Layer extends BaseClass unless stateName? throw new Error("Missing required argument 'stateName' in stateSwitch()") return @animate(stateName, options) if options.animate is true - return @animate(stateName, _.defaults({}, options, {instant:true})) + return @animate(stateName, _.defaults({}, options, {instant: true})) animations: (includePending=false) -> # Current running animations on this layer @@ -1189,66 +1189,66 @@ class exports.Layer extends BaseClass # Gestures # Tap - onTap:(cb) -> @on(Events.Tap, cb) - onTapStart:(cb) -> @on(Events.TapStart, cb) - onTapEnd:(cb) -> @on(Events.TapEnd, cb) - onDoubleTap:(cb) -> @on(Events.DoubleTap, cb) + onTap: (cb) -> @on(Events.Tap, cb) + onTapStart: (cb) -> @on(Events.TapStart, cb) + onTapEnd: (cb) -> @on(Events.TapEnd, cb) + onDoubleTap: (cb) -> @on(Events.DoubleTap, cb) # Force Tap - onForceTap:(cb) -> @on(Events.ForceTap, cb) - onForceTapChange:(cb) -> @on(Events.ForceTapChange, cb) - onForceTapStart:(cb) -> @on(Events.ForceTapStart, cb) - onForceTapEnd:(cb) -> @on(Events.ForceTapEnd, cb) + onForceTap: (cb) -> @on(Events.ForceTap, cb) + onForceTapChange: (cb) -> @on(Events.ForceTapChange, cb) + onForceTapStart: (cb) -> @on(Events.ForceTapStart, cb) + onForceTapEnd: (cb) -> @on(Events.ForceTapEnd, cb) # Press - onLongPress:(cb) -> @on(Events.LongPress, cb) - onLongPressStart:(cb) -> @on(Events.LongPressStart, cb) - onLongPressEnd:(cb) -> @on(Events.LongPressEnd, cb) + onLongPress: (cb) -> @on(Events.LongPress, cb) + onLongPressStart: (cb) -> @on(Events.LongPressStart, cb) + onLongPressEnd: (cb) -> @on(Events.LongPressEnd, cb) # Swipe - onSwipe:(cb) -> @on(Events.Swipe, cb) - onSwipeStart:(cb) -> @on(Events.SwipeStart, cb) - onSwipeEnd:(cb) -> @on(Events.SwipeEnd, cb) + onSwipe: (cb) -> @on(Events.Swipe, cb) + onSwipeStart: (cb) -> @on(Events.SwipeStart, cb) + onSwipeEnd: (cb) -> @on(Events.SwipeEnd, cb) - onSwipeUp:(cb) -> @on(Events.SwipeUp, cb) - onSwipeUpStart:(cb) -> @on(Events.SwipeUpStart, cb) - onSwipeUpEnd:(cb) -> @on(Events.SwipeUpEnd, cb) + onSwipeUp: (cb) -> @on(Events.SwipeUp, cb) + onSwipeUpStart: (cb) -> @on(Events.SwipeUpStart, cb) + onSwipeUpEnd: (cb) -> @on(Events.SwipeUpEnd, cb) - onSwipeDown:(cb) -> @on(Events.SwipeDown, cb) - onSwipeDownStart:(cb) -> @on(Events.SwipeDownStart, cb) - onSwipeDownEnd:(cb) -> @on(Events.SwipeDownEnd, cb) + onSwipeDown: (cb) -> @on(Events.SwipeDown, cb) + onSwipeDownStart: (cb) -> @on(Events.SwipeDownStart, cb) + onSwipeDownEnd: (cb) -> @on(Events.SwipeDownEnd, cb) - onSwipeLeft:(cb) -> @on(Events.SwipeLeft, cb) - onSwipeLeftStart:(cb) -> @on(Events.SwipeLeftStart, cb) - onSwipeLeftEnd:(cb) -> @on(Events.SwipeLeftEnd, cb) + onSwipeLeft: (cb) -> @on(Events.SwipeLeft, cb) + onSwipeLeftStart: (cb) -> @on(Events.SwipeLeftStart, cb) + onSwipeLeftEnd: (cb) -> @on(Events.SwipeLeftEnd, cb) - onSwipeRight:(cb) -> @on(Events.SwipeRight, cb) - onSwipeRightStart:(cb) -> @on(Events.SwipeRightStart, cb) - onSwipeRightEnd:(cb) -> @on(Events.SwipeRightEnd, cb) + onSwipeRight: (cb) -> @on(Events.SwipeRight, cb) + onSwipeRightStart: (cb) -> @on(Events.SwipeRightStart, cb) + onSwipeRightEnd: (cb) -> @on(Events.SwipeRightEnd, cb) # Pan - onPan:(cb) -> @on(Events.Pan, cb) - onPanStart:(cb) -> @on(Events.PanStart, cb) - onPanEnd:(cb) -> @on(Events.PanEnd, cb) - onPanLeft:(cb) -> @on(Events.PanLeft, cb) - onPanRight:(cb) -> @on(Events.PanRight, cb) - onPanUp:(cb) -> @on(Events.PanUp, cb) - onPanDown:(cb) -> @on(Events.PanDown, cb) + onPan: (cb) -> @on(Events.Pan, cb) + onPanStart: (cb) -> @on(Events.PanStart, cb) + onPanEnd: (cb) -> @on(Events.PanEnd, cb) + onPanLeft: (cb) -> @on(Events.PanLeft, cb) + onPanRight: (cb) -> @on(Events.PanRight, cb) + onPanUp: (cb) -> @on(Events.PanUp, cb) + onPanDown: (cb) -> @on(Events.PanDown, cb) # Pinch - onPinch:(cb) -> @on(Events.Pinch, cb) - onPinchStart:(cb) -> @on(Events.PinchStart, cb) - onPinchEnd:(cb) -> @on(Events.PinchEnd, cb) + onPinch: (cb) -> @on(Events.Pinch, cb) + onPinchStart: (cb) -> @on(Events.PinchStart, cb) + onPinchEnd: (cb) -> @on(Events.PinchEnd, cb) # Scale - onScale:(cb) -> @on(Events.Scale, cb) - onScaleStart:(cb) -> @on(Events.ScaleStart, cb) - onScaleEnd:(cb) -> @on(Events.ScaleEnd, cb) + onScale: (cb) -> @on(Events.Scale, cb) + onScaleStart: (cb) -> @on(Events.ScaleStart, cb) + onScaleEnd: (cb) -> @on(Events.ScaleEnd, cb) # Rotate - onRotate:(cb) -> @on(Events.Rotate, cb) - onRotateStart:(cb) -> @on(Events.RotateStart, cb) - onRotateEnd:(cb) -> @on(Events.RotateEnd, cb) + onRotate: (cb) -> @on(Events.Rotate, cb) + onRotateStart: (cb) -> @on(Events.RotateStart, cb) + onRotateEnd: (cb) -> @on(Events.RotateEnd, cb) ############################################################## diff --git a/framer/LayerDraggable.coffee b/framer/LayerDraggable.coffee index f987b6aa7..27ee9f983 100644 --- a/framer/LayerDraggable.coffee +++ b/framer/LayerDraggable.coffee @@ -53,7 +53,7 @@ class exports.LayerDraggable extends BaseClass @define "momentumVelocityMultiplier", @simpleProperty("momentumVelocityMultiplier", 800) @define "directionLock", @simpleProperty("directionLock", true) - @define "directionLockThreshold", @simpleProperty("directionLockThreshold", {x:10, y:10}) + @define "directionLockThreshold", @simpleProperty("directionLockThreshold", {x: 10, y: 10}) @define "propagateEvents", @simpleProperty("propagateEvents", true) @define "constraints", @@ -61,10 +61,10 @@ class exports.LayerDraggable extends BaseClass set: (value) -> if value and _.isObject(value) value = _.pick(value, ["x", "y", "width", "height"]) - value = _.defaults(value, {x:0, y:0, width:0, height:0}) + value = _.defaults(value, {x: 0, y: 0, width: 0, height: 0}) @_constraints = value else - @_constraints = {x:0, y:0, width:0, height:0} + @_constraints = {x: 0, y: 0, width: 0, height: 0} @_updateSimulationConstraints(@_constraints) if @_constraints # The isDragging only is true when there was actual movement, so you can @@ -74,12 +74,12 @@ class exports.LayerDraggable extends BaseClass @define "isMoving", get: -> @_isMoving or false @define "layerStartPoint", get: -> @_layerStartPoint or @layer.point - @define "cursorStartPoint", get: -> @_cursorStartPoint or {x:0, y:0} - @define "layerCursorOffset", get: -> @_layerCursorOffset or {x:0, y:0} + @define "cursorStartPoint", get: -> @_cursorStartPoint or {x: 0, y: 0} + @define "layerCursorOffset", get: -> @_layerCursorOffset or {x: 0, y: 0} @define "offset", get: -> - return {x:0, y:0} if not @_correctedLayerStartPoint + return {x: 0, y: 0} if not @_correctedLayerStartPoint return offset = x: @layer.x - @_correctedLayerStartPoint.x y: @layer.y - @_correctedLayerStartPoint.y @@ -291,7 +291,7 @@ class exports.LayerDraggable extends BaseClass @define "constraintsOffset", get: -> - return {x:0, y:0} unless @constraints + return {x: 0, y: 0} unless @constraints {minX, maxX, minY, maxY} = @_calculateConstraints(@constraints) point = @layer.point constrainedPoint = @@ -367,11 +367,11 @@ class exports.LayerDraggable extends BaseClass get: -> return @_calculateSimulationVelocity() if @isAnimating return @_eventBuffer.velocity - return {x:0, y:0} + return {x: 0, y: 0} # return @_eventBuffer.velocity if @isDragging # return @_calculateSimulationVelocity() if @isAnimating - # return {x:0, y:0} + # return {x: 0, y: 0} @define "angle", get: -> @_eventBuffer.angle @@ -405,7 +405,7 @@ class exports.LayerDraggable extends BaseClass xFinished = @_simulation.x.finished() yFinished = @_simulation.y.finished() - velocity = {x:0, y:0} + velocity = {x: 0, y: 0} velocity.x = (@_simulation.x.simulator.state.v / @momentumVelocityMultiplier) if not xFinished velocity.y = (@_simulation.y.simulator.state.v / @momentumVelocityMultiplier) if not yFinished @@ -483,11 +483,11 @@ class exports.LayerDraggable extends BaseClass return unless @_simulation if constraints {minX, maxX, minY, maxY} = @_calculateConstraints(@_constraints) - @_simulation.x.simulator.options = {min:minX, max:maxX} - @_simulation.y.simulator.options = {min:minY, max:maxY} + @_simulation.x.simulator.options = {min: minX, max: maxX} + @_simulation.y.simulator.options = {min: minY, max: maxY} else - @_simulation.x.simulator.options = {min:-Infinity, max:+Infinity} - @_simulation.y.simulator.options = {min:-Infinity, max:+Infinity} + @_simulation.x.simulator.options = {min: -Infinity, max: +Infinity} + @_simulation.y.simulator.options = {min: -Infinity, max: +Infinity} _onSimulationStep: (axis, state) => diff --git a/framer/LayerStates.coffee b/framer/LayerStates.coffee index c21e9a08c..0103cacba 100644 --- a/framer/LayerStates.coffee +++ b/framer/LayerStates.coffee @@ -93,7 +93,7 @@ class LayerStates deprecatedWarning("remove", "delete layer.states.a") delete @[stateName] - switch: (stateName, options) -> + switch: (stateName, options) -> deprecatedWarning("switch", "layer.animate(\"state\")") @machine.switchTo(stateName, options) diff --git a/framer/Matrix.coffee b/framer/Matrix.coffee index a31b47e9e..8b44a92f3 100644 --- a/framer/Matrix.coffee +++ b/framer/Matrix.coffee @@ -8,7 +8,7 @@ WebKitCSSMatrix::skew = (skew) -> return @multiply(m) WebKitCSSMatrix::point = (point = {}) -> - {x, y, z} = _.defaults(point, {x:0, y:0, z:0}) + {x, y, z} = _.defaults(point, {x: 0, y: 0, z: 0}) w = @m14 * x + @m24 * y + @m34 * z + @m44 w = w or 1 return point = diff --git a/framer/Print.coffee b/framer/Print.coffee index 97341610d..eb4bb5c6f 100644 --- a/framer/Print.coffee +++ b/framer/Print.coffee @@ -4,7 +4,7 @@ Utils = require "./Utils" class Printer constructor: -> - @_context = new Context(name:"PrintConsole") + @_context = new Context(name: "PrintConsole") @_context.run => Events.wrap(window).addEventListener("resize", @resize) createLayer: => diff --git a/framer/Screen.coffee b/framer/Screen.coffee index a12b46478..7fc54e49d 100644 --- a/framer/Screen.coffee +++ b/framer/Screen.coffee @@ -36,25 +36,25 @@ class ScreenClass extends BaseClass # Edge Swipe - onEdgeSwipe:(cb) -> @on(Events.EdgeSwipe, cb) - onEdgeSwipeStart:(cb) -> @on(Events.EdgeSwipeStart, cb) - onEdgeSwipeEnd:(cb) -> @on(Events.EdgeSwipeEnd, cb) + onEdgeSwipe: (cb) -> @on(Events.EdgeSwipe, cb) + onEdgeSwipeStart: (cb) -> @on(Events.EdgeSwipeStart, cb) + onEdgeSwipeEnd: (cb) -> @on(Events.EdgeSwipeEnd, cb) - onEdgeSwipeTop:(cb) -> @on(Events.EdgeSwipeTop, cb) - onEdgeSwipeTopStart:(cb) -> @on(Events.EdgeSwipeTopStart, cb) - onEdgeSwipeTopEnd:(cb) -> @on(Events.EdgeSwipeTopEnd, cb) + onEdgeSwipeTop: (cb) -> @on(Events.EdgeSwipeTop, cb) + onEdgeSwipeTopStart: (cb) -> @on(Events.EdgeSwipeTopStart, cb) + onEdgeSwipeTopEnd: (cb) -> @on(Events.EdgeSwipeTopEnd, cb) - onEdgeSwipeRight:(cb) -> @on(Events.EdgeSwipeRight, cb) - onEdgeSwipeRightStart:(cb) -> @on(Events.EdgeSwipeRightStart, cb) - onEdgeSwipeRightEnd:(cb) -> @on(Events.EdgeSwipeRightEnd, cb) + onEdgeSwipeRight: (cb) -> @on(Events.EdgeSwipeRight, cb) + onEdgeSwipeRightStart: (cb) -> @on(Events.EdgeSwipeRightStart, cb) + onEdgeSwipeRightEnd: (cb) -> @on(Events.EdgeSwipeRightEnd, cb) - onEdgeSwipeBottom:(cb) -> @on(Events.EdgeSwipeBottom, cb) - onEdgeSwipeBottomStart:(cb) -> @on(Events.EdgeSwipeBottomStart, cb) - onEdgeSwipeBottomEnd:(cb) -> @on(Events.EdgeSwipeBottomEnd, cb) + onEdgeSwipeBottom: (cb) -> @on(Events.EdgeSwipeBottom, cb) + onEdgeSwipeBottomStart: (cb) -> @on(Events.EdgeSwipeBottomStart, cb) + onEdgeSwipeBottomEnd: (cb) -> @on(Events.EdgeSwipeBottomEnd, cb) - onEdgeSwipeLeft:(cb) -> @on(Events.EdgeSwipeLeft, cb) - onEdgeSwipeLeftStart:(cb) -> @on(Events.EdgeSwipeLeftStart, cb) - onEdgeSwipeLeftEnd:(cb) -> @on(Events.EdgeSwipeLeftEnd, cb) + onEdgeSwipeLeft: (cb) -> @on(Events.EdgeSwipeLeft, cb) + onEdgeSwipeLeftStart: (cb) -> @on(Events.EdgeSwipeLeftStart, cb) + onEdgeSwipeLeftEnd: (cb) -> @on(Events.EdgeSwipeLeftEnd, cb) # We use this as a singleton exports.Screen = new ScreenClass diff --git a/framer/Simulator.coffee b/framer/Simulator.coffee index 1b4cd2531..7919e4e5f 100644 --- a/framer/Simulator.coffee +++ b/framer/Simulator.coffee @@ -16,7 +16,7 @@ class exports.Simulator extends BaseClass set: (state) -> @_state = _.clone(state) constructor: (options={}) -> - @_state = {x:0, v:0} + @_state = {x: 0, v: 0} @options = null @setup(options) diff --git a/framer/Utils.coffee b/framer/Utils.coffee index 7f822a8e5..cd794776d 100644 --- a/framer/Utils.coffee +++ b/framer/Utils.coffee @@ -656,7 +656,7 @@ Utils.point = (input) -> return result Utils.pointZero = (n=0) -> - return {x:n, y:n} + return {x: n, y: n} Utils.pointDivide = (point, fraction) -> return point = @@ -737,37 +737,37 @@ Utils.size = (input) -> return result Utils.sizeZero = (n=0) -> - return {width:n, height:n} + return {width: n, height: n} Utils.sizeMin = -> sizes = Utils.arrayFromArguments arguments size = - width: _.min sizes.map (size) -> size.width + width: _.min sizes.map (size) -> size.width height: _.min sizes.map (size) -> size.height Utils.sizeMax = -> sizes = Utils.arrayFromArguments arguments size = - width: _.max sizes.map (size) -> size.width + width: _.max sizes.map (size) -> size.width height: _.max sizes.map (size) -> size.height # Rect Utils.rectZero = (args={}) -> - return _.defaults(args, {top:0, right:0, bottom:0, left:0}) + return _.defaults(args, {top: 0, right: 0, bottom: 0, left: 0}) Utils.parseRect = (args) -> if _.isArray(args) and _.isNumber(args[0]) - return Utils.parseRect({top:args[0]}) if args.length is 1 - return Utils.parseRect({top:args[0], right:args[1]}) if args.length is 2 - return Utils.parseRect({top:args[0], right:args[1], bottom:args[2]}) if args.length is 3 - return Utils.parseRect({top:args[0], right:args[1], bottom:args[2], left:args[3]}) if args.length is 4 + return Utils.parseRect({top: args[0]}) if args.length is 1 + return Utils.parseRect({top: args[0], right: args[1]}) if args.length is 2 + return Utils.parseRect({top: args[0], right: args[1], bottom: args[2]}) if args.length is 3 + return Utils.parseRect({top: args[0], right: args[1], bottom: args[2], left: args[3]}) if args.length is 4 if _.isArray(args) and _.isObject(args[0]) return args[0] if _.isObject(args) return args if _.isNumber(args) - return {top:args, right:args, bottom:args, left:args} + return {top: args, right: args, bottom: args, left: args} return {} @@ -814,7 +814,7 @@ Utils.frame = (input) -> return result Utils.frameZero = (n=0) -> - return {x:n, y:n} + return {x: n, y: n} Utils.frameSize = (frame) -> size = @@ -831,10 +831,10 @@ Utils.pointsFromFrame = (frame) -> maxX = Utils.frameGetMaxX(frame) minY = Utils.frameGetMinY(frame) maxY = Utils.frameGetMaxY(frame) - corner1 = {x:minX, y:minY} - corner2 = {x:minX, y:maxY} - corner3 = {x:maxX, y:maxY} - corner4 = {x:maxX, y:minY} + corner1 = {x: minX, y: minY} + corner2 = {x: minX, y: maxY} + corner3 = {x: maxX, y: maxY} + corner4 = {x: maxX, y: minY} return [corner1, corner2, corner3, corner4] Utils.frameFromPoints = (points) -> @@ -892,7 +892,7 @@ Utils.framePointForOrigin = (frame, originX, originY) -> Utils.frameInset = (frame, inset) -> if _.isNumber(inset) - inset = {top:inset, right:inset, bottom:inset, left:inset} + inset = {top: inset, right: inset, bottom: inset, left: inset} frame = Utils.frame(frame) @@ -985,7 +985,7 @@ Utils.rotationNormalizer = -> # convert a point from a layer to the context level, with rootContext enabled you can make it cross to the top context Utils.convertPointToContext = (point = {}, layer, rootContext=false, includeLayer=true) -> - point = _.defaults(point, {x:0, y:0, z:0}) + point = _.defaults(point, {x: 0, y: 0, z: 0}) ancestors = layer.ancestors(rootContext) ancestors.unshift(layer) if includeLayer @@ -997,7 +997,7 @@ Utils.convertPointToContext = (point = {}, layer, rootContext=false, includeLaye return point Utils.convertFrameToContext = (frame = {}, layer, rootContext=false, includeLayer=true) -> - frame = _.defaults(frame, {x:0, y:0, width:100, height:100}) + frame = _.defaults(frame, {x: 0, y: 0, width: 100, height: 100}) corners = Utils.pointsFromFrame(frame) convertedCorners = corners.map (point) -> return Utils.convertPointToContext(point, layer, rootContext, includeLayer) @@ -1006,7 +1006,7 @@ Utils.convertFrameToContext = (frame = {}, layer, rootContext=false, includeLaye # convert a point from the context level to a layer, with rootContext enabled you can make it cross from the top context Utils.convertPointFromContext = (point = {}, layer, rootContext=false, includeLayer=true) -> - point = _.defaults(point, {x:0, y:0, z:0}) + point = _.defaults(point, {x: 0, y: 0, z: 0}) if rootContext and webkitConvertPointFromPageToNode? if includeLayer @@ -1028,7 +1028,7 @@ Utils.convertPointFromContext = (point = {}, layer, rootContext=false, includeLa # convert a frame from the context level to a layer, with rootContext enabled you can make it start from the top context Utils.convertFrameFromContext = (frame = {}, layer, rootContext=false, includeLayer=true) -> - frame = _.defaults(frame, {x:0, y:0, width:100, height:100}) + frame = _.defaults(frame, {x: 0, y: 0, width: 100, height: 100}) corners = Utils.pointsFromFrame(frame) convertedCorners = corners.map (point) -> return Utils.convertPointFromContext(point, layer, rootContext, includeLayer) @@ -1038,7 +1038,7 @@ Utils.convertFrameFromContext = (frame = {}, layer, rootContext=false, includeLa Utils.convertPoint = (input, layerA, layerB, rootContext=false) -> # Convert a point between two layer coordinate systems - point = _.defaults(input, {x:0, y:0, z:0}) + point = _.defaults(input, {x: 0, y: 0, z: 0}) point = Utils.convertPointToContext(point, layerA, rootContext) if layerA if layerB? return Utils.convertPointFromContext(point, layerB, rootContext) @@ -1050,7 +1050,7 @@ Utils.convertPoint = (input, layerA, layerB, rootContext=false) -> # get the bounding frame of a layer, either at the canvas (rootcontext) or screen level Utils.boundingFrame = (layer, rootContext=true) -> - frame = {x:0, y:0, width:layer.width, height:layer.height} + frame = {x: 0, y: 0, width: layer.width, height: layer.height} cornerPoints = Utils.pointsFromFrame(frame) contextCornerPoints = cornerPoints.map (point) -> return Utils.convertPointToContext(point, layer, rootContext) diff --git a/gulpfile.coffee b/gulpfile.coffee index 8ed50bf72..2ea0bce19 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -35,7 +35,7 @@ gulp.task "test", ["webpack:tests", "lint"], -> return gulp .src("test/phantomjs/index.html") .pipe(phantomjs({ - reporter:"dot", + reporter: "dot", viewportSize: {width: 1024, height: 768}, useColors: true, loadImages: false diff --git a/scripts/site.coffee b/scripts/site.coffee index 82e46ab9a..9b7ed6158 100644 --- a/scripts/site.coffee +++ b/scripts/site.coffee @@ -29,7 +29,7 @@ main = -> COMMANDS = "upload": -> uploadDir Config.output - "build": -> build() + "build": -> build() command = process.argv[2] @@ -50,7 +50,7 @@ build = -> indexData = fs.readFileSync "#{Config.input}/index.html", "utf8" # Build up a context - context = commits:[] + context = commits: [] exec "git log --pretty=format:\"%h\t%an\t%ad\t%s\" --first-parent master", (err, output) -> throw err if err diff --git a/test/tests.coffee b/test/tests.coffee index cf13dc21f..c8e18db9d 100644 --- a/test/tests.coffee +++ b/test/tests.coffee @@ -17,7 +17,7 @@ chai.should() chai.config.truncateThreshold = 2 chai.config.showDiff = true -mocha.setup({ui:"bdd", bail:true, reporter:"dot"}) +mocha.setup({ui: "bdd", bail: true, reporter: "dot"}) mocha.globals(["__import__"]) window.print = (args...) -> diff --git a/test/tests/AlignTest.coffee b/test/tests/AlignTest.coffee index 3af3ed0dc..d9999715d 100644 --- a/test/tests/AlignTest.coffee +++ b/test/tests/AlignTest.coffee @@ -33,9 +33,9 @@ describe "Align", -> layer.y.should.equal 75 it "should take borderWidth into account", -> - {child} = createAlignedLayers("x", Align.center, {borderWidth:30}) + {child} = createAlignedLayers("x", Align.center, {borderWidth: 30}) child.x.should.equal 170 - {child} = createAlignedLayers("y", Align.center, {borderWidth:30}) + {child} = createAlignedLayers("y", Align.center, {borderWidth: 30}) child.y.should.equal 20 @@ -52,7 +52,7 @@ describe "Align", -> layer.x.should.equal 0 it "should take borderWidth into account", -> - {child} = createAlignedLayers("x", Align.left, {borderWidth:30}) + {child} = createAlignedLayers("x", Align.left, {borderWidth: 30}) child.x.should.equal 0 describe "right", -> @@ -68,7 +68,7 @@ describe "Align", -> layer.x.should.equal 300 it "should take borderWidth into account", -> - {child} = createAlignedLayers("x", Align.right, {borderWidth:30}) + {child} = createAlignedLayers("x", Align.right, {borderWidth: 30}) child.x.should.equal 340 describe "top", -> @@ -84,7 +84,7 @@ describe "Align", -> layer.y.should.equal 0 it "should take borderWidth into account", -> - {child} = createAlignedLayers("y", Align.top, {borderWidth:30}) + {child} = createAlignedLayers("y", Align.top, {borderWidth: 30}) child.y.should.equal 0 describe "bottom", -> @@ -100,7 +100,7 @@ describe "Align", -> layer.y.should.equal 200 it "should take borderWidth into account", -> - {child} = createAlignedLayers("y", Align.bottom, {borderWidth:30}) + {child} = createAlignedLayers("y", Align.bottom, {borderWidth: 30}) child.y.should.equal 40 describe "constructors", -> diff --git a/test/tests/BaseClassTest.coffee b/test/tests/BaseClassTest.coffee index cd2d65fdb..5ef98e7ba 100644 --- a/test/tests/BaseClassTest.coffee +++ b/test/tests/BaseClassTest.coffee @@ -36,7 +36,7 @@ describe "BaseClass", -> it "should set defaults on construction", -> - testClass = new TestClass width:100, height:100 + testClass = new TestClass width: 100, height: 100 testClass.width.should.equal 100 testClass.height.should.equal 100 @@ -141,7 +141,7 @@ describe "BaseClass", -> constructor: -> super - @poop = {hello:100} + @poop = {hello: 100} testClass = new TestClass7() testClass.poop.hello.should.equal 100 diff --git a/test/tests/ContextTest.coffee b/test/tests/ContextTest.coffee index 16c424208..77e38c695 100644 --- a/test/tests/ContextTest.coffee +++ b/test/tests/ContextTest.coffee @@ -11,7 +11,7 @@ describe "Context", -> # There's one default context: document.querySelectorAll(".framerContext").length.should.equal(c1) - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.reset() context.reset() @@ -28,7 +28,7 @@ describe "Context", -> it "should remove events", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") layer = null handler = -> @@ -44,7 +44,7 @@ describe "Context", -> it "should restore events", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") layer = null handler = -> @@ -61,7 +61,7 @@ describe "Context", -> it "should freeze and restore multiple events on multiple layers", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") layerA = layerB = null handlerA = -> @@ -93,7 +93,7 @@ describe "Context", -> it "should freeze and restore multiple events a layer", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") layerA = null handlerA = -> @@ -123,7 +123,7 @@ describe "Context", -> it "should stop animations", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") layer = null animation = null @@ -142,7 +142,7 @@ describe "Context", -> it "should stop timers", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") layer = null timer = null @@ -163,7 +163,7 @@ describe "Context", -> it "should add and remove layers", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.run -> @@ -178,12 +178,12 @@ describe "Context", -> it "should list root layers", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.run -> layerA = new Layer - layerB = new Layer parent:layerA + layerB = new Layer parent: layerA context.rootLayers.should.eql [layerA] layerB.parent = null @@ -191,7 +191,7 @@ describe "Context", -> it "should get layers by id", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.run -> layerA = new Layer @@ -199,7 +199,7 @@ describe "Context", -> it "should get layers by element", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.run -> layerA = new Layer @@ -211,13 +211,13 @@ describe "Context", -> it "should emit reset", (callback) -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.on "reset", -> callback() context.reset() it "should emit layer create", (callback) -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.on "layer:create", -> context.layers.length.should.equal 1 callback() @@ -228,7 +228,7 @@ describe "Context", -> it "should emit layer destroy", (callback) -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.on "layer:create", -> context.layers.length.should.equal 1 @@ -243,7 +243,7 @@ describe "Context", -> it "should keep layer id count per context", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.run -> layer = new Layer @@ -263,7 +263,7 @@ describe "Context", -> it "should set backgroundColor", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.backgroundColor = "red" color = new Color "red" colorString = color.toString() @@ -271,11 +271,11 @@ describe "Context", -> it "should have a default perspective of 0", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context._element.style["webkitPerspective"].should.equal "0" it "should allow the perspective to be changed", -> - context = new Framer.Context(name:"Test") + context = new Framer.Context(name: "Test") context.perspective = 800 context._element.style["webkitPerspective"].should.equal "800" diff --git a/test/tests/DeviceComponentTest.coffee b/test/tests/DeviceComponentTest.coffee index 9cfa61f03..eded8697e 100644 --- a/test/tests/DeviceComponentTest.coffee +++ b/test/tests/DeviceComponentTest.coffee @@ -105,7 +105,7 @@ describe "DeviceComponent", -> device.deviceType = "nexus-5-black" device.context.run -> - Screen.size.should.eql {width:1080, height:1920} + Screen.size.should.eql {width: 1080, height: 1920} Utils.inspect(Screen).should.equal "" it "should calculate canvas frames", -> @@ -116,7 +116,7 @@ describe "DeviceComponent", -> device.deviceType = "nexus-5-black" device.context.run -> - Screen.size.should.eql {width:1080, height:1920} + Screen.size.should.eql {width: 1080, height: 1920} Screen.canvasFrame.should.eql device.screen.canvasFrame device.deviceType = "fullscreen" @@ -133,19 +133,19 @@ describe "DeviceComponent", -> device.orientation.should.equal 0 device.isPortrait.should.equal true - device.screenSize.should.eql {width:1080, height:1920} + device.screenSize.should.eql {width: 1080, height: 1920} device.rotateLeft(false) device.orientation.should.equal 90 device.isPortrait.should.equal false - device.screenSize.should.eql {width:1920, height:1080} + device.screenSize.should.eql {width: 1920, height: 1080} device.rotateRight(false) device.orientation.should.equal 0 device.isPortrait.should.equal true - device.screenSize.should.eql {width:1080, height:1920} + device.screenSize.should.eql {width: 1080, height: 1920} device.rotateRight(false) device.orientation.should.equal -90 device.isPortrait.should.equal false - device.screenSize.should.eql {width:1920, height:1080} + device.screenSize.should.eql {width: 1920, height: 1080} diff --git a/test/tests/LayerAnimationTest.coffee b/test/tests/LayerAnimationTest.coffee index b2de318fe..0762b0e72 100644 --- a/test/tests/LayerAnimationTest.coffee +++ b/test/tests/LayerAnimationTest.coffee @@ -13,7 +13,7 @@ describe "LayerAnimation", -> curve: "spring(1, 2, 3)" animation = new Animation new Layer(), - x:50 + x: 50 animation.options.curve.should.equal "spring(1, 2, 3)" @@ -24,7 +24,7 @@ describe "LayerAnimation", -> # We shouldn't change the linear default, people rely on it animation = new Animation new Layer(), - x:50 + x: 50 animation.options.curve.should.equal "ease" animation.options.time.should.equal 1 @@ -352,7 +352,7 @@ describe "LayerAnimation", -> layer = new Layer() animation = new Animation layer, - x:50 + x: 50 options: curve: "linear" time: AnimationTime @@ -373,7 +373,7 @@ describe "LayerAnimation", -> layer = new Layer() animation = new Animation layer, - x:50 + x: 50 options: curve: "linear" time: AnimationTime @@ -392,7 +392,7 @@ describe "LayerAnimation", -> layer = new Layer() animation = new Animation layer, - x:50 + x: 50 options: curve: "linear" time: AnimationTime * 2 @@ -415,7 +415,7 @@ describe "LayerAnimation", -> layer = new Layer() animation = new Animation layer, - x:50 + x: 50 options: curve: "linear" time: AnimationTime @@ -432,7 +432,7 @@ describe "LayerAnimation", -> it "should stop when stopped before delay ends", (done) -> layer = new Layer() animation = new Animation layer, - properties: {x:50} + properties: {x: 50} curve: "linear" time: 0.5 delay: 0.3 @@ -499,24 +499,24 @@ describe "LayerAnimation", -> it "should only stop when all animations are done", (done) -> - layerA = new Layer width:80, height:80 + layerA = new Layer width: 80, height: 80 layerA.name = "layerA" layerA.animate - y:300 + y: 300 options: time: 2 * AnimationTime - layerB = new Layer width:80, height:80, x:100, backgroundColor:"red" + layerB = new Layer width: 80, height: 80, x: 100, backgroundColor: "red" layerB.name = "layerB" layerB.animate - y:300 + y: 300 options: time: 5 * AnimationTime - layerC = new Layer width:80, height:80, x:200, backgroundColor:"orange" + layerC = new Layer width: 80, height: 80, x: 200, backgroundColor: "orange" layerC.name = "layerC" layerC.animate - y:300 + y: 300 options: time: 2 * AnimationTime curve: "cubic-bezier" diff --git a/test/tests/LayerStatesBackwardsTest.coffee b/test/tests/LayerStatesBackwardsTest.coffee index b4e2d6637..ab28b5b40 100644 --- a/test/tests/LayerStatesBackwardsTest.coffee +++ b/test/tests/LayerStatesBackwardsTest.coffee @@ -124,8 +124,8 @@ describe "LayerStates Backwards compatibility", -> beforeEach -> @layer = new Layer() - @layer.states.add("a", {x:100, y:100}) - @layer.states.add("b", {x:200, y:200}) + @layer.states.add("a", {x: 100, y: 100}) + @layer.states.add("b", {x: 200, y: 200}) it "should emit StateWillSwitch when switching", (done) -> @@ -155,7 +155,7 @@ describe "LayerStates Backwards compatibility", -> it "should set defaults", -> layer = new Layer - layer.states.add "test", {x:123} + layer.states.add "test", {x: 123} animation = layer.states.switch "test" animation.options.curve.should.equal Framer.Defaults.Animation.curve @@ -164,7 +164,7 @@ describe "LayerStates Backwards compatibility", -> curve: "spring(1, 2, 3)" layer = new Layer - layer.states.add "test", {x:456} + layer.states.add "test", {x: 456} animation = layer.states.switch "test" animation.options.curve.should.equal "spring(1, 2, 3)" diff --git a/test/tests/LayerStatesTest.coffee b/test/tests/LayerStatesTest.coffee index c3e5de59d..bbb1f01d4 100644 --- a/test/tests/LayerStatesTest.coffee +++ b/test/tests/LayerStatesTest.coffee @@ -12,8 +12,8 @@ describe "LayerStates", -> beforeEach -> @layer = new Layer() - @layer.states.a = {x:100, y:100} - @layer.states.b = {x:200, y:200} + @layer.states.a = {x: 100, y: 100} + @layer.states.b = {x: 200, y: 200} it "should emit StateSwitchStart when switching", (done) -> @@ -146,9 +146,9 @@ describe "LayerStates", -> layer = new Layer layer.states = stateA: - x:123 + x: 123 stateB: - y:123 + y: 123 options: instant: true @@ -169,7 +169,7 @@ describe "LayerStates", -> it "should switch non animatable properties", -> layer = new Layer - layer.states.stateA = {x: 100, image:"static/test2.png"} + layer.states.stateA = {x: 100, image: "static/test2.png"} layer.animate "stateA", instant: true layer.x.should.equal 100 layer.image.should.equal "static/test2.png" @@ -234,8 +234,8 @@ describe "LayerStates", -> layer = new Layer layer.states = - stateA: {x:100, rotation: 90, options: time: 0.05} - stateB: {x:200, rotation: 180, options: time: 0.05} + stateA: {x: 100, rotation: 90, options: time: 0.05} + stateB: {x: 200, rotation: 180, options: time: 0.05} layer.x.should.equal 0 @@ -324,7 +324,7 @@ describe "LayerStates", -> layer = new Layer layer.states = - stateA: {scroll:true, backgroundColor:"red"} + stateA: {scroll: true, backgroundColor: "red"} layer.scroll.should.equal false @@ -339,7 +339,7 @@ describe "LayerStates", -> layer = new Layer layer.states = - stateA: {x:200, backgroundColor:"red"} + stateA: {x: 200, backgroundColor: "red"} # layer.scroll.should.equal false layer.x.should.equal 0 @@ -350,13 +350,13 @@ describe "LayerStates", -> layer.style.backgroundColor.should.equal new Color("red").toString() done() - layer.animate "stateA", {curve:"linear", time:0.1} + layer.animate "stateA", {curve: "linear", time: 0.1} it "should restore the initial state when using non exportable properties", -> layer = new Layer layer.states = - stateA: {midX:200} + stateA: {midX: 200} layer.x.should.equal 0 diff --git a/test/tests/ScrollComponentTest.coffee b/test/tests/ScrollComponentTest.coffee index e4fe08ca8..54f87b586 100644 --- a/test/tests/ScrollComponentTest.coffee +++ b/test/tests/ScrollComponentTest.coffee @@ -7,8 +7,8 @@ describe "ScrollComponent", -> scroll = new ScrollComponent size: 300 - scroll.frame.should.eql {x:0, y:0, width:300, height:300} - scroll.content.frame.should.eql {x:0, y:0, width:300, height:300} + scroll.frame.should.eql {x: 0, y: 0, width: 300, height: 300} + scroll.content.frame.should.eql {x: 0, y: 0, width: 300, height: 300} it "should have the right content frame with align", -> @@ -20,8 +20,8 @@ describe "ScrollComponent", -> size: 100 point: Align.center - scroll.content.frame.should.eql {x:0, y:0, width:300, height:300} - layer.frame.should.eql {x:100, y:100, width:100, height:100} + scroll.content.frame.should.eql {x: 0, y: 0, width: 300, height: 300} + layer.frame.should.eql {x: 100, y: 100, width: 100, height: 100} it "should apply constructor options", -> @@ -154,23 +154,23 @@ describe "ScrollComponent", -> it "should use the wrapped layer as content layer when there are children", -> - layerA = new Layer frame:Screen.frame - layerB = new Layer superLayer:layerA + layerA = new Layer frame: Screen.frame + layerB = new Layer superLayer: layerA scroll = ScrollComponent.wrap(layerA) scroll.content.should.equal layerA it "should use the wrapped layer as content if there are no children", -> - layerA = new Layer frame:Screen.frame + layerA = new Layer frame: Screen.frame scroll = ScrollComponent.wrap(layerA) scroll.content.children[0].should.equal layerA it "should copy the name and image", -> - layerA = new Layer frame:Screen.frame, name:"Koen", image:"../static/test.png" - layerB = new Layer superLayer:layerA + layerA = new Layer frame: Screen.frame, name: "Koen", image: "../static/test.png" + layerB = new Layer superLayer: layerA scroll = ScrollComponent.wrap(layerA) @@ -187,7 +187,7 @@ describe "ScrollComponent", -> frame.width += 100 frame.height += 100 - layerA = new Layer frame:frame + layerA = new Layer frame: frame scroll = ScrollComponent.wrap(layerA) scroll.width.should.equal Screen.width @@ -199,8 +199,8 @@ describe "ScrollComponent", -> frame.width += 100 frame.height += 100 - layerA = new Layer frame:frame - layerB = new Layer superLayer:layerA + layerA = new Layer frame: frame + layerB = new Layer superLayer: layerA scroll = ScrollComponent.wrap(layerA) scroll.width.should.equal Screen.width @@ -209,7 +209,7 @@ describe "ScrollComponent", -> it "should work with null backgroundColor", -> layerA = new Layer - layerB = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA delete layerA._properties.backgroundColor scroll = ScrollComponent.wrap(layerA) diff --git a/test/tests/UtilsTest.coffee b/test/tests/UtilsTest.coffee index b21dca52b..d8bba766c 100644 --- a/test/tests/UtilsTest.coffee +++ b/test/tests/UtilsTest.coffee @@ -68,14 +68,14 @@ describe "Utils", -> it "should work", -> Utils.sizeMax([ - {width:100, height:100}, - {width:100, height:100}, - ]).should.eql {width:100, height:100} + {width: 100, height: 100}, + {width: 100, height: 100}, + ]).should.eql {width: 100, height: 100} Utils.sizeMax([ - {width:1000, height:1000}, - {width:100, height:100}, - ]).should.eql {width:1000, height:1000} + {width: 1000, height: 1000}, + {width: 100, height: 100}, + ]).should.eql {width: 1000, height: 1000} describe "pathJoin", -> @@ -88,21 +88,21 @@ describe "Utils", -> it "should work", -> Utils.sizeMin([ - {width:100, height:100}, - {width:100, height:100}, - ]).should.eql {width:100, height:100} + {width: 100, height: 100}, + {width: 100, height: 100}, + ]).should.eql {width: 100, height: 100} Utils.sizeMin([ - {width:1000, height:1000}, - {width:100, height:100}, - ]).should.eql {width:100, height:100} + {width: 1000, height: 1000}, + {width: 100, height: 100}, + ]).should.eql {width: 100, height: 100} describe "points", -> it "should get points from frame", -> - frame = {x:200, y:-60, width:200, height:200} + frame = {x: 200, y: -60, width: 200, height: 200} points = Utils.pointsFromFrame(frame) points.length.should.eql 4 @@ -112,7 +112,7 @@ describe "Utils", -> it "should get frame from points", -> - points = [{x:200, y:-60}, {x:200, y:140}, {x:400, y:140}, {x:400, y:-60}] + points = [{x: 200, y: -60}, {x: 200, y: 140}, {x: 400, y: 140}, {x: 400, y: -60}] frame = Utils.frameFromPoints(points) frame.x.should.eql 200 @@ -130,24 +130,24 @@ describe "Utils", -> frame[p].should.equal result[p], p compare [ - {x:0, y:0, width:100, height:100}, - {x:0, y:0, width:100, height:100}, - ], {x:0, y:0, width:100, height:100} + {x: 0, y: 0, width: 100, height: 100}, + {x: 0, y: 0, width: 100, height: 100}, + ], {x: 0, y: 0, width: 100, height: 100} compare [ - {x:0, y:0, width:100, height:100}, - {x:0, y:0, width:500, height:500}, - ], {x:0, y:0, width:500, height:500} + {x: 0, y: 0, width: 100, height: 100}, + {x: 0, y: 0, width: 500, height: 500}, + ], {x: 0, y: 0, width: 500, height: 500} compare [ - {x:0, y:0, width:100, height:100}, - {x:100, y:100, width:500, height:500}, - ], {x:0, y:0, width:600, height:600} + {x: 0, y: 0, width: 100, height: 100}, + {x: 100, y: 100, width: 500, height: 500}, + ], {x: 0, y: 0, width: 600, height: 600} compare [ - {x:100, y:100, width:100, height:100}, - {x:100, y:100, width:500, height:500}, - ], {x:100, y:100, width:500, height:500} + {x: 100, y: 100, width: 100, height: 100}, + {x: 100, y: 100, width: 500, height: 500}, + ], {x: 100, y: 100, width: 500, height: 500} # Bla bla. This works. Doing a visual comparison is so much easier # Start the cactus project and go to /test.html @@ -155,14 +155,14 @@ describe "Utils", -> describe "framePointForOrigin", -> it "should work", -> - Utils.framePointForOrigin({x:100, y:100, width:100, height:100}, 0, 0).should.eql( - {x:100, y:100, width:100, height:100}) - Utils.framePointForOrigin({x:100, y:100, width:100, height:100}, 0, 0).should.eql( - {x:100, y:100, width:100, height:100}) - Utils.framePointForOrigin({x:100, y:100, width:100, height:100}, 0, 0).should.eql( - {x:100, y:100, width:100, height:100}) - Utils.framePointForOrigin({x:100, y:100, width:100, height:100}, 0, 0).should.eql( - {x:100, y:100, width:100, height:100}) + Utils.framePointForOrigin({x: 100, y: 100, width: 100, height: 100}, 0, 0).should.eql( + {x: 100, y: 100, width: 100, height: 100}) + Utils.framePointForOrigin({x: 100, y: 100, width: 100, height: 100}, 0, 0).should.eql( + {x: 100, y: 100, width: 100, height: 100}) + Utils.framePointForOrigin({x: 100, y: 100, width: 100, height: 100}, 0, 0).should.eql( + {x: 100, y: 100, width: 100, height: 100}) + Utils.framePointForOrigin({x: 100, y: 100, width: 100, height: 100}, 0, 0).should.eql( + {x: 100, y: 100, width: 100, height: 100}) @@ -222,35 +222,35 @@ describe "Utils", -> # Todo: for some reason these don't work reliable in phantomjs text = "Hello Koen Bok" - style = {font:"20px/1em Menlo"} + style = {font: "20px/1em Menlo"} # it "should return the right size", -> - # Utils.textSize(text, style).should.eql({width:168, height:20}) + # Utils.textSize(text, style).should.eql({width: 168, height: 20}) # it "should return the right size with width constraint", -> - # Utils.textSize(text, style, {width:100}).should.eql({width:100, height:40}) + # Utils.textSize(text, style, {width: 100}).should.eql({width: 100, height: 40}) # it "should return the right size with height constraint", -> - # Utils.textSize(text, style, {height:100}).should.eql(width:168, height:100) + # Utils.textSize(text, style, {height: 100}).should.eql(width: 168, height: 100) describe "frameSortByAbsoluteDistance", -> it "should sort x", -> - layerA = new Layer x:300, y:100 - layerB = new Layer x:100, y:100 - layerC = new Layer x:200, y:100 + layerA = new Layer x: 300, y: 100 + layerB = new Layer x: 100, y: 100 + layerC = new Layer x: 200, y: 100 - Utils.frameSortByAbsoluteDistance({x:0, y:0}, [layerA, layerB, layerC]).should.eql([layerB, layerC, layerA]) + Utils.frameSortByAbsoluteDistance({x: 0, y: 0}, [layerA, layerB, layerC]).should.eql([layerB, layerC, layerA]) it "should sort", -> - layerA = new Layer x:500, y:500 - layerB = new Layer x:300, y:300 - layerC = new Layer x:100, y:100 + layerA = new Layer x: 500, y: 500 + layerB = new Layer x: 300, y: 300 + layerC = new Layer x: 100, y: 100 - Utils.frameSortByAbsoluteDistance({x:0, y:0}, [layerA, layerB, layerC]).should.eql([layerC, layerB, layerA]) + Utils.frameSortByAbsoluteDistance({x: 0, y: 0}, [layerA, layerB, layerC]).should.eql([layerC, layerB, layerA]) describe "inspect", -> @@ -274,7 +274,7 @@ describe "Utils", -> Utils.inspect(["a", 1, ["b", "c"]]).should.equal("[\"a\", 1, [\"b\", \"c\"]]") it "should work for objects", -> - Utils.inspect({a:1, b:[1, 2, 3]}).should.equal("{a:1, b:[1, 2, 3]}") + Utils.inspect({a: 1, b: [1, 2, 3]}).should.equal("{a:1, b:[1, 2, 3]}") it "should work for functions", -> test = -> return "a" diff --git a/test/tests/VideoLayerTest.coffee b/test/tests/VideoLayerTest.coffee index 5ddb64658..9cea31b79 100644 --- a/test/tests/VideoLayerTest.coffee +++ b/test/tests/VideoLayerTest.coffee @@ -6,5 +6,5 @@ describe "VideoLayer", -> if not Utils.isSafari() it "should create video", -> - videoLayer = new VideoLayer video:"../static/test.mp4" + videoLayer = new VideoLayer video: "../static/test.mp4" videoLayer.player.src.should.equal "../static/test.mp4" From 7afed27153be26e3f0e553799ef815745426c650 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 11:35:16 +0100 Subject: [PATCH 04/13] Spacing after comma --- coffeelint.json | 2 +- gulpfile.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index 43589e09b..958e11bdf 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -127,7 +127,7 @@ "level": "ignore" }, "spacing_after_comma": { - "level": "ignore" + "level": "error" }, "transform_messes_up_line_numbers": { "level": "warn" diff --git a/gulpfile.coffee b/gulpfile.coffee index 2ea0bce19..498543cc5 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -42,7 +42,7 @@ gulp.task "test", ["webpack:tests", "lint"], -> })) gulp.task 'lint', -> - gulp.src(["./framer/**","!./framer/Version.coffee.template","./test/tests/**","./test/tests.coffee","./gulpfile.coffee","scripts/site.coffee"]) + gulp.src(["./framer/**", "!./framer/Version.coffee.template", "./test/tests/**", "./test/tests.coffee", "./gulpfile.coffee", "scripts/site.coffee"]) .pipe(coffeelint()) .pipe(coffeelint.reporter()) From 552951e24dc29003eb7484ffe4275f283acbc3fe Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 11:45:50 +0100 Subject: [PATCH 05/13] =?UTF-8?q?Replace=20=3D=3D=20with=20=E2=80=98is?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framer/Color.coffee | 50 ++++++++++++------------ framer/Components/DeviceComponent.coffee | 18 ++++----- framer/Components/PageComponent.coffee | 8 ++-- framer/Components/ScrollComponent.coffee | 4 +- framer/Context.coffee | 2 +- framer/Extras/MobileScrollFix.coffee | 2 +- framer/GestureInputRecognizer.coffee | 12 +++--- framer/Importer.coffee | 2 +- framer/Layer.coffee | 10 ++--- framer/LayerDraggable.coffee | 4 +- framer/LayerStateMachine.coffee | 2 +- framer/LayerStyle.coffee | 2 +- framer/Utils.coffee | 6 +-- test/tests/LayerAnimationTest.coffee | 4 +- test/tests/LayerStatesTest.coffee | 2 +- 15 files changed, 64 insertions(+), 64 deletions(-) diff --git a/framer/Color.coffee b/framer/Color.coffee index 2da6531ad..602ff7b36 100644 --- a/framer/Color.coffee +++ b/framer/Color.coffee @@ -13,7 +13,7 @@ ColorType = class exports.Color extends BaseClass constructor: (@color, r, g, b) -> - if @color == "" + if @color is "" @color = null color = @color @@ -62,7 +62,7 @@ class exports.Color extends BaseClass return "#" + @toHex(allow3Char) toRgb: -> - if @_rgb == undefined + if @_rgb is undefined @_rgb = r: Math.round(@_r) g: Math.round(@_g) @@ -71,11 +71,11 @@ class exports.Color extends BaseClass return _.clone(@_rgb) toRgbString: -> - if @_a == 1 then "rgb(#{Utils.round(@_r, 0)}, #{Utils.round(@_g, 0)}, #{Utils.round(@_b, 0)})" + if @_a is 1 then "rgb(#{Utils.round(@_r, 0)}, #{Utils.round(@_g, 0)}, #{Utils.round(@_b, 0)})" else "rgba(#{Utils.round(@_r, 0)}, #{Utils.round(@_g, 0)}, #{Utils.round(@_b, 0)}, #{@_roundA})" toHsl: -> - if @_hsl == undefined + if @_hsl is undefined @_hsl = h: @h s: @s @@ -84,7 +84,7 @@ class exports.Color extends BaseClass return _.clone(@_hsl) toHusl: -> - if @_husl == undefined + if @_husl is undefined c = libhusl._conv husl = c.lch.husl c.luv.lch c.xyz.luv c.rgb.xyz([@r/255, @g/255, @b/255]) @_husl = {h: husl[0], s: husl[1], l: husl[2]} @@ -92,12 +92,12 @@ class exports.Color extends BaseClass return _.clone(@_husl) toHslString: -> - if @_hslString == undefined + if @_hslString is undefined hsl = @toHsl() h = Math.round(hsl.h) s = Math.round(hsl.s * 100) l = Math.round(hsl.l * 100) - if @_a == 1 + if @_a is 1 @_hslString = "hsl(#{h}, #{s}%, #{l}%)" else @_hslString = "hsla(#{h}, #{s}%, #{l}%, #{@_roundA})" @@ -110,7 +110,7 @@ class exports.Color extends BaseClass for key in _.keys cssNames value = cssNames[key] - if value == hex + if value is hex return key return false @@ -173,9 +173,9 @@ class exports.Color extends BaseClass return Color.equal(@, colorB) toInspect: => - if @_type == ColorType.HSL + if @_type is ColorType.HSL return "<#{@constructor.name} h:#{@h} s:#{@s} l:#{@l} a:#{@a}>" - else if @_type == ColorType.HEX || @_type == ColorType.NAME + else if @_type is ColorType.HEX || @_type is ColorType.NAME return "<#{@constructor.name} \"#{@color}\">" else return "<#{@constructor.name} r:#{@r} g:#{@g} b:#{@b} a:#{@a}>" @@ -195,11 +195,11 @@ class exports.Color extends BaseClass if colorA not instanceof Color and colorB instanceof Color colorA = colorB.transparent() - else if colorA instanceof Color and colorA._a == 0 and colorB instanceof Color and colorB._a isnt 0 + else if colorA instanceof Color and colorA._a is 0 and colorB instanceof Color and colorB._a isnt 0 colorA = colorB.transparent() else if colorB not instanceof Color and colorA instanceof Color colorB = colorA.transparent() - else if colorB instanceof Color and colorB._a == 0 and colorA instanceof Color and colorA._a isnt 0 + else if colorB instanceof Color and colorB._a is 0 and colorA instanceof Color and colorA._a isnt 0 colorB = colorA.transparent() if colorB instanceof Color @@ -227,9 +227,9 @@ class exports.Color extends BaseClass hslA = colorA.toHusl() hslB = colorB.toHusl() - if hslA.s == 0 + if hslA.s is 0 hslA.h = hslB.h - else if hslB.s == 0 + else if hslB.s is 0 hslB.h = hslA.h fromH = hslA.h @@ -267,7 +267,7 @@ class exports.Color extends BaseClass @gray: (args...) -> @grey(args...) @toColor: (color) -> return new Color(color) - @validColorValue: (color) -> return color instanceof Color or color == null + @validColorValue: (color) -> return color instanceof Color or color is null @isColor: (color) -> if _.isString(color) @@ -345,7 +345,7 @@ inputData = (color, g, b, alpha) -> ok = false type = ColorType.RGB - if color == null + if color is null a = 0 else if _.isNumber(color) rgb.r = color @@ -358,7 +358,7 @@ inputData = (color, g, b, alpha) -> a = alpha else - if typeof color == "string" + if typeof color is "string" color = stringToObject(color) if !color @@ -371,7 +371,7 @@ inputData = (color, g, b, alpha) -> if color.hasOwnProperty("type") type = color.type - if typeof color == "object" + if typeof color is "object" if color.hasOwnProperty("r") or color.hasOwnProperty("g") or color.hasOwnProperty("b") rgb = rgbToRgb(color.r, color.g, color.b) @@ -429,7 +429,7 @@ rgbToHex = (r, g, b, allow3Char) -> pad2(Math.round(g).toString(16)) pad2(Math.round(b).toString(16)) ] - if allow3Char and hex[0].charAt(0) == hex[0].charAt(1) and hex[1].charAt(0) == hex[1].charAt(1) and hex[2].charAt(0) == hex[2].charAt(1) + if allow3Char and hex[0].charAt(0) is hex[0].charAt(1) and hex[1].charAt(0) is hex[1].charAt(1) and hex[2].charAt(0) is hex[2].charAt(1) return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) hex.join "" @@ -443,7 +443,7 @@ rgbToHsl = (r, g, b) -> min = Math.min(r, g, b) h = s = l = (max + min) / 2 - if max == min then h = s = 0 + if max is min then h = s = 0 else d = max - min s = if l > 0.5 then d / (2 - max - min) else d / (max + min) @@ -472,7 +472,7 @@ hslToRgb = (h, s, l) -> if t < 2 / 3 then return p + (q - p) * (2 / 3 - t) * 6 return p - if s == 0 + if s is 0 r = g = b = l # Achromatic else @@ -516,15 +516,15 @@ bound01 = (n, max) -> isOnePointZero = (n) -> - return typeof n == "string" and n.indexOf(".") isnt -1 and parseFloat(n) == 1 + return typeof n is "string" and n.indexOf(".") isnt -1 and parseFloat(n) is 1 # Check to see if string passed in is a percentage isPercentage = (n) -> - return typeof n == "string" and n.indexOf("%") isnt -1 + return typeof n is "string" and n.indexOf("%") isnt -1 # Force hex to have 2 characters. pad2 = (char) -> - if char.length == 1 then "0" + char + if char.length is 1 then "0" + char else "" + char # Matchers @@ -563,7 +563,7 @@ stringToObject = (color) -> named = true type: ColorType.NAME - else if color == "transparent" + else if color is "transparent" return { r: 0 g: 0 diff --git a/framer/Components/DeviceComponent.coffee b/framer/Components/DeviceComponent.coffee index dd8b0967d..d0f6253e1 100644 --- a/framer/Components/DeviceComponent.coffee +++ b/framer/Components/DeviceComponent.coffee @@ -157,7 +157,7 @@ class exports.DeviceComponent extends BaseClass @content.height = height @screen.center() - @setHand(@selectedHand) if @selectedHand && @_orientation == 0 + @setHand(@selectedHand) if @selectedHand && @_orientation is 0 _shouldRenderFullScreen: -> @@ -259,7 +259,7 @@ class exports.DeviceComponent extends BaseClass lDevicetype = deviceType.toLowerCase() for key in _.keys(Devices) lKey = key.toLowerCase() - device = Devices[key] if lDevicetype == lKey + device = Devices[key] if lDevicetype is lKey if not device throw Error "No device named #{deviceType}. Options are: #{_.keys Devices}" @@ -360,12 +360,12 @@ class exports.DeviceComponent extends BaseClass setDeviceScale: (deviceScale, animate=false) -> - if deviceScale == "fit" or deviceScale < 0 + if deviceScale is "fit" or deviceScale < 0 deviceScale = "fit" else deviceScale = parseFloat(deviceScale) - if deviceScale == @_deviceScale + if deviceScale is @_deviceScale return @_deviceScale = deviceScale @@ -373,7 +373,7 @@ class exports.DeviceComponent extends BaseClass if @_shouldRenderFullScreen() return - if deviceScale == "fit" + if deviceScale is "fit" phoneScale = @_calculatePhoneScale() else phoneScale = deviceScale @@ -455,12 +455,12 @@ class exports.DeviceComponent extends BaseClass setOrientation: (orientation, animate=false) -> - orientation *= -1 if Utils.framerStudioVersion() == oldDeviceMaxVersion + orientation *= -1 if Utils.framerStudioVersion() is oldDeviceMaxVersion - if orientation == "portrait" + if orientation is "portrait" orientation = 0 - if orientation == "landscape" + if orientation is "landscape" orientation = 90 if @_shouldRenderFullScreen() @@ -512,7 +512,7 @@ class exports.DeviceComponent extends BaseClass @content.height = height offset = (@screen.width - width) / 2 - offset *= -1 if @_orientation == -90 + offset *= -1 if @_orientation is -90 [x, y] = [0, 0] diff --git a/framer/Components/PageComponent.coffee b/framer/Components/PageComponent.coffee index 6c1112453..8352b12fa 100644 --- a/framer/Components/PageComponent.coffee +++ b/framer/Components/PageComponent.coffee @@ -141,11 +141,11 @@ class exports.PageComponent extends ScrollComponent # See if we meet the minimum velocity to scroll to the next page. If not we snap # to the layer closest to the scroll point. - xDisabled = !@scrollHorizontal and (@direction == "right" or @direction == "left") - yDisabled = !@scrollVertical and (@direction == "down" or @direction == "up") + xDisabled = !@scrollHorizontal and (@direction is "right" or @direction is "left") + yDisabled = !@scrollVertical and (@direction is "down" or @direction is "up") - xLock = @content.draggable._directionLockEnabledX and (@direction == "right" or @direction == "left") - yLock = @content.draggable._directionLockEnabledY and (@direction == "down" or @direction == "up") + xLock = @content.draggable._directionLockEnabledX and (@direction is "right" or @direction is "left") + yLock = @content.draggable._directionLockEnabledY and (@direction is "down" or @direction is "up") maximumVelocity = Math.max(Math.abs(velocity.x), Math.abs(velocity.y)) diff --git a/framer/Components/ScrollComponent.coffee b/framer/Components/ScrollComponent.coffee index f8f69bd2b..7c6f17a8d 100644 --- a/framer/Components/ScrollComponent.coffee +++ b/framer/Components/ScrollComponent.coffee @@ -288,7 +288,7 @@ class exports.ScrollComponent extends Layer if contentLayer and contentLayer.parent isnt @content throw Error("Can't scroll to this layer because it's not in the ScrollComponent. Add it to the content like layer.parent = scroll.content.") - if not contentLayer or @content.children.length == 0 + if not contentLayer or @content.children.length is 0 scrollPoint = {x: 0, y: 0} else scrollPoint = @_scrollPointForLayer(contentLayer, originX, originY) @@ -381,7 +381,7 @@ class exports.ScrollComponent extends Layer if @scrollVertical deltaY = event.wheelDeltaY - if deltaX == 0 and deltaY == 0 + if deltaX is 0 and deltaY is 0 return if not @_mouseWheelScrolling diff --git a/framer/Context.coffee b/framer/Context.coffee index 80a211722..2dc52dea8 100644 --- a/framer/Context.coffee +++ b/framer/Context.coffee @@ -364,7 +364,7 @@ class exports.Context extends BaseClass toInspect: -> round = (value) -> - if parseInt(value) == value + if parseInt(value) is value return parseInt(value) return Utils.round(value, 1) diff --git a/framer/Extras/MobileScrollFix.coffee b/framer/Extras/MobileScrollFix.coffee index 937f93396..3940b00e2 100644 --- a/framer/Extras/MobileScrollFix.coffee +++ b/framer/Extras/MobileScrollFix.coffee @@ -34,7 +34,7 @@ exports.enable = -> # Only do this for bare layers, it messes with the # Scroll and Page Component for now. - if @constructor.name == "Layer" + if @constructor.name is "Layer" @on "change:scrollVertical", @_updateScrollListeners @_updateScrollListeners() diff --git a/framer/GestureInputRecognizer.coffee b/framer/GestureInputRecognizer.coffee index 2c3bf8d88..b0fa6959d 100644 --- a/framer/GestureInputRecognizer.coffee +++ b/framer/GestureInputRecognizer.coffee @@ -76,9 +76,9 @@ class exports.GestureInputRecognizer if event.touches? if Utils.isTouch() - return unless (event.touches.length == 0) + return unless (event.touches.length is 0) else - return unless (event.touches.length == event.changedTouches.length) + return unless (event.touches.length is event.changedTouches.length) @em.wrap(window).removeEventListener("mousemove", @touchmove) @em.wrap(window).removeEventListener("mouseup", @touchend) @@ -298,10 +298,10 @@ class exports.GestureInputRecognizer # Detect pinch, rotate and scale events # Stop panning if we go from 2 to 1 finger - if @session.started.pinch and event.fingers == 1 + if @session.started.pinch and event.fingers is 1 @pinchend(event) # If we did not start yet and get two fingers, start - else if not @session.started.pinch and event.fingers == 2 + else if not @session.started.pinch and event.fingers is 2 @pinchstart(event) # If we did start send pinch events else if @session.started.pinch @@ -406,10 +406,10 @@ class exports.GestureInputRecognizer # For delta we switch to center-compare if there are two fingers if @session?.lastEvent # If we just switched fingers, we skip the delta event entirely - if event.fingers isnt @session.lastEvent.fingers == 2 + if event.fingers isnt @session.lastEvent.fingers is 2 event.delta = {x: 0, y: 0} # If we are having two finger events, we use the touchCenter as base for delta - if event.fingers == 2 and @session.lastEvent.fingers == 2 + if event.fingers is 2 and @session.lastEvent.fingers is 2 event.delta = Utils.pointSubtract(event.touchCenter, @session.lastEvent.touchCenter) # Force touch diff --git a/framer/Importer.coffee b/framer/Importer.coffee index 94e80fb03..1aef8b082 100644 --- a/framer/Importer.coffee +++ b/framer/Importer.coffee @@ -8,7 +8,7 @@ open -a Google\ Chrome -–allow-file-access-from-files resizeFrame = (scale, frame) -> - return frame if scale == 1 + return frame if scale is 1 result = {} diff --git a/framer/Layer.coffee b/framer/Layer.coffee index 0ca5f872f..1f3a840ae 100644 --- a/framer/Layer.coffee +++ b/framer/Layer.coffee @@ -610,8 +610,8 @@ class exports.Layer extends BaseClass # then we turn off ignoreEvents so buttons etc will work. # if not ( - # @_elementHTML.childNodes.length == 1 and - # @_elementHTML.childNodes[0].nodeName == "#text") + # @_elementHTML.childNodes.length is 1 and + # @_elementHTML.childNodes[0].nodeName is "#text") # @ignoreEvents = false @emit "change:html" @@ -671,7 +671,7 @@ class exports.Layer extends BaseClass currentValue = @_getPropertyValue "image" - if currentValue == value + if currentValue is value return @emit "load" # Unset the background color only if it’s the default color @@ -817,10 +817,10 @@ class exports.Layer extends BaseClass layer.parent = null childrenWithName: (name) -> - _.filter @children, (layer) -> layer.name == name + _.filter @children, (layer) -> layer.name is name siblingsWithName: (name) -> - _.filter @siblingLayers, (layer) -> layer.name == name + _.filter @siblingLayers, (layer) -> layer.name is name ancestors: (context=false) -> diff --git a/framer/LayerDraggable.coffee b/framer/LayerDraggable.coffee index 27ee9f983..cd5fd958b 100644 --- a/framer/LayerDraggable.coffee +++ b/framer/LayerDraggable.coffee @@ -355,8 +355,8 @@ class exports.LayerDraggable extends BaseClass x: Utils.clamp(proposedPoint.x, minX, maxX) y: Utils.clamp(proposedPoint.y, minY, maxY) - point.x = proposedPoint.x if @speedX == 0 or @horizontal is false - point.y = proposedPoint.y if @speedY == 0 or @vertical is false + point.x = proposedPoint.x if @speedX is 0 or @horizontal is false + point.y = proposedPoint.y if @speedY is 0 or @vertical is false return point diff --git a/framer/LayerStateMachine.coffee b/framer/LayerStateMachine.coffee index 1d2d57238..baf8dfb67 100644 --- a/framer/LayerStateMachine.coffee +++ b/framer/LayerStateMachine.coffee @@ -36,7 +36,7 @@ class exports.LayerStateMachine extends BaseClass # Check if the state exists, if not this is a pretty serious error throw Error "No such state: '#{stateName}'" unless @states[stateName] - if stateName == "previous" + if stateName is "previous" stateName = @previousName # Prep the properties and the options. The options come from the state, and can be overriden diff --git a/framer/LayerStyle.coffee b/framer/LayerStyle.coffee index 879abe9a8..e17f1b8b8 100644 --- a/framer/LayerStyle.coffee +++ b/framer/LayerStyle.coffee @@ -163,7 +163,7 @@ exports.LayerStyle = if not props.shadowColor return "" - else if props.shadowX == 0 and props.shadowY == 0 and props.shadowBlur == 0 and props.shadowSpread == 0 + else if props.shadowX is 0 and props.shadowY is 0 and props.shadowBlur is 0 and props.shadowSpread is 0 return "" return "#{layer._properties.shadowX}px #{layer._properties.shadowY}px #{layer._properties.shadowBlur}px #{layer._properties.shadowSpread}px #{layer._properties.shadowColor}" diff --git a/framer/Utils.coffee b/framer/Utils.coffee index cd794776d..821772c59 100644 --- a/framer/Utils.coffee +++ b/framer/Utils.coffee @@ -25,10 +25,10 @@ Utils.setValueForKeyPath = (obj, path, val) -> n = fields.length while i < n and result isnt undefined field = fields[i] - if i == n - 1 + if i is n - 1 result[field] = val else - if typeof result[field] == "undefined" or !_.isObject(result[field]) + if typeof result[field] is "undefined" or !_.isObject(result[field]) result[field] = {} result = result[field] i++ @@ -271,7 +271,7 @@ Utils.uuid = -> random = 0x2000000 + (Math.random() * 0x1000000) | 0 if (random <= 0x02) r = random & 0xf random = random >> 4 - output[digit] = chars[if digit == 19 then (r & 0x3) | 0x8 else r] + output[digit] = chars[if digit is 19 then (r & 0x3) | 0x8 else r] output.join "" diff --git a/test/tests/LayerAnimationTest.coffee b/test/tests/LayerAnimationTest.coffee index 0762b0e72..27713f205 100644 --- a/test/tests/LayerAnimationTest.coffee +++ b/test/tests/LayerAnimationTest.coffee @@ -379,7 +379,7 @@ describe "LayerAnimation", -> time: AnimationTime count = 0 - test = -> count++; done() if count == 2 + test = -> count++; done() if count is 2 animation.on "end", test layer.on "end", test @@ -398,7 +398,7 @@ describe "LayerAnimation", -> time: AnimationTime * 2 count = 0 - test = -> count++; done() if count == 2 + test = -> count++; done() if count is 2 animation.on "stop", test layer.on "stop", test diff --git a/test/tests/LayerStatesTest.coffee b/test/tests/LayerStatesTest.coffee index bbb1f01d4..57c792b77 100644 --- a/test/tests/LayerStatesTest.coffee +++ b/test/tests/LayerStatesTest.coffee @@ -269,7 +269,7 @@ describe "LayerStates", -> count = 0 ready = (animation, layer) -> - if count == 4 + if count is 4 done() return count++ From 85a3dae9e1a36eee3797b5590c92e46dcdcb7107 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 12:01:44 +0100 Subject: [PATCH 06/13] Using english logic operators --- coffeelint.json | 4 ++-- framer/Animation.coffee | 4 ++-- framer/Color.coffee | 14 +++++++------- framer/Components/DeviceComponent.coffee | 10 +++++----- framer/Components/PageComponent.coffee | 6 +++--- framer/LayerStyle.coffee | 2 +- framer/Simulators/MomentumBounceSimulator.coffee | 10 +++++----- framer/Utils.coffee | 14 +++++++------- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index 958e11bdf..e602d4010 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -120,8 +120,8 @@ "level": "ignore" }, "prefer_english_operator": { - "level": "ignore", - "doubleNotLevel": "ignore" + "level": "warn", + "doubleNotLevel": "warn" }, "space_operators": { "level": "ignore" diff --git a/framer/Animation.coffee b/framer/Animation.coffee index 2d9f4f18a..7d862169d 100644 --- a/framer/Animation.coffee +++ b/framer/Animation.coffee @@ -92,7 +92,7 @@ class exports.Animation extends BaseClass get: -> @options.looping set: (value) -> @options?.looping = value - if @options?.looping and @layer? and !@isAnimating + if @options?.looping and @layer? and not @isAnimating @restart() @define "isNoop", @simpleProperty("isNoop", false) @@ -161,7 +161,7 @@ class exports.Animation extends BaseClass # Todo: more repeat behaviours: # 1) add (from end position) 2) reverse (loop between a and b) @once "end", => - if @_repeatCounter > 0 || @looping + if @_repeatCounter > 0 or @looping @restart() if not @looping @_repeatCounter-- diff --git a/framer/Color.coffee b/framer/Color.coffee index 602ff7b36..028529410 100644 --- a/framer/Color.coffee +++ b/framer/Color.coffee @@ -175,7 +175,7 @@ class exports.Color extends BaseClass toInspect: => if @_type is ColorType.HSL return "<#{@constructor.name} h:#{@h} s:#{@s} l:#{@l} a:#{@a}>" - else if @_type is ColorType.HEX || @_type is ColorType.NAME + else if @_type is ColorType.HEX or @_type is ColorType.NAME return "<#{@constructor.name} \"#{@color}\">" else return "<#{@constructor.name} r:#{@r} g:#{@g} b:#{@b} a:#{@a}>" @@ -292,12 +292,12 @@ class exports.Color extends BaseClass @equal: (colorA, colorB) -> - if !@validColorValue(colorA) - if !Color.isColorString(colorA) + if not @validColorValue(colorA) + if not Color.isColorString(colorA) return false - if !@validColorValue(colorB) - if !Color.isColorString(colorB) + if not @validColorValue(colorB) + if not Color.isColorString(colorB) return false colorA = new Color(colorA) @@ -361,7 +361,7 @@ inputData = (color, g, b, alpha) -> if typeof color is "string" color = stringToObject(color) - if !color + if not color color = r: 0 g: 0 @@ -545,7 +545,7 @@ matchers = do -> } isNumeric = (value) -> - return !isNaN(value) && isFinite(value) + return not isNaN(value) and isFinite(value) percentToFraction = (percentage) -> return numberFromString(percentage) / 100 diff --git a/framer/Components/DeviceComponent.coffee b/framer/Components/DeviceComponent.coffee index d0f6253e1..394375cb7 100644 --- a/framer/Components/DeviceComponent.coffee +++ b/framer/Components/DeviceComponent.coffee @@ -157,7 +157,7 @@ class exports.DeviceComponent extends BaseClass @content.height = height @screen.center() - @setHand(@selectedHand) if @selectedHand && @_orientation is 0 + @setHand(@selectedHand) if @selectedHand and @_orientation is 0 _shouldRenderFullScreen: -> @@ -334,8 +334,8 @@ class exports.DeviceComponent extends BaseClass # If we're running Framer Studio and have local files, we'd like to use those. # For now we always use jp2 inside framer stusio if Utils.isFramerStudio() and window.FramerStudioInfo - if @_device.minStudioVersion and Utils.framerStudioVersion() >= @_device.minStudioVersion or !@_device.minStudioVersion - if @_device.maxStudioVersion and Utils.framerStudioVersion() <= @_device.maxStudioVersion or !@_device.maxStudioVersion + if @_device.minStudioVersion and Utils.framerStudioVersion() >= @_device.minStudioVersion or not @_device.minStudioVersion + if @_device.maxStudioVersion and Utils.framerStudioVersion() <= @_device.maxStudioVersion or not @_device.maxStudioVersion resourceUrl = window.FramerStudioInfo.deviceImagesUrl return "#{resourceUrl}/#{name.replace(".png", ".jp2")}" @@ -531,7 +531,7 @@ class exports.DeviceComponent extends BaseClass @emit("change:orientation", window.orientation) @define "isPortrait", get: -> Math.abs(@orientation) % 180 is 0 - @define "isLandscape", get: -> !@isPortrait + @define "isLandscape", get: -> not @isPortrait @define "orientationName", get: -> @@ -571,7 +571,7 @@ class exports.DeviceComponent extends BaseClass setHand: (hand) -> @selectedHand = hand - return @handsImageLayer.image = "" if !hand or !@handSwitchingSupported() + return @handsImageLayer.image = "" if not hand or not @handSwitchingSupported() handData = @_device.hands[hand] if handData diff --git a/framer/Components/PageComponent.coffee b/framer/Components/PageComponent.coffee index 8352b12fa..daadb992f 100644 --- a/framer/Components/PageComponent.coffee +++ b/framer/Components/PageComponent.coffee @@ -50,7 +50,7 @@ class exports.PageComponent extends ScrollComponent # Figure out the point from where to look for next layers in a direction point = {x: 0, y: 0} point = Utils.framePointForOrigin(currentPage, @originX, @originY) if currentPage - if !withoutCurrentPage + if not withoutCurrentPage point = {x: @scrollX + (@originX * @width), y: @scrollY + (@originY * @height)} layers = @content.childrenAbove(point, @originX, @originY) if direction in ["up", "top", "north"] @@ -141,8 +141,8 @@ class exports.PageComponent extends ScrollComponent # See if we meet the minimum velocity to scroll to the next page. If not we snap # to the layer closest to the scroll point. - xDisabled = !@scrollHorizontal and (@direction is "right" or @direction is "left") - yDisabled = !@scrollVertical and (@direction is "down" or @direction is "up") + xDisabled = not @scrollHorizontal and (@direction is "right" or @direction is "left") + yDisabled = not @scrollVertical and (@direction is "down" or @direction is "up") xLock = @content.draggable._directionLockEnabledX and (@direction is "right" or @direction is "left") yLock = @content.draggable._directionLockEnabledY and (@direction is "down" or @direction is "up") diff --git a/framer/LayerStyle.coffee b/framer/LayerStyle.coffee index e17f1b8b8..ab1094346 100644 --- a/framer/LayerStyle.coffee +++ b/framer/LayerStyle.coffee @@ -3,7 +3,7 @@ filterFormat = (value, unit) -> # "#{value}#{unit}" roundToZero = (num) -> - if (-1e-6 < num && num < 1e-6) + if (-1e-6 < num and num < 1e-6) return 0 return num diff --git a/framer/Simulators/MomentumBounceSimulator.coffee b/framer/Simulators/MomentumBounceSimulator.coffee index d473f536d..365da3929 100644 --- a/framer/Simulators/MomentumBounceSimulator.coffee +++ b/framer/Simulators/MomentumBounceSimulator.coffee @@ -70,10 +70,10 @@ class exports.MomentumBounceSimulator extends Simulator # further away, then transition from friction to spring simulation _tryTransitionToSpring: (force) -> - belowMinWithVelocity = @_state.x < @options.min && @_state.v <= 0 - aboveMaxWithVelocity = @_state.x > @options.max && @_state.v >= 0 + belowMinWithVelocity = @_state.x < @options.min and @_state.v <= 0 + aboveMaxWithVelocity = @_state.x > @options.max and @_state.v >= 0 - if (belowMinWithVelocity || aboveMaxWithVelocity) + if (belowMinWithVelocity or aboveMaxWithVelocity) bound = @options.min if belowMinWithVelocity bound = @options.max if aboveMaxWithVelocity @_transitionToSpring(bound) @@ -93,8 +93,8 @@ class exports.MomentumBounceSimulator extends Simulator # Note that if velocity is 0, the state is still valid (should use spring, # not friction), and we don't want to divide by 0 later in the check. - belowMinTravelingBack = @_state.x < @options.min && @_state.v > 0 - aboveMaxTravelingBack = @_state.x > @options.max && @_state.v < 0 + belowMinTravelingBack = @_state.x < @options.min and @_state.v > 0 + aboveMaxTravelingBack = @_state.x > @options.max and @_state.v < 0 check = false diff --git a/framer/Utils.coffee b/framer/Utils.coffee index 821772c59..36178f353 100644 --- a/framer/Utils.coffee +++ b/framer/Utils.coffee @@ -28,7 +28,7 @@ Utils.setValueForKeyPath = (obj, path, val) -> if i is n - 1 result[field] = val else - if typeof result[field] is "undefined" or !_.isObject(result[field]) + if typeof result[field] is "undefined" or not _.isObject(result[field]) result[field] = {} result = result[field] i++ @@ -177,8 +177,8 @@ Utils.defineEnum = (names = [], offset = 0, geometric = 0) -> Enum = {} for name, i in names j = i - j = if ! offset then j else j + offset - j = if ! geometric then j else Math.pow geometric, j + j = if not offset then j else j + offset + j = if not geometric then j else Math.pow geometric, j Enum[Enum[name] = j] = name return Enum @@ -357,7 +357,7 @@ Utils.isDataUrl = (url) -> return _.startsWith(url, "data:") Utils.isRelativeUrl = (url) -> - !/^([a-zA-Z]{1,8}:\/\/).*$/.test(url) + not /^([a-zA-Z]{1,8}:\/\/).*$/.test(url) Utils.isLocalServerUrl = (url) -> return url.indexOf("127.0.0.1") isnt -1 or url.indexOf("localhost") isnt -1 @@ -475,7 +475,7 @@ Utils.modulate = (value, rangeA, rangeB, limit=false) -> [toLow, toHigh] = rangeB # if rangeB consists of Colors we return a color tween - # if Color.isColor(toLow) || _.isString(toLow) && Color.isColorString(toLow) + # if Color.isColor(toLow) or _.isString(toLow) and Color.isColorString(toLow) # ratio = Utils.modulate(value, rangeA, [0, 1]) # result = Color.mix(toLow, toHigh, ratio) # return result @@ -926,7 +926,7 @@ Utils.pointInPolygon = (point, vs) -> yj = vs[j][1] intersect = yi > y isnt yj > y and x < (xj - xi) * (y - yi) / (yj - yi) + xi if intersect - inside = !inside + inside = not inside j = i++ inside @@ -1104,7 +1104,7 @@ Utils.textSize = (text, style={}, constraints={}) -> # returns the rendered text size. This can be pretty slow, so use sporadically. # http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript - shouldCreateNode = !_textSizeNode + shouldCreateNode = not _textSizeNode if shouldCreateNode _textSizeNode = document.createElement("div") From 989b7a78f22728f56efe00656ac70b4278c33b15 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 12:02:06 +0100 Subject: [PATCH 07/13] Unnecessary fat arrows cause errors --- coffeelint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coffeelint.json b/coffeelint.json index e602d4010..66fd35c4b 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -114,7 +114,7 @@ "level": "ignore" }, "no_unnecessary_fat_arrows": { - "level": "warn" + "level": "error" }, "non_empty_constructor_needs_parens": { "level": "ignore" From a28ffe3b1a9bb7c51a105ed82a69736a81576152 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 12:06:29 +0100 Subject: [PATCH 08/13] Newline at end of file --- coffeelint.json | 2 +- framer/SVGLayer.coffee | 6 +++--- framer/Underscore.coffee | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index 66fd35c4b..a733d66d1 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -34,7 +34,7 @@ "level": "warn" }, "eol_last": { - "level": "ignore" + "level": "warn" }, "indentation": { "value": 1, diff --git a/framer/SVGLayer.coffee b/framer/SVGLayer.coffee index 429950b01..a2af9d9cc 100644 --- a/framer/SVGLayer.coffee +++ b/framer/SVGLayer.coffee @@ -3,12 +3,12 @@ {Layer} = require "./Layer" class exports.SVGLayer extends Layer - + constructor: (options={}) -> super _.defaults options, backgroundColor: null - + @svg = document.createElementNS("http://www.w3.org/2000/svg", "svg") @svg.setAttribute("width", "100%") @svg.setAttribute("height", "100%") @@ -17,4 +17,4 @@ class exports.SVGLayer extends Layer addShape: (type) -> shape = document.createElementNS("http://www.w3.org/2000/svg", "circle") @svg.appendChild(shape) - return shape \ No newline at end of file + return shape diff --git a/framer/Underscore.coffee b/framer/Underscore.coffee index e4fe13992..d9d422483 100644 --- a/framer/Underscore.coffee +++ b/framer/Underscore.coffee @@ -3,4 +3,4 @@ exports._ = require "lodash" # Backwards compatibility for older lodash -_.pluck = _.map \ No newline at end of file +_.pluck = _.map From a5a751e3cf52964728a22809e706fd8c0ac50c56 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 12:10:41 +0100 Subject: [PATCH 09/13] Newlines after classes --- coffeelint.json | 4 ++-- framer/Components/ScrollComponent.coffee | 1 + framer/Context.coffee | 6 ++---- framer/DOMEventManager.coffee | 1 + framer/Extras/MobileScrollFix.coffee | 1 + framer/Extras/ShareInfo.coffee | 1 + framer/LayerAnchor.coffee | 2 +- framer/LayerDraggable.coffee | 1 + framer/Simulator.coffee | 1 + 9 files changed, 11 insertions(+), 7 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index a733d66d1..e1211820c 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -54,8 +54,8 @@ "is_strict": false }, "newlines_after_classes": { - "value": 3, - "level": "ignore" + "value": 2, + "level": "warn" }, "no_backticks": { "level": "error" diff --git a/framer/Components/ScrollComponent.coffee b/framer/Components/ScrollComponent.coffee index 7c6f17a8d..df91547a4 100644 --- a/framer/Components/ScrollComponent.coffee +++ b/framer/Components/ScrollComponent.coffee @@ -71,6 +71,7 @@ class exports.ScrollComponent extends Layer exportable: false get: -> @_content + @define "mouseWheelSpeedMultiplier", @simpleProperty("mouseWheelSpeedMultiplier", 1) constructor: (options={}) -> diff --git a/framer/Context.coffee b/framer/Context.coffee index 2dc52dea8..d11c6c9e0 100644 --- a/framer/Context.coffee +++ b/framer/Context.coffee @@ -37,11 +37,9 @@ class exports.Context extends BaseClass @all = -> return _.clone(Contexts) - @define "parent", - get: -> @_parent + @define "parent", get: -> @_parent - @define "element", - get: -> @_element + @define "element", get: -> @_element constructor: (options={}) -> diff --git a/framer/DOMEventManager.coffee b/framer/DOMEventManager.coffee index f0ae5ff5f..38319501e 100644 --- a/framer/DOMEventManager.coffee +++ b/framer/DOMEventManager.coffee @@ -26,6 +26,7 @@ class DOMEventManagerElement extends EventEmitter on: @::addListener off: @::removeListener + class exports.DOMEventManager constructor: (element) -> diff --git a/framer/Extras/MobileScrollFix.coffee b/framer/Extras/MobileScrollFix.coffee index 3940b00e2..3f34b3e28 100644 --- a/framer/Extras/MobileScrollFix.coffee +++ b/framer/Extras/MobileScrollFix.coffee @@ -53,5 +53,6 @@ exports.enable = -> else super + # Override the standard window Layer with this patched one window.Layer = window.Framer.Layer = MobileScrollFixLayer diff --git a/framer/Extras/ShareInfo.coffee b/framer/Extras/ShareInfo.coffee index 3b4b7e6a4..4344a4d39 100644 --- a/framer/Extras/ShareInfo.coffee +++ b/framer/Extras/ShareInfo.coffee @@ -25,6 +25,7 @@ class ShareInfo extends BaseClass destroy: -> @context.destroy() + exports.enable = -> return if ShareInfoDisabled Framer.ShareInfo ?= new ShareInfo() diff --git a/framer/LayerAnchor.coffee b/framer/LayerAnchor.coffee index c68aa1997..66aaa151a 100644 --- a/framer/LayerAnchor.coffee +++ b/framer/LayerAnchor.coffee @@ -46,7 +46,6 @@ calculateFrame = (layer, rules) -> return frame - class LayerAnchor extends EventEmitter constructor: (@layer, rules) -> @@ -90,4 +89,5 @@ class LayerAnchor extends EventEmitter _parseRules: -> return Utils.parseRect(Utils.arrayFromArguments(arguments)) + exports.LayerAnchor = LayerAnchor diff --git a/framer/LayerDraggable.coffee b/framer/LayerDraggable.coffee index cd5fd958b..b5cbc92ec 100644 --- a/framer/LayerDraggable.coffee +++ b/framer/LayerDraggable.coffee @@ -67,6 +67,7 @@ class exports.LayerDraggable extends BaseClass @_constraints = {x: 0, y: 0, width: 0, height: 0} @_updateSimulationConstraints(@_constraints) if @_constraints + # The isDragging only is true when there was actual movement, so you can # use it to determine a click from a drag event. @define "isDragging", get: -> @_isDragging or false diff --git a/framer/Simulator.coffee b/framer/Simulator.coffee index 7919e4e5f..f7aca01bd 100644 --- a/framer/Simulator.coffee +++ b/framer/Simulator.coffee @@ -15,6 +15,7 @@ class exports.Simulator extends BaseClass get: -> _.clone(@_state) set: (state) -> @_state = _.clone(state) + constructor: (options={}) -> @_state = {x: 0, v: 0} @options = null From a48038c7da1d0f0bb3d2ff2f5d8fba9a03fa18d4 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Wed, 2 Nov 2016 12:12:55 +0100 Subject: [PATCH 10/13] No empty params list --- coffeelint.json | 2 +- test/tests/BaseClassTest.coffee | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coffeelint.json b/coffeelint.json index e1211820c..f366d5ed0 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -68,7 +68,7 @@ "level": "ignore" }, "no_empty_param_list": { - "level": "ignore" + "level": "error" }, "no_implicit_braces": { "level": "ignore", diff --git a/test/tests/BaseClassTest.coffee b/test/tests/BaseClassTest.coffee index 5ef98e7ba..17279f076 100644 --- a/test/tests/BaseClassTest.coffee +++ b/test/tests/BaseClassTest.coffee @@ -153,7 +153,7 @@ describe "BaseClass", -> class TestClass extends Framer.BaseClass @define "testProp", - get: () -> "value" + get: -> "value" exportable: false instance = new TestClass() @@ -171,7 +171,7 @@ describe "BaseClass", -> class TestClass extends Framer.BaseClass @define "testProp", - get: () -> "value" + get: -> "value" enumerable: false instance = new TestClass() @@ -184,7 +184,7 @@ describe "BaseClass", -> it.skip "should throw on assignment of read-only prop", -> class TestClass extends Framer.BaseClass @define "testProp", - get: () -> "value" + get: -> "value" instance = new TestClass() (-> instance.testProp = "foo").should.throw "TestClass.testProp is readonly" From fe21d292842a683ce707e9104c325456b65e8505 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Thu, 3 Nov 2016 15:21:30 +0100 Subject: [PATCH 11/13] Making files conform to linter --- framer/LayerDraggable.coffee | 2 +- test/tests/ScrollComponentTest.coffee | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/framer/LayerDraggable.coffee b/framer/LayerDraggable.coffee index b5cbc92ec..6dc56180e 100644 --- a/framer/LayerDraggable.coffee +++ b/framer/LayerDraggable.coffee @@ -381,7 +381,7 @@ class exports.LayerDraggable extends BaseClass get: -> # return null if not @isDragging velocity = @velocity - if velocity.x == 0 and velocity.y == 0 + if velocity.x is 0 and velocity.y is 0 delta = @_lastEvent?.delta return null if not delta if Math.abs(delta.x) > Math.abs(delta.y) diff --git a/test/tests/ScrollComponentTest.coffee b/test/tests/ScrollComponentTest.coffee index 54f87b586..f1ec1028b 100644 --- a/test/tests/ScrollComponentTest.coffee +++ b/test/tests/ScrollComponentTest.coffee @@ -115,17 +115,17 @@ describe "ScrollComponent", -> ups = _.lastIndexOf(moves, "up") downs = moves.indexOf("down") nulls = moves.indexOf(null) - if ups < downs < nulls or (nulls == -1 and ups < downs) then return done() + if ups < downs < nulls or (nulls is -1 and ups < downs) then return done() done("expected up+, down+, null+, but got: #{moves}") # TODO instead of actually taking time, trick time - draggable._touchStart({clientX:100, clientY:100, preventDefault:(()->), stopPropagation:(()->)}) + draggable._touchStart({clientX: 100, clientY: 100, preventDefault: (->), stopPropagation: (->)}) Utils.delay 0.01, -> - draggable._touchMove({clientX:100, clientY:111, preventDefault:(()->), stopPropagation:(()->), delta:{x:0,y:11}}) + draggable._touchMove({clientX: 100, clientY: 111, preventDefault: (->), stopPropagation: (->), delta: {x: 0, y: 11}}) Utils.delay 0.20, -> # enough time to set velocity to zero - draggable._touchMove({clientX:100, clientY:112, preventDefault:(()->), stopPropagation:(()->), delta:{x:0,y:1}}) + draggable._touchMove({clientX: 100, clientY: 112, preventDefault: (->), stopPropagation: (->), delta: {x: 0, y: 1}}) Utils.delay 0.21, -> - draggable._touchEnd({clientX:100, clientY:112, preventDefault:(()->), stopPropagation:(()->), delta:{x:0,y:0}}) + draggable._touchEnd({clientX: 100, clientY: 112, preventDefault: (->), stopPropagation: (->), delta: {x: 0, y: 0}}) describe "PageComponent", -> it "should fire scroll events", (done) -> From d9ec18ac1813ad9d34131fe6b3154d663af164f7 Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Mon, 7 Nov 2016 17:22:40 +0100 Subject: [PATCH 12/13] Add spaces after colons --- test/tests/LayerDraggableTest.coffee | 6 +- test/tests/LayerTest.coffee | 178 +++++++++++++-------------- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/test/tests/LayerDraggableTest.coffee b/test/tests/LayerDraggableTest.coffee index 23f34eded..02a8e5d69 100644 --- a/test/tests/LayerDraggableTest.coffee +++ b/test/tests/LayerDraggableTest.coffee @@ -7,9 +7,9 @@ describe "Layer", -> layer = new Layer layer.draggable.enabled = true - a1 = layer.animate x:100 - a2 = layer.animate y:100 - a3 = layer.animate blur:1 + a1 = layer.animate x: 100 + a2 = layer.animate y: 100 + a3 = layer.animate blur: 1 a1.isAnimating.should.equal true a2.isAnimating.should.equal true diff --git a/test/tests/LayerTest.coffee b/test/tests/LayerTest.coffee index 874263f4e..264489195 100644 --- a/test/tests/LayerTest.coffee +++ b/test/tests/LayerTest.coffee @@ -63,7 +63,7 @@ describe "Layer", -> it "should set defaults with override", -> - layer = new Layer x:50, y:60 + layer = new Layer x: 50, y: 60 layer.x.should.equal 50 layer.y.should.equal 60 @@ -86,7 +86,7 @@ describe "Layer", -> it "should set width", -> - layer = new Layer width:200 + layer = new Layer width: 200 layer.width.should.equal 200 layer.style.width.should.equal "200px" @@ -166,8 +166,8 @@ describe "Layer", -> it "should handle midX and midY when width and height are 0", -> box = new Layer - midX:200 - midY:300 + midX: 200 + midY: 300 width: 0 height: 0 @@ -301,16 +301,16 @@ describe "Layer", -> it "should set image", -> imagePath = "../static/test.png" - layer = new Layer image:imagePath + layer = new Layer image: imagePath layer.image.should.equal imagePath it "should unset image with null", -> - layer = new Layer image:"../static/test.png" + layer = new Layer image: "../static/test.png" layer.image = null layer.image.should.equal "" it "should unset image with empty string", -> - layer = new Layer image:"../static/test.png" + layer = new Layer image: "../static/test.png" layer.image = "" layer.image.should.equal "" @@ -321,7 +321,7 @@ describe "Layer", -> f.should.throw() it "should set name on create", -> - layer = new Layer name:"Test" + layer = new Layer name: "Test" layer.name.should.equal "Test" layer._element.getAttribute("name").should.equal "Test" @@ -344,14 +344,14 @@ describe "Layer", -> imagePath = "../static/test.png" - layer = new Layer image:imagePath + layer = new Layer image: imagePath assert.equal layer.backgroundColor.color, null layer = new Layer layer.image = imagePath assert.equal layer.backgroundColor.color, null - layer = new Layer backgroundColor:"red" + layer = new Layer backgroundColor: "red" layer.image = imagePath Color.equal(layer.backgroundColor, new Color("red")).should.be.true @@ -401,9 +401,9 @@ describe "Layer", -> it "should set scroll from properties", -> layer = new Layer - layer.props = {scroll:false} + layer.props = {scroll: false} layer.scroll.should.equal false - layer.props = {scroll:true} + layer.props = {scroll: true} layer.scroll.should.equal true it "should set scrollHorizontal", -> @@ -503,12 +503,12 @@ describe "Layer", -> it "should only set name when explicitly set", -> layer = new Layer - layer.__framerInstanceInfo = {name:"aap"} + layer.__framerInstanceInfo = {name: "aap"} layer.name.should.equal "" it "it should show the variable name in toInspect()", -> layer = new Layer - layer.__framerInstanceInfo = {name:"aap"} + layer.__framerInstanceInfo = {name: "aap"} (_.startsWith layer.toInspect(), " it "should check superLayer", -> - f = -> layer = new Layer superLayer:1 + f = -> layer = new Layer superLayer: 1 f.should.throw() it "should add child", -> layerA = new Layer - layerB = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA assert.equal layerB._element.parentNode, layerA._element assert.equal layerB.superLayer, layerA @@ -635,7 +635,7 @@ describe "Layer", -> it "should remove child", -> layerA = new Layer - layerB = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA layerB.superLayer = null @@ -645,8 +645,8 @@ describe "Layer", -> it "should list children", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerA assert.deepEqual layerA.children, [layerB, layerC] @@ -669,8 +669,8 @@ describe "Layer", -> it "should list sibling layers", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerA assert.deepEqual layerB.siblingLayers, [layerC] assert.deepEqual layerC.siblingLayers, [layerB] @@ -678,24 +678,24 @@ describe "Layer", -> it "should list super layers", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerB + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerB assert.deepEqual layerC.superLayers(), [layerB, layerA] it "should list descendants deeply", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerB + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerB layerA.descendants.should.eql [layerB, layerC] it "should list descendants", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerA layerA.descendants.should.eql [layerB, layerC] @@ -718,7 +718,7 @@ describe "Layer", -> it "should set at creation", -> - layer = new Layer index:666 + layer = new Layer index: 666 layer.index.should.equal 666 it "should change index", -> @@ -737,8 +737,8 @@ describe "Layer", -> it "should be in front", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerA assert.equal layerB.index, 1 assert.equal layerC.index, 2 @@ -746,8 +746,8 @@ describe "Layer", -> it "should send back and front", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerA + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerA layerC.sendToBack() @@ -762,9 +762,9 @@ describe "Layer", -> it "should place in front", -> layerA = new Layer - layerB = new Layer superLayer:layerA # 1 - layerC = new Layer superLayer:layerA # 2 - layerD = new Layer superLayer:layerA # 3 + layerB = new Layer superLayer: layerA # 1 + layerC = new Layer superLayer: layerA # 2 + layerD = new Layer superLayer: layerA # 3 layerB.placeBefore layerC @@ -775,9 +775,9 @@ describe "Layer", -> it "should place behind", -> layerA = new Layer - layerB = new Layer superLayer:layerA # 1 - layerC = new Layer superLayer:layerA # 2 - layerD = new Layer superLayer:layerA # 3 + layerB = new Layer superLayer: layerA # 1 + layerC = new Layer superLayer: layerA # 2 + layerD = new Layer superLayer: layerA # 3 layerC.placeBehind layerB @@ -790,9 +790,9 @@ describe "Layer", -> it "should get a children by name", -> layerA = new Layer - layerB = new Layer name:"B", superLayer:layerA - layerC = new Layer name:"C", superLayer:layerA - layerD = new Layer name:"C", superLayer:layerA + layerB = new Layer name: "B", superLayer: layerA + layerC = new Layer name: "C", superLayer: layerA + layerD = new Layer name: "C", superLayer: layerA layerA.childrenWithName("B").should.eql [layerB] layerA.childrenWithName("C").should.eql [layerC, layerD] @@ -800,17 +800,17 @@ describe "Layer", -> it "should get a siblinglayer by name", -> layerA = new Layer - layerB = new Layer name:"B", superLayer:layerA - layerC = new Layer name:"C", superLayer:layerA - layerD = new Layer name:"C", superLayer:layerA + layerB = new Layer name: "B", superLayer: layerA + layerC = new Layer name: "C", superLayer: layerA + layerD = new Layer name: "C", superLayer: layerA layerB.siblingLayersByName("C").should.eql [layerC, layerD] layerD.siblingLayersByName("B").should.eql [layerB] it "should get a superlayers", -> layerA = new Layer - layerB = new Layer superLayer:layerA - layerC = new Layer superLayer:layerB + layerB = new Layer superLayer: layerA + layerC = new Layer superLayer: layerB layerC.superLayers().should.eql [layerB, layerA] @@ -818,7 +818,7 @@ describe "Layer", -> it "should set on create", -> - layer = new Layer frame:{x:111, y:222, width:333, height:444} + layer = new Layer frame: {x: 111, y: 222, width: 333, height: 444} assert.equal layer.x, 111 assert.equal layer.y, 222 @@ -828,7 +828,7 @@ describe "Layer", -> it "should set after create", -> layer = new Layer - layer.frame = {x:111, y:222, width:333, height:444} + layer.frame = {x: 111, y: 222, width: 333, height: 444} assert.equal layer.x, 111 assert.equal layer.y, 222 @@ -836,69 +836,69 @@ describe "Layer", -> assert.equal layer.height, 444 it "should set minX on creation", -> - layer = new Layer minX:200, y:100, width:100, height:100 + layer = new Layer minX: 200, y: 100, width: 100, height: 100 layer.x.should.equal 200 it "should set midX on creation", -> - layer = new Layer midX:200, y:100, width:100, height:100 + layer = new Layer midX: 200, y: 100, width: 100, height: 100 layer.x.should.equal 150 it "should set maxX on creation", -> - layer = new Layer maxX:200, y:100, width:100, height:100 + layer = new Layer maxX: 200, y: 100, width: 100, height: 100 layer.x.should.equal 100 it "should set minY on creation", -> - layer = new Layer x:100, minY:200, width:100, height:100 + layer = new Layer x: 100, minY: 200, width: 100, height: 100 layer.y.should.equal 200 it "should set midY on creation", -> - layer = new Layer x:100, midY:200, width:100, height:100 + layer = new Layer x: 100, midY: 200, width: 100, height: 100 layer.y.should.equal 150 it "should set maxY on creation", -> - layer = new Layer x:100, maxY:200, width:100, height:100 + layer = new Layer x: 100, maxY: 200, width: 100, height: 100 layer.y.should.equal 100 it "should set minX", -> - layer = new Layer y:100, width:100, height:100 + layer = new Layer y: 100, width: 100, height: 100 layer.minX = 200 layer.x.should.equal 200 it "should set midX", -> - layer = new Layer y:100, width:100, height:100 + layer = new Layer y: 100, width: 100, height: 100 layer.midX = 200 layer.x.should.equal 150 it "should set maxX", -> - layer = new Layer y:100, width:100, height:100 + layer = new Layer y: 100, width: 100, height: 100 layer.maxX = 200 layer.x.should.equal 100 it "should set minY", -> - layer = new Layer x:100, width:100, height:100 + layer = new Layer x: 100, width: 100, height: 100 layer.minY = 200 layer.y.should.equal 200 it "should set midY", -> - layer = new Layer x:100, width:100, height:100 + layer = new Layer x: 100, width: 100, height: 100 layer.midY = 200 layer.y.should.equal 150 it "should set maxY", -> - layer = new Layer x:100, width:100, height:100 + layer = new Layer x: 100, width: 100, height: 100 layer.maxY = 200 layer.y.should.equal 100 it "should get and set canvasFrame", -> - layerA = new Layer x:100, y:100, width:100, height:100 - layerB = new Layer x:300, y:300, width:100, height:100, superLayer:layerA + layerA = new Layer x: 100, y: 100, width: 100, height: 100 + layerB = new Layer x: 300, y: 300, width: 100, height: 100, superLayer: layerA assert.equal layerB.canvasFrame.x, 400 assert.equal layerB.canvasFrame.y, 400 - layerB.canvasFrame = {x:1000, y:1000} + layerB.canvasFrame = {x: 1000, y: 1000} assert.equal layerB.canvasFrame.x, 1000 assert.equal layerB.canvasFrame.y, 1000 @@ -911,48 +911,48 @@ describe "Layer", -> assert.equal layerB.canvasFrame.y, 900 it "should calculate scale", -> - layerA = new Layer scale:0.9 - layerB = new Layer scale:0.8, superLayer:layerA + layerA = new Layer scale: 0.9 + layerB = new Layer scale: 0.8, superLayer: layerA layerB.screenScaleX().should.equal 0.9 * 0.8 layerB.screenScaleY().should.equal 0.9 * 0.8 it "should calculate scaled frame", -> - layerA = new Layer x:100, width:500, height:900, scale:0.5 - layerA.scaledFrame().should.eql {"x":225, "y":225, "width":250, "height":450} + layerA = new Layer x: 100, width: 500, height: 900, scale: 0.5 + layerA.scaledFrame().should.eql {"x": 225, "y": 225, "width": 250, "height": 450} it "should calculate scaled screen frame", -> - layerA = new Layer x:100, width:500, height:900, scale:0.5 - layerB = new Layer y:50, width:600, height:600, scale:0.8, superLayer:layerA - layerC = new Layer y:-60, width:800, height:700, scale:1.2, superLayer:layerB + layerA = new Layer x: 100, width: 500, height: 900, scale: 0.5 + layerB = new Layer y: 50, width: 600, height: 600, scale: 0.8, superLayer: layerA + layerC = new Layer y: -60, width: 800, height: 700, scale: 1.2, superLayer: layerB - layerA.screenScaledFrame().should.eql {"x":225, "y":225, "width":250, "height":450} - layerB.screenScaledFrame().should.eql {"x":255, "y":280, "width":240, "height":240} - layerC.screenScaledFrame().should.eql {"x":223, "y":228, "width":384, "height":336} + layerA.screenScaledFrame().should.eql {"x": 225, "y": 225, "width": 250, "height": 450} + layerB.screenScaledFrame().should.eql {"x": 255, "y": 280, "width": 240, "height": 240} + layerC.screenScaledFrame().should.eql {"x": 223, "y": 228, "width": 384, "height": 336} it "should accept point shortcut", -> - layer = new Layer point:10 + layer = new Layer point: 10 layer.x.should.equal 10 layer.y.should.equal 10 it "should accept size shortcut", -> - layer = new Layer size:10 + layer = new Layer size: 10 layer.width.should.equal 10 layer.height.should.equal 10 describe "Center", -> it "should center", -> - layerA = new Layer width:200, height:200 - layerB = new Layer width:100, height:100, superLayer:layerA + layerA = new Layer width: 200, height: 200 + layerB = new Layer width: 100, height: 100, superLayer: layerA layerB.center() assert.equal layerB.x, 50 assert.equal layerB.y, 50 it "should center with offset", -> - layerA = new Layer width:200, height:200 - layerB = new Layer width:100, height:100, superLayer:layerA + layerA = new Layer width: 200, height: 200 + layerB = new Layer width: 100, height: 100, superLayer: layerA layerB.centerX(50) layerB.centerY(50) @@ -960,14 +960,14 @@ describe "Layer", -> assert.equal layerB.y, 100 it "should center return layer", -> - layerA = new Layer width:200, height:200 + layerA = new Layer width: 200, height: 200 layerA.center().should.equal layerA layerA.centerX().should.equal layerA layerA.centerY().should.equal layerA it "should center pixel align", -> - layerA = new Layer width:200, height:200 - layerB = new Layer width:111, height:111, superLayer:layerA + layerA = new Layer width: 200, height: 200 + layerB = new Layer width: 111, height: 111, superLayer: layerA layerB.center().pixelAlign() assert.equal layerB.x, 44 @@ -989,7 +989,7 @@ describe "Layer", -> backgroundColor: "red" layerB.center() - layerB.frame.should.eql {x:20, y:20, width:100, height:100} + layerB.frame.should.eql {x: 20, y: 20, width: 100, height: 100} describe "CSS", -> @@ -1157,9 +1157,9 @@ describe "Layer", -> BORDERRADIUS = 20 layer = new Layer - x:X - y:Y - image:IMAGE + x: X + y: Y + image: IMAGE layer.borderRadius = BORDERRADIUS @@ -1186,9 +1186,9 @@ describe "Layer", -> it "copied Layer should also copy styles", -> layer = new Layer style: - "font-family" : "-apple-system" - "font-size" : "1.2em" - "text-align" : "right" + "font-family": "-apple-system" + "font-size": "1.2em" + "text-align": "right" copy = layer.copy() copy.style["font-family"].should.equal "-apple-system" From 141869583aa73aa883d0aa9289700992ea94099d Mon Sep 17 00:00:00 2001 From: Niels van Hoorn Date: Mon, 7 Nov 2016 17:22:49 +0100 Subject: [PATCH 13/13] Using not instead of ! --- test/tests/ScrollComponentTest.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/tests/ScrollComponentTest.coffee b/test/tests/ScrollComponentTest.coffee index f1ec1028b..2310f5c43 100644 --- a/test/tests/ScrollComponentTest.coffee +++ b/test/tests/ScrollComponentTest.coffee @@ -96,7 +96,7 @@ describe "ScrollComponent", -> # also check isMoving, isDragging, isAnimating throughout this test # TODO should be separate, when we can actually trick time - assert !scroll.isMoving, "must not be moving at start" + assert not scroll.isMoving, "must not be moving at start" # collect the move events as they happen moves = [] @@ -109,9 +109,9 @@ describe "ScrollComponent", -> # verify the timeline of move events looks good draggable.on Events.DragAnimationEnd, (event) -> #console.log "END", scroll.isMoving, scroll.direction - assert !scroll.isMoving, "no more moving" - assert !scroll.isAnimating, "no more animating" - assert !scroll.isDragging, "no more dragging" + assert not scroll.isMoving, "no more moving" + assert not scroll.isAnimating, "no more animating" + assert not scroll.isDragging, "no more dragging" ups = _.lastIndexOf(moves, "up") downs = moves.indexOf("down") nulls = moves.indexOf(null)