Created
November 18, 2016 16:28
-
-
Save machty/a7fe659f428a09e4eb5da69415856976 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains 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 { task, timeout, asyncComputed, emit } from 'ember-concurrency'; | |
export default Ember.Controller.extend({ | |
value: 123, | |
tweened: asyncComputed('value', function * (v) { | |
let targetValue = parseInt(v); | |
let curValue = parseInt(this.get('tweened.lastComplete.value') || targetValue); | |
while (true) { | |
let delta = Math.floor((targetValue - curValue) * 0.6); | |
if (delta) { | |
curValue += delta; | |
yield emit(curValue); | |
} else { | |
return targetValue; | |
} | |
yield timeout(50); | |
} | |
}), | |
}); |
This file contains 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.10.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.6.0", | |
"ember-data": "2.6.1", | |
"ember-template-compiler": "2.6.0" | |
}, | |
"addons": { | |
"ember-concurrency": "tof3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment