Last active
July 9, 2019 20:26
-
-
Save elidupuis/c5c115d8d808cbc8bec4e5b2177e8b46 to your computer and use it in GitHub Desktop.
Parent animator offset via private API
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 move from 'ember-animated/motions/move'; | |
import { fadeIn, fadeOut } from 'ember-animated/motions/opacity'; | |
import { easeIn, easeOut, easeInAndOut } from 'ember-animated/easings/cosine'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
isThingActive: false, | |
showThingActions: true, | |
duration: 1500, | |
things: null, | |
init() { | |
this.set('things', this.makeItems(2)); | |
console.log(this.get('things')); | |
this.initialThings = [...this.things]; | |
}, | |
actions: { | |
activate(thing) { | |
this.set('selectedThing', thing.id); | |
this.get('things').reverseObjects(); | |
} | |
}, | |
// manages vertical motion during list sorting | |
*transition({ keptSprites, duration }) { | |
// console.log(arguments[0]); | |
for (let sprite of keptSprites) { | |
move(sprite, { duration, easing: easeOut }); | |
} | |
}, | |
// manages icons sliding in/out of list items | |
*iconTransition({ insertedSprites, keptSprites, removedSprites, duration }) { | |
// a slight slide in from the right | |
for (let sprite of insertedSprites) { | |
sprite.startTranslatedBy(50, 0); | |
move(sprite, { duration, easing: easeOut }); | |
// fadeIn(sprite); | |
} | |
// handle interruption | |
for (let sprite of keptSprites) { | |
move(sprite, { duration, easing: easeOut }); | |
// fadeIn(sprite); | |
} | |
// a slight slide out to the right | |
for (let sprite of removedSprites) { | |
sprite.endTranslatedBy(50, 0); | |
move(sprite, { duration, easing: easeIn }); | |
// fadeOut(sprite); | |
} | |
}, | |
// manages icons sliding in/out of list items | |
*iconTransitionWithOffset({ insertedSprites, keptSprites, removedSprites, duration }) { | |
// a slight slide in from the right | |
for (let sprite of insertedSprites) { | |
let offsetDy = 0 | |
// WARNING: this is private API. | |
let offsetSprite = sprite._offsetSprite; | |
if (offsetSprite) { | |
offsetDy = offsetSprite.initialBounds.top - offsetSprite.finalBounds.top; | |
} | |
sprite.startTranslatedBy(50, -offsetDy); | |
move(sprite, { duration, easing: easeOut }); | |
// fadeIn(sprite); | |
} | |
// handle interruption | |
for (let sprite of keptSprites) { | |
move(sprite, { duration, easing: easeOut }); | |
// fadeIn(sprite); | |
} | |
// a slight slide out to the right | |
for (let sprite of removedSprites) { | |
sprite.endTranslatedBy(50, 0); | |
move(sprite, { duration, easing: easeIn }); | |
// fadeOut(sprite); | |
} | |
}, | |
makeItems(count = 5) { | |
let result = Ember.A(); | |
for (let i = 0; i < count; i++) { | |
result.push(makeRandomItem(i)); | |
} | |
return (result); | |
}, | |
}); | |
function makeRandomItem(index) { | |
var messages = ["Dwight", "Stanley", "Kelly", "Ryan", "Kevin"]; | |
var images = ['https://pbs.twimg.com/profile_images/549268771484229632/WnatiHzT_400x400.jpeg', 'https://pbs.twimg.com/profile_images/1839546020/florida_stanley_400x400.jpg', 'https://pbs.twimg.com/profile_images/71405458/2928282474_24807334d7_400x400.jpg', 'https://pbs.twimg.com/profile_images/740436182107049984/y0N8Sqbi_400x400.jpg', 'https://pbs.twimg.com/profile_images/118888142/Brian_Baumgartner_134198_400x400.jpg']; | |
return { id: index, message: messages[index], image: images[index] }; | |
} |
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; | |
} | |
.thing { | |
width: 50vw; | |
padding: 1rem; | |
margin: 0.5rem 0; | |
color: white; | |
background: steelblue; | |
display: flex; | |
justify-content: space-between; | |
align-items: center; | |
cursor: pointer; | |
/* overflow: hidden; */ | |
} | |
.icons { | |
} |
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-animated": "0.6.1", | |
"ember-truth-helpers": "2.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment