mirror of
https://github.com/LBRYFoundation/lbryorg.git
synced 2025-08-23 20:47:23 +00:00
fix: optimize the scroll linked effects
This commit is contained in:
parent
62a2d02eca
commit
1595031250
1 changed files with 12 additions and 9 deletions
|
@ -1,17 +1,20 @@
|
|||
// Parallax
|
||||
const depthFactor = 5; // Depth of the image wrt to the 0 z-index. Infinity being at the same distance as the rest of the content and 1 being as far away as possible.
|
||||
const parallaxOffset = 20;
|
||||
$(window).on('scroll', () => {
|
||||
const movedBy = window.scrollY;
|
||||
|
||||
if ($(window).height() - elem.getBoundingClientRect().top >= parallaxOffset) {
|
||||
$('.parallax').each((i, parallax) => {
|
||||
$(parallax).find('.parallax-layer').each((i, layer) => {
|
||||
const depth = $(layer).attr('data-depth-factor') || depthFactor; // dynamically get depthFactor
|
||||
|
||||
$('.parallax').each((i, parallax) => {
|
||||
$(parallax).find('.parallax-layer').each((i, layer) => {
|
||||
const depth = $(layer).attr('data-depth-factor') || depthFactor; // dynamically get depthFactor
|
||||
|
||||
$(layer).css({
|
||||
transform: `translateY(+${movedBy / depth}px)` // Move differently than the rest of the window
|
||||
$(layer).css({
|
||||
transform: `translateY(+${movedBy / depth}px)` // Move differently than the rest of the window
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
// /Parallax
|
||||
|
||||
|
@ -34,8 +37,8 @@ $(window).on('scroll', () => {
|
|||
const delay = $(elem).attr('data-fade-delay') || fadeDelay;
|
||||
|
||||
if ($(window).height() - elem.getBoundingClientRect().top >= offset) {
|
||||
$(elem).delay(delay).animate({opacity: 1}, duration).css({transition: `transform ${duration / 1000}s`}).css({transform: 'scale(1)'});
|
||||
$(elem).delay(delay).animate({opacity: 1}, duration).css({transition: `transform ${duration / 1000}s`}).css({transform: 'scale(1)'}).removeClass('scroll-fade');
|
||||
}
|
||||
})
|
||||
})
|
||||
// /ScrollFade Anim
|
||||
// /ScrollFade Anim
|
||||
|
|
Loading…
Add table
Reference in a new issue