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
(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