12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- var transitionize = require('../transitionize');
- window.onload = function() {
- var elem = document.querySelector('.js-elem')
- , prop = {};
- elem.addEventListener('click', function() {
- var position = parseInt(elem.style.left) || 0;
- if (position == 0) {
- this.style.left = this.parentNode.offsetWidth - this.offsetWidth + 'px';
- this.style.backgroundColor = '#53e7d0';
- prop = {
- 'background-color': '0.3s'
- , 'left': '0.3s'
- };
- } else {
- this.style.left = 0;
- this.style.backgroundColor = '#febf04';
- prop = {
- 'background-color': '1s'
- , 'left': '1s'
- };
- }
- transitionize(elem, prop);
- });
- };
|