Last active
June 23, 2018 16:26
-
-
Save kimroen/06f9fa95444a01e645261b6ba232bcc2 to your computer and use it in GitHub Desktop.
Animate Focus
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 move from 'ember-animated/motions/move'; | |
import opacity from 'ember-animated/motions/opacity'; | |
import { easeOut, easeIn } from 'ember-animated/easings/cosine'; | |
import Promise from 'rsvp'; | |
export default Ember.Component.extend({ | |
myProperty: false, | |
transition: function* ({ insertedSprites, keptSprites, removedSprites, duration }) { | |
yield Promise.all([ | |
...insertedSprites.map(sprite => { | |
sprite.startAtPixel({ x: window.innerWidth }); | |
return Promise.all([ | |
move(sprite, { easing: easeOut, duration }), | |
opacity(sprite, { to: 1, duration }) | |
]); | |
}), | |
...keptSprites.map(move), | |
removedSprites.map(sprite => { | |
sprite.endAtPixel({ x: -sprite.initialBounds.width }); | |
return Promise.all([ | |
move(sprite, { easing: easeIn, duration }), | |
opacity(sprite, {to: 0, duration }) | |
]); | |
}) | |
]); | |
// TODO: not this | |
insertedSprites[0].__element.parentNode.querySelector('input').focus(); | |
}, | |
}); |
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.14.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": "2.18.2", | |
"ember-template-compiler": "2.18.2", | |
"ember-testing": "2.18.2" | |
}, | |
"addons": { | |
"ember-data": "2.18.2", | |
"ember-animated": "0.3.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment