Skip to content
Snippets Groups Projects
Commit d6cf236b authored by stefanorigano's avatar stefanorigano Committed by qsm-odoo
Browse files

[REF] website: refactor parallax snippet

This commit is a refactoring of the 's_parallax' snippet. Note that it
is compatible with previous parallax snippet (old snippets are just
transformed into the brand new one on page load). Note that scroll
speed are changed by this implementation though.

This solves several issues:

- Bg image went easily off of the frame if scroll speed was too fast

- The 'scroll speed' effect was visually inconsistent across different
    devices.

- If the Bg image was smaller than the frame (condition which occurs
    often in a responsive environment), then the image was totally
    offset.

- Since the previous implementation use background-position property
    to perform the effect, It was not possible to define an image
    focus point.

This implementation solves the previous issues introducing a safe-area
that limit the effect range. It's calculated dynamically, according to
the current screen size and the 'speed' option.

The effect if now achieved thanks to the translation of a DOM element
instead of background-position changes. This allows to solve the last
mentionned problem and improve performance.

The implementation rely on the new animation methods of the snippets
Animation class.
As this use the "requestAnimationFrame" function, the snippet knows
the right time to repaint itself, instead of using the "scroll" event
which is triggered too many times and thus occurs between painting
frames. This change greatly improved performances (CPU/painting usage
many times smaller).
parent 0e08e653
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment