Note that there are some explanatory texts on larger screens.

plurals
  1. POFeature detection for parallax / background-position
    primarykey
    data
    text
    <p>Ok, so I've created my own parallaxing jQuery/JS script, but I just don't know how to target browsers that will support the following (needs the following):</p> <ul> <li>Supports transition for background-position</li> </ul> <p>The site (preview) I'm trying this at is: <a href="http://bringmebusiness.com.au/downloads/test/" rel="nofollow">My Test Site</a></p> <p>How can I detect whether a browser will support this though? Can I run media queries bases on window width? Do I have to browser sniff? I can't see anything on the WWW that gives me clues as to how I can feature-detect for this.</p> <p>Any help would be greatly appreciated.</p> <p>My JS code is here: (please feel free to use it if you like it)</p> <pre><code>var goTop = 0; var thisGoTop = 0; var thisHeight = 0; var thisWinH = 0; var bottomIntrusion = 0; var thisMax = 0; var bgPos = 0; function parallax(){ goTop = $(window).scrollTop(); thisWinH = $(window).height(); $('div.para').each(function(){ thisGoTop = $(this).offset().top; thisHeight = $(this).height(); thisMax = Math.floor(thisHeight * 0.3); bottomIntrusion = (thisGoTop + (thisHeight / 2) - goTop) / thisWinH; if (bottomIntrusion &gt; 0) { bgPos = 0 - (Math.floor(thisMax * bottomIntrusion)); $(this).css('background-position','center ' + bgPos + 'px'); } }); } parallax(); $(window).scroll(function(){ parallax(); }); </code></pre> <p><strong>Edit:</strong> I've looked into the Modernizr library, and I haven't found anything that gives me clues about background-position transform support for CSS3. I'm getting real close to brower sniffing at this point, and I'd hate to go there.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload