Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding infinity scrollpath when pressing button
    primarykey
    data
    text
    <p>Hoping someone can help me. I'm trying to create a rollercoaster ride, which must go down, as long as a new track is added. I've added a button on top, which have 2 paths. These paths must be generated one at a time, but below each other. My code so far:</p> <pre><code>$(window).load(function(){ $(document).ready(); function pathOne(){ var roadDiv = document.createElement("div"); var roadImage = document.createElement("div"); roadDiv.className = "road1"; roadImage.className = "roadImage1" $('.wrapper').append(roadDiv); $(roadDiv).append(roadImage); $.fn.scrollPath("getPath") .moveTo(340, 50, {}) .lineTo(340, 300, {rotate: .1}) .lineTo(340, 300, {rotate: .7}) .lineTo(620, 600, {}) .rotate(0, {}) .lineTo(620, 820, {}) .rotate(- .8, {}) .lineTo(160, 1280, {}) .rotate(0, {}) .lineTo(160, 1484, {}) } function pathTwo(){ var roadDiv = document.createElement("div"); var roadImage = document.createElement("div"); roadDiv.className = "road2"; roadImage.className = "roadImage2" $('.wrapper').append(roadDiv); $(roadDiv).append(roadImage); $.fn.scrollPath("getPath") //.moveTo(160, 1580, {}) .lineTo(160, 1580, {}) .rotate(-.8, {}) .lineTo(-80, 1820, {}) .rotate(0, {}) .lineTo(-80, 2190, {}) .rotate(.8, {}) .lineTo(180, 2460, {}) .rotate(0, {}) .lineTo(180, 2680, {}) .rotate(-.8, {}) .lineTo(50, 2820, {}) .rotate(0, {}) .lineTo(50, 2918, {}) } $(".addRow").click(function(){ if ($(".wrapper").is(':empty')) { pathOne(); //alert("added pathOne"); } else if ( $('.road1').length &gt; 0 ){ pathTwo(); alert("added pathTwo"); return; } $(".wrapper").scrollPath({drawPath: false, wrapAround: false, scrollBar: true}); }); function ordinal(num) { return num + ( (num % 10 == 1 &amp;&amp; num % 100 != 11) ? 'st' : (num % 10 == 2 &amp;&amp; num % 100 != 12) ? 'nd' : (num % 10 == 3 &amp;&amp; num % 100 != 13) ? 'rd' : 'th' ); } }); </code></pre> <p>The demo can be seen here: <a href="http://graahf.dk/rollercoaster/rollercoaster_demo.html" rel="nofollow">rollercoaster track</a></p> <p>My problem is that, when I add a new track it most always add it below other tracks and switch between track 1(pathOne) and track 2(pathTwo). Starting with track 1, pressing button adds track 2, press again it should add track 1 below track 2 and so on.</p> <p>Any help would be sweet :)</p> <p>I'm useing the plugin from <a href="http://joelb.me/scrollpath/" rel="nofollow">here</a></p>
    singulars
    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