View PerformantAnimations4.css
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
.box { | |
box-shadow: 1px 1px 1px rgba(0,0,0,.5); | |
transition: .2s; | |
} | |
.active { | |
box-shadow: 1px 1px 1px rgba(0,0,0,1); | |
} |
View PerformantAnimations12.js
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
var wrapperHeight = wrapper.getBoundingClientRect().height + 'px'; | |
boxes.forEach(box => { | |
box.style.transform = “translateY(“ + wrapperHeight + “px)”; | |
}) |
View PerformantAnimations10.js
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
element.addEventListener('touchmove', doSomething(), { passive: true }); |
View PerformantAnimations13.css
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
.box { | |
contain: style; //will limit the scope of styles to this element and its children | |
} |
View PerformantAnimations11.js
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
boxes.forEach(box => { | |
box.style.transform = “translateY(“ + wrapper.getBoundingClientRect().height + “px)”; | |
}) | |
View PerformantAnimations9.js
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 doSomething() { | |
requestAnimationFrame(doSomething); | |
// Do stuff | |
} | |
doSomething(); | |
View PerformantAnimations8.js
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
var box = document.getElementById("box") | |
box.addEventListener("click", function(){ | |
box.classList.toggle("class-name"); | |
}); |
View PerformantAnimations7.css
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
@keyframes spin { | |
from {transform: rotate(0deg);} | |
to {transform: rotate(360deg);} | |
} | |
.box { | |
animation-name: spin; | |
animation-duration: 3ms; | |
animation-iteration-count: infinite; | |
animation-timing-function: linear; | |
} |
View PerformantAnimations6.css
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
.box { | |
will-change: auto; | |
} |
View PerformantAnimations5.css
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
.box { | |
position: relative; | |
} | |
.box:before { | |
content: “”; | |
box-shadow: 1px 1px 1px rgb(0,0,0); | |
opacity: .5; | |
transition: .2s; | |
position: absolute; | |
width: 100%; |
NewerOlder