Last active
March 26, 2019 14:47
-
-
Save astronomersiva/2e230805a23b7e34a235074fa999fd81 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { inject as service } from '@ember/service'; | |
export default Ember.Component.extend({ | |
progressBar: service(), | |
didInsertElement() { | |
this._super(...arguments); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { inject as service } from '@ember/service'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
progressBar: service(), | |
actions: { | |
showProgress() { | |
this.get('progressBar').startLoading(); | |
}, | |
endProgress() { | |
this.get('progressBar').endLoading(); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { later } from '@ember/runloop'; | |
export default Ember.Service.extend({ | |
start() { | |
let interval = (1000/60); // 16fps | |
let ratio = .1; | |
let progress = 0; | |
let timer = setInterval(() => { | |
progress = progress + ((progress || 20) * ratio); | |
if (ratio < 0.0005) { | |
ratio = ratio * .999; | |
} else { | |
ratio = ratio * .97; | |
} | |
this.set('width', `${progress}%`); | |
if (progress > 100) { | |
this.set('width', `100%`); | |
clearInterval(timer); | |
} | |
}, interval); | |
this.timer = timer; | |
}, | |
startLoading() { | |
this.set('width', 0); | |
this.set('canShow', true); | |
this.start(); | |
}, | |
endLoading() { | |
clearInterval(this.timer); | |
this.set('width', `100%`); | |
this.set('complete', true); | |
later(() => { | |
this.set('width', 0); | |
this.set('complete', false); | |
this.set('canShow', false); | |
}, 300); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.progress-complete { | |
transition: width linear .15s; | |
} | |
.progress { | |
position: absolute; | |
height: 3px; | |
background: #0eb477; | |
top: 0; | |
left: 0; | |
} | |
.progress-lead { | |
position: absolute; | |
right: 0; | |
top: 0; | |
height: 100%; | |
width: 40px; | |
box-shadow: #0eb477ff 0px 0px 10px; | |
transform: rotate(3deg) translate(0px,-4px); | |
translate: -10%; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment