On a website i'm making at my internship, I want to make a arrow, that flattens once the user is scrolling down. I have tried to make this with jQuery, but this seemed to be very heavy for the browser.
For this function, I used the .scroll() function, and a calculation that makes the arrow (triangle) flatter once the user scrolls down:
$(window).scroll(function(e){
triangleRotation = 5.6125 - ($(window).scrollTop() / ($(window).height() / 7.3));
if (triangleRotation <= 0) {
triangleRotation = 0;
}
$('.triangle-left').css({'transform': 'rotate(' + triangleRotation + 'deg)', '-webkit-transform': 'rotate(' + triangleRotation + 'deg)', '-moz-transform': 'rotate(' + triangleRotation + 'deg)'});
$('.triangle-right').css({'transform': 'rotate(-' + triangleRotation + 'deg)', '-webkit-transform': 'rotate(-' + triangleRotation + 'deg)', '-moz-transform': 'rotate(-' + triangleRotation + 'deg)'});
});
I also tried this via a triangle shaped image, and simply flatten the image. This was also to heavy.
Is there a less heavy way to do this?