website/public/scripts/vorkath.coffee

18 lines
882 B
CoffeeScript
Raw Permalink Normal View History

2022-02-19 12:05:13 -05:00
$(window).scroll ->
wScroll = $(this).scrollTop()
console.log(wScroll + ' | ' + window.innerHeight)
# Header parallax
$('#header-logo').css('transform', 'translate(-50%, ' + (wScroll / 2) + 'px)')
$('#header-logo h1').css('transform', 'translateY(-' + (wScroll / 2) + 'px)')
# YouTube section parallax
if not (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
$('.youtube-section').each (i, e) ->
if wScroll >= ($(e).offset().top - window.innerHeight)
offset = (Math.min(0, wScroll - $(e).offset().top + window.innerHeight - 500)).toFixed()
$(e).find('.video-card:first-child').css('transform': 'translate(' + offset + 'px, ' + Math.abs(offset * 0.2) + 'px)')
$(e).find('.video-card:last-child').css('transform': 'translate(' + Math.abs(offset) + 'px, ' + Math.abs(offset * 0.2) + 'px)')