This commit is contained in:
Roman Pyrih
2025-08-05 15:41:08 +02:00
parent 807c9b262f
commit e374c3c489
41 changed files with 599 additions and 16 deletions

View File

@@ -0,0 +1,23 @@
jQuery(function ($) {
$(window).on('scroll', function () {
$('.parallax-box').each(function () {
var box = $(this)
var img = box.find('.parallax-box-img')
var boxTop = box.offset().top
var boxHeight = box.outerHeight()
var scrollTop = $(window).scrollTop()
var windowHeight = $(window).height()
if (scrollTop + windowHeight > boxTop && scrollTop < boxTop + boxHeight) {
var percentSeen =
(scrollTop + windowHeight - boxTop) / (windowHeight + boxHeight)
percentSeen = Math.min(Math.max(percentSeen, 0), 1)
var translateY = (percentSeen - 0.5) * 400
img.css('transform', 'translateY(' + translateY + 'px)')
}
})
})
})