Skip to content

Instantly share code, notes, and snippets.

@jakeleboeuf
Created August 26, 2016 17:10
Show Gist options
  • Save jakeleboeuf/23e19699f92644ae526d3a1450b6d174 to your computer and use it in GitHub Desktop.
Save jakeleboeuf/23e19699f92644ae526d3a1450b6d174 to your computer and use it in GitHub Desktop.
Best Practices?
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
moveYourBody(anim) {
let hand;
let initX,initY,handX,handY;
function handMove(ev){
let currentX = ev.clientX;
let currentY = ev.clientY;
anim.animationData.layers[0].layers[0].ks.p.k[0].s[0] = handX + (currentX - initX);
anim.animationData.layers[0].layers[0].ks.p.k[0].e[0] = handX + (currentX - initX);
anim.animationData.layers[0].layers[0].ks.p.k[0].s[1] = handY + (currentY - initY);
anim.animationData.layers[0].layers[0].ks.p.k[0].e[1] = handY + (currentY - initY);
}
function handUp(){
document.removeEventListener('mousemove', handMove);
document.removeEventListener('mouseup', handUp);
}
function handDown(ev){
document.addEventListener('mousemove', handMove);
document.addEventListener('mouseup', handUp);
initX = ev.clientX;
initY = ev.clientY;
handX = anim.animationData.layers[0].layers[0].ks.p.k[0].s[0];
handY = anim.animationData.layers[0].layers[0].ks.p.k[0].s[1];
}
function init(){
hand = document.getElementById('hand');
hand.addEventListener('mousedown', handDown);
}
anim.addEventListener('DOMLoaded', init);
this.send('announcement');
},
announcement() {
console.log(`let's rock`);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment