Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery changing scrollleft position if statement(for image swap) depending on screen resolution
    primarykey
    data
    text
    <p>i have a horizontal sliding website.Depending on your scroll position I have image swaps to show where on the page you are. I want to be able depending on the screen resolution(browser resize) to change the scroll position if statement of image swaps. My code is:</p> <pre><code> $(window).scroll(function(){ if(($(window).scrollLeft() &gt;= 0)&amp;&amp; ($(window).scrollLeft() &lt;= 1040)){ $(".wrapper").css('background','url(img/naboutus.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 1041)&amp;&amp; ($(window).scrollLeft() &lt;= 2840)){ $(".wrapper").css('background','url(img/nwhatwedo.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 2841)&amp;&amp; ($(window).scrollLeft() &lt;= 4640)){ $(".wrapper").css('background','url(img/ntheory.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 4641)&amp;&amp; ($(window).scrollLeft() &lt;= 8424)){ $(".wrapper").css('background','url(img/nportfolio.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 8424)&amp;&amp; ($(window).scrollLeft() &lt;= 11124)){ $(".wrapper").css('background','url(img/nclients.png) 95% top no-repeat fixed'); }else { $(".wrapper").css('background','url(img/ncontacts.png) 95% top no-repeat fixed'); } }); </code></pre> <p>This is for a screen resolution with width 1680px. So if the screen resolution width is say 1440px I would like the scroll position image swaps to change so effectively you would have say this code:</p> <pre><code> $(window).scroll(function(){ if(($(window).scrollLeft() &gt;= 0)&amp;&amp; ($(window).scrollLeft() &lt;= 840)){ $(".wrapper").css('background','url(img/naboutus.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 841)&amp;&amp; ($(window).scrollLeft() &lt;= 1681)){ $(".wrapper").css('background','url(img/nwhatwedo.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 1682)&amp;&amp; ($(window).scrollLeft() &lt;= 2522)){ $(".wrapper").css('background','url(img/ntheory.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 2523)&amp;&amp; ($(window).scrollLeft() &lt;= 3363)){ $(".wrapper").css('background','url(img/nportfolio.png) 95% top no-repeat fixed'); } else if(($(window).scrollLeft() &gt;= 8224)&amp;&amp; ($(window).scrollLeft() &lt;= 10924)){ $(".wrapper").css('background','url(img/nclients.png) 95% top no-repeat fixed'); }else { $(".wrapper").css('background','url(img/ncontacts.png) 95% top no-repeat fixed'); } }); </code></pre> <p>The test site is on <a href="http://karpouzaki.com/fade/" rel="nofollow">http://karpouzaki.com/fade/</a></p> <p>I hope I explained it clearly enough what I m looking to do. If you need any more clarification please do not hesitate to ask.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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