3

I have just started working with stellar.js (Parallax jQuery library), and it seems pretty easy to use, however it is really jerky/jumpy when you scroll with the mouse wheel (less so when you drag the browser scrollbar manually. Oddly, it is perfectly smooth when uploaded to JSFiddle.

Has anyone encountered this issue before and know what the likely cause could be looking at my code? Please feel free to download the code from JSFiddle and recreate locally to see if you get the same issue, or if you spot anything obvious on my Fiddle, help would be appreciated.

For reference, this problem occurs in Chrome (version 32 here).

CSS

body { background: url(https://www.google.co.uk/images/srpr/logo11w.png) no-repeat; background-size: 100% ; }

    section.one { position: relative; border-bottom: 5px solid #000; }
    .one .div1 { background: #ccc; width: 200px; height:300px; position: absolute; top: 200px; overflow: hidden; }
    .one .div2 { background: #eee; width: 200px; height:200px; position: absolute; top: 100px; left: 100px; }
    .one .div3 { background: #aaa; width: 200px; height:200px; position: absolute; top: 100px; left: 150px; }

    section.two { position: relative; border-bottom: 5px solid #000; overflow: hidden; }
    .two .div1 { background: #ccc; width: 200px; height:300px; position: absolute; top: 200px; }
    .two .div2 { background: #eee; width: 200px; height:200px; position: absolute; top: 100px; left: 100px; }
    .two .div3 { background: #aaa; width: 200px; height:200px; position: absolute; top: 100px; left: 150px; }

JavaScript/jQuery

$(document).ready(function(){
    $.stellar()
});

HTML

<body data-stellar-background-ratio="0.1">
<section class="one">
    <div class="div1" data-stellar-ratio="1"></div>
    <div class="div2" data-stellar-ratio=".5"></div>
    <div class="div3" data-stellar-ratio=".3"></div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
</section>
<section class="two">
    <div class="div1" data-stellar-ratio="1"></div>
    <div class="div2" data-stellar-ratio=".5"></div>
    <div class="div3" data-stellar-ratio=".3"></div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
</section>

</body>
wickywills
  • 4,024
  • 2
  • 38
  • 54
  • I have a similar issue with jerky backgrounds but only in IE ([link](http://stackoverflow.com/questions/22202573/stellarjs-not-behaving-correctly-in-ie)) – Bruno Camarneiro Mar 07 '14 at 11:31

2 Answers2

1

I had this problem a month ago. I think it's ok in JSfiddle because the render window is small and it has a simple html code.

As the project I was working on needed to be really smooth / speed with a heavy HTML structure and lots of CSS animations, I had to do that effect from scratch with jQuery just with a simple $(window).scroll() and configuring the top property of my elements (position: absolute).

enguerranws
  • 8,087
  • 8
  • 49
  • 97
  • Oddly though, it's also perfectly smooth when the results window is viewed full screen within JSFiddle - http://jsfiddle.net/f3dku/2/embedded/result/. I would prefer to use something like stellar.js, due to the complexity and time (or lack of!) I have for my project. If it comes to it, I could do it all manually, but stellar will make things so much easier as the complexity increases. – wickywills Jan 14 '14 at 10:23
  • It's jumpy and not really smooth on my computer (Win/Chrome). – enguerranws Jan 14 '14 at 10:29
  • Guess it depends on PC spec, but it's still noticibly smoother using JSFiddle than when viewed locally regardless of browser size (I'm on a very high-spec computer here and it's still jerky!). The stellar.js website has a ton of divs, yet still manages to be perfectly smooth. I only have a few divs and mines jerky :( – wickywills Jan 14 '14 at 10:31
  • My project had tons of div / elements to scroll with big img as backgrounds. Stellar couldn't do the job. Try to upload your local copy, and see how it's render ? – enguerranws Jan 14 '14 at 11:24
  • Code uploaded (http://wickywills.com/misc/stellar/index.html) - still jerky, even when the browser window is shrunk. Given that the stellar.js website works perfectly smoothly, it's clearly something I'm doing wrong - yet to find out what though!! – wickywills Jan 14 '14 at 11:27
1

Don't know if still open but might help: add:

background-attachment:fixed
Unihedron
  • 10,902
  • 13
  • 62
  • 72
hichtibidi
  • 11
  • 1