Skip to content

Commit

Permalink
Fix load error
Browse files Browse the repository at this point in the history
  • Loading branch information
larsenwork committed May 30, 2018
1 parent 0b37795 commit 9c0b1e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Binary file modified docs/easing-gradient-assets.sketch
Binary file not shown.
6 changes: 5 additions & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const UI = require('sketch/ui') // eslint-disable-line import/no-unresolved

export default function(layer) {
const gradientParams = layer.name
.split('🌈')
Expand All @@ -10,13 +12,15 @@ export default function(layer) {
let timing = 'linear'
let colorSpace = 'lrgb'
let colorStops = 15

if (gradientParams.length === 3) {
;[timing, colorSpace, colorStops] = gradientParams
} else if (gradientParams.length === 2) {
;[timing, colorSpace] = gradientParams
} else {
UI.message("🌈 ⚠️ Couldn't parse the layer name. Resetting.")
UI.message("🌈 ⚠️ Couldn't parse the layer name. Setting defaults.")
}

const paramsAsString = JSON.stringify([
gradientStopFirst.color,
timing,
Expand Down
6 changes: 3 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ export default function() {
) {
const browserWindow = new BrowserWindow(options)
const { webContents } = browserWindow
const paramsAsString = getParamsFromLayer(selectedLayer)

// Show the window when the page has loaded
browserWindow.on('ready-to-show', () => {
browserWindow.once('ready-to-show', () => {
browserWindow.show()
})

Expand All @@ -37,8 +38,7 @@ export default function() {
})

// Send gradient parameters to the webview once it's loaded
webContents.on('did-finish-load', () => {
const paramsAsString = getParamsFromLayer(selectedLayer)
webContents.once('did-finish-load', () => {
webContents.executeJavaScript(`setGradientParams('${paramsAsString}')`)
})

Expand Down

0 comments on commit 9c0b1e8

Please sign in to comment.