Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Parallax code working BUT starts to late

  • So I have been collating parallax info that GP people have been posting and I have got it working well – BUT – for some reason and I cannot work out why – the text starts much lower dowmn the image than I want and then goes off the page and behind the block below it

    I have added link to page in private info box

    Parallax created as an element – block with image – tagged with parallax-wrapper – as main container

    with CSS code

    .parallax-wrapper {
        overflow-y: hidden;
    }
    
    .parallax {
        overflow-y: hidden;
    }

    and parallax JS hooked into footer

    <script>
    window.addEventListener('scroll', throttle(parallax, 14));
    
    function throttle(fn, wait) {
      var time = Date.now();
      return function() {
        if ((time + wait - Date.now()) < 0) {
          fn();
          time = Date.now();
        }
      }
    };
    
    function parallax() {
      var scrolled = window.pageYOffset;
      var parallax = document.querySelector(".parallax");
      // You can adjust the 0.4 to change the speed
    	var coords = (scrolled * 0.3) + 'px'
      parallax.style.transform = 'translateY(' + coords + ')';
    };
    </script>

    I am also using SAL scripts to animate the text above – but even when removed the parallax still does it

    I have also got the depicter slider for the banner – again when I disable that – the text for parallax starts higher but still disappears off the page – so its better but not right

    Its like its expecting the parallax to be the very first thing and its not?!

    Any ideas to assist or point me in the direction to play?

    thank you
    Sarah

  • Hi there,

    not sure on this one, I can see the fault is related to the JS using translate on the container which affects the content. But that looks to be a fundamental flaw to that approach, so not something I can say how to fix.

    Have you tried a parallax script like this one ?

    https://github.com/angusfretwell/parallax

  • Thank you David – I have gone back to a fixed scroll version and removed the JS as I too was not able to get it to work right – thank you for taking the time however

  • You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.