Unverified Commit f84551b9 authored by Liana Husikyan's avatar Liana Husikyan Committed by GitHub

Merge pull request #1859 from ethereum/fixSpinningBouncing

Fix spinning bouncing
parents 8fca40fe ada343c1
...@@ -76,7 +76,21 @@ class CompileTab extends CompilerApi { ...@@ -76,7 +76,21 @@ class CompileTab extends CompilerApi {
*/ */
listenToEvents () { listenToEvents () {
this.compiler.event.register('compilationStarted', () => { let onContentChanged = () => {
this.events.emit('statusChanged', {key: 'code', title: 'the content has changed, needs recompilation', type: 'info'})
}
this.editor.event.register('contentChanged', onContentChanged)
this.editor.event.register('sessionSwitched', onContentChanged)
this.compiler.event.register('loadingCompiler', () => {
this.events.emit('statusChanged', {key: 'spinner', title: 'loading compiler...', type: 'info'})
})
this.compiler.event.register('compilerLoaded', () => {
this.events.emit('statusChanged', {key: '', title: '', type: ''})
})
this.compileTabLogic.event.on('startingCompilation', () => {
if (this._view.errorContainer) { if (this._view.errorContainer) {
this._view.errorContainer.innerHTML = '' this._view.errorContainer.innerHTML = ''
} }
...@@ -85,10 +99,12 @@ class CompileTab extends CompilerApi { ...@@ -85,10 +99,12 @@ class CompileTab extends CompilerApi {
this.fileManager.events.on('currentFileChanged', (name) => { this.fileManager.events.on('currentFileChanged', (name) => {
this.compilerContainer.currentFile = name this.compilerContainer.currentFile = name
onContentChanged()
}) })
this.fileManager.events.on('noFileSelected', () => { this.fileManager.events.on('noFileSelected', () => {
this.compilerContainer.currentFile = '' this.compilerContainer.currentFile = ''
onContentChanged()
}) })
this.compiler.event.register('compilationFinished', (success, data, source) => { this.compiler.event.register('compilationFinished', (success, data, source) => {
...@@ -352,8 +368,6 @@ class CompileTab extends CompilerApi { ...@@ -352,8 +368,6 @@ class CompileTab extends CompilerApi {
this._view.errorContainer = yo`<div class="${css.errorBlobs}"></div>` this._view.errorContainer = yo`<div class="${css.errorBlobs}"></div>`
this._view.contractSelection = this.contractSelection() this._view.contractSelection = this.contractSelection()
this._view.compilerContainer = this.compilerContainer.render() this._view.compilerContainer = this.compilerContainer.render()
const currentFile = this.fileManager.currentFile()
if (currentFile) this.compilerContainer.currentFile = currentFile
this._view.el = yo` this._view.el = yo`
<div id="compileTabView"> <div id="compileTabView">
......
const async = require('async') const async = require('async')
const EventEmitter = require('events')
var remixTests = require('remix-tests') var remixTests = require('remix-tests')
var Compiler = require('remix-solidity').Compiler var Compiler = require('remix-solidity').Compiler
var CompilerImport = require('../../compiler/compiler-imports') var CompilerImport = require('../../compiler/compiler-imports')
...@@ -9,6 +10,7 @@ const addTooltip = require('../../ui/tooltip') ...@@ -9,6 +10,7 @@ const addTooltip = require('../../ui/tooltip')
class CompileTab { class CompileTab {
constructor (queryParams, fileManager, editor, config, fileProviders) { constructor (queryParams, fileManager, editor, config, fileProviders) {
this.event = new EventEmitter()
this.queryParams = queryParams this.queryParams = queryParams
this.compilerImport = new CompilerImport() this.compilerImport = new CompilerImport()
this.compiler = new Compiler((url, cb) => this.importFileCb(url, cb)) this.compiler = new Compiler((url, cb) => this.importFileCb(url, cb))
...@@ -45,7 +47,11 @@ class CompileTab { ...@@ -45,7 +47,11 @@ class CompileTab {
provider.get(target, (error, content) => { provider.get(target, (error, content) => {
if (error) return console.log(error) if (error) return console.log(error)
sources[target] = { content } sources[target] = { content }
this.compiler.compile(sources, target) this.event.emit('startingCompilation')
setTimeout(() => {
// setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation')
this.compiler.compile(sources, target)
}, 100)
}) })
} }
......
...@@ -47,6 +47,13 @@ class CompilerContainer { ...@@ -47,6 +47,13 @@ class CompilerContainer {
this.editor.event.register('contentChanged', this.scheduleCompilation.bind(this)) this.editor.event.register('contentChanged', this.scheduleCompilation.bind(this))
this.editor.event.register('sessionSwitched', this.scheduleCompilation.bind(this)) this.editor.event.register('sessionSwitched', this.scheduleCompilation.bind(this))
this.compileTabLogic.event.on('startingCompilation', () => {
if (!this._view.compileIcon) return
this._view.compileIcon.setAttribute('title', 'compiling...')
this._view.compileIcon.classList.remove(`${css.bouncingIcon}`)
this._view.compileIcon.classList.add(`${css.spinningIcon}`)
})
this.compileTabLogic.compiler.event.register('compilationDuration', (speed) => { this.compileTabLogic.compiler.event.register('compilationDuration', (speed) => {
if (!this._view.warnCompilationSlow) return if (!this._view.warnCompilationSlow) return
if (speed > 1000) { if (speed > 1000) {
...@@ -65,29 +72,22 @@ class CompilerContainer { ...@@ -65,29 +72,22 @@ class CompilerContainer {
this.compileTabLogic.compiler.event.register('loadingCompiler', () => { this.compileTabLogic.compiler.event.register('loadingCompiler', () => {
if (!this._view.compileIcon) return if (!this._view.compileIcon) return
this._view.compileIcon.classList.add(`${css.spinningIcon}`)
this._view.warnCompilationSlow.style.visibility = 'hidden'
this._view.compileIcon.setAttribute('title', 'compiler is loading, please wait a few moments.') this._view.compileIcon.setAttribute('title', 'compiler is loading, please wait a few moments.')
})
this.compileTabLogic.compiler.event.register('compilationStarted', () => {
if (!this._view.compileIcon) return
this._view.compileIcon.classList.remove(`${css.bouncingIcon}`)
this._view.compileIcon.classList.add(`${css.spinningIcon}`) this._view.compileIcon.classList.add(`${css.spinningIcon}`)
this._view.compileIcon.setAttribute('title', 'compiling...') this._view.warnCompilationSlow.style.visibility = 'hidden'
}) })
this.compileTabLogic.compiler.event.register('compilerLoaded', () => { this.compileTabLogic.compiler.event.register('compilerLoaded', () => {
if (!this._view.compileIcon) return if (!this._view.compileIcon) return
this._view.compileIcon.classList.remove(`${css.spinningIcon}`)
this._view.compileIcon.setAttribute('title', '') this._view.compileIcon.setAttribute('title', '')
this._view.compileIcon.classList.remove(`${css.spinningIcon}`)
}) })
this.compileTabLogic.compiler.event.register('compilationFinished', (success, data, source) => { this.compileTabLogic.compiler.event.register('compilationFinished', (success, data, source) => {
if (!this._view.compileIcon) return if (!this._view.compileIcon) return
this._view.compileIcon.setAttribute('title', 'idle')
this._view.compileIcon.classList.remove(`${css.spinningIcon}`) this._view.compileIcon.classList.remove(`${css.spinningIcon}`)
this._view.compileIcon.classList.remove(`${css.bouncingIcon}`) this._view.compileIcon.classList.remove(`${css.bouncingIcon}`)
this._view.compileIcon.setAttribute('title', 'idle')
}) })
} }
......
...@@ -141,32 +141,78 @@ const css = csjs` ...@@ -141,32 +141,78 @@ const css = csjs`
.icon { .icon {
margin-right: 0.3em; margin-right: 0.3em;
} }
.spinningIcon {
margin-right: .3em;
animation: spin 2s linear infinite;
}
.bouncingIcon {
margin-right: .3em;
animation: bounce 2s infinite;
}
.errorBlobs { .errorBlobs {
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
} }
.spinningIcon {
display: inline-block;
position: relative;
animation: spin 2s infinite linear;
-moz-animation: spin 2s infinite linear;
-o-animation: spin 2s infinite linear;
-webkit-animation: spin 2s infinite linear;
}
@keyframes spin { @keyframes spin {
0% { transform: rotate(0deg); } 0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); } 100% { transform: rotate(360deg); }
} }
@-webkit-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@-moz-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@-o-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@-ms-keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.bouncingIcon {
display: inline-block;
position: relative;
-moz-animation: bounce 2s infinite linear;
-o-animation: bounce 2s infinite linear;
-webkit-animation: bounce 2s infinite linear;
animation: bounce 2s infinite linear;
}
@-webkit-keyframes bounce { @-webkit-keyframes bounce {
0% { 0% { top: 0; }
margin-bottom: 0; 50% { top: -0.2em; }
} 70% { top: -0.3em; }
70% { 100% { top: 0; }
margin-bottom: 0; }
} @-moz-keyframes bounce {
100% { 0% { top: 0; }
margin-bottom: 0; 50% { top: -0.2em; }
} 70% { top: -0.3em; }
100% { top: 0; }
}
@-o-keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
}
@-ms-keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
}
@keyframes bounce {
0% { top: 0; }
50% { top: -0.2em; }
70% { top: -0.3em; }
100% { top: 0; }
} }
` `
......
...@@ -125,14 +125,12 @@ export class LandingPage extends BaseApi { ...@@ -125,14 +125,12 @@ export class LandingPage extends BaseApi {
this.appManager.ensureActivated('run') this.appManager.ensureActivated('run')
this.appManager.ensureActivated('solidityStaticAnalysis') this.appManager.ensureActivated('solidityStaticAnalysis')
this.appManager.ensureActivated('solidityUnitTesting') this.appManager.ensureActivated('solidityUnitTesting')
globalRegistry.get('filemanager').api.switchFile()
globalRegistry.get('verticalicon').api.select('solidity') globalRegistry.get('verticalicon').api.select('solidity')
} }
let startVyper = () => { let startVyper = () => {
closeAll() closeAll()
this.appManager.ensureActivated('vyper') this.appManager.ensureActivated('vyper')
this.appManager.ensureActivated('run') this.appManager.ensureActivated('run')
globalRegistry.get('filemanager').api.switchFile()
globalRegistry.get('verticalicon').api.select('vyper') globalRegistry.get('verticalicon').api.select('vyper')
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment