I am currently working on a website project that involves the use of jQuery and jQuery UI. One of the key features I have implemented is elements fading in when they enter the viewport, which is functioning well. However, I have encountered a specific issue.
In order for the fade effect to work properly, the elements need to initially be hidden, so I have applied display: none
to them. The problem arises when they start to fade in, as this changes the size of the containing div.
This poses a challenge because I have a unique smooth scrolling feature that navigates you through different sections of the page gradually, instead of instantly jumping with links. This functionality is based on detecting the offset of the target element from the top of the page. The scroll is affected by fading elements increasing the length of the page, altering the offset of the target element and causing the scrolling to stop prematurely.
Is there a way to animate elements without the initial use of display: none
?
NOTE: I am unable to utilize opacity
! Please refrain from suggesting it as a solution! I require more complex effects such as Fold
and Slide In
, which cannot be achieved solely with opacity. I have refrained from sharing code at this stage, as my question focuses on whether jQuery offers any alternatives to using display: none
.