Skip to content

Instantly share code, notes, and snippets.

@claudia-romano
Created August 1, 2018 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudia-romano/1a3d21dc04a7f5d2ab51550dfdbd055d to your computer and use it in GitHub Desktop.
Save claudia-romano/1a3d21dc04a7f5d2ab51550dfdbd055d to your computer and use it in GitHub Desktop.
(function() {
function TransitionIcon( element ) {
this.element = element;
this.size = this.element.getBoundingClientRect();
this.states = this.element.querySelectorAll('.js-transition-icon__state');
this.time = {start: null, total: 200};
this.status = {interacted : false, animating : false};
this.init();
};
TransitionIcon.prototype.init = function() {
var self = this;
this.element.addEventListener('click', function(){
if(self.status.animating) return;
self.status.animating = true;
window.requestAnimationFrame(self.triggerAnimation.bind(self));
});
};
TransitionIcon.prototype.triggerAnimation = function(timestamp) {
//.. this is where the animation takes place
};
var transitionIcons = document.querySelectorAll('.js-transition-icon');
if( transitionIcons ) {
for( var i = 0; transitionIcons.length > i; i++ ) {
//create a TransitionIcon object for each .js-transition-icon element
(function(i) {
new TransitionIcon(transitionIcons[i]);
}(i));
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment