0

At the moment for my parallax site i have next and previous buttons on each section. I would like to just have one set of prev/next navigation that will go to each section.

Can you advise me on whitch route to go down please?

html:

<head>
    <title>The history of aeronautics</title>

    <meta charset="utf-8" />
    <meta name="description" content="A parallax scrolling experiment using jQuery" />

    <link rel="stylesheet" media="all" href="css/main.css" />

    <script src="js/modernizr.custom.37797.js"></script> 
    <!-- Grab Google CDN's jQuery. fall back to local if necessary --> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
    <script>!window.jQuery && document.write('<script src="/js/jquery-1.6.1.min.js"><\/script>')</script>
    <script src="js/parallax.js"></script>
</head>

<body>

    <div id="wrapper">

        <div id="car"><img src="images/car.png"></div>

        <nav id="primary">
            <ul>
                <li>
                    <h1>Hospital</h1>
                    <a class="hospital" href="#hospital">View</a>
                </li>
                <li>
                    <h1>University</h1>
                    <a class="university" href="#university">View</a>
                </li>
                <li>
                    <h1>Health Centre</h1>
                    <a class="health-centre" href="#health-centre">View</a>
                </li>
                <li>
                    <h1>Horiba HQ</h1>
                    <a class="horiba-hq" href="#horiba-hq">View</a>
                </li>
                <li>
                    <h1>Entertainment Hub</h1>
                    <a class="entertainment-hub" href="#entertainment-hub">View</a>
                </li>
                <li>
                    <h1>Vet</h1>
                    <a class="vet" href="#vet">View</a>
                </li>
                <li>
                    <h1>General Hospital</h1>
                    <a class="general-hospital" href="#general-hospital">View</a>
                </li>
            </ul>
        </nav>

        <div id="content">
            <article id="hospital">
            <a href="#"><img src="images/image1.png"/></a>
                <ul class="ch-grid">
                <li>
                    <div class="ch-item ch-img-2">
                        <div class="ch-info">
                            <h3><a class="university" href="#university">Next</a></h3>
                        </div>
                    </div>
                </li>
                </ul>
            </article>

            <article id="university">
            <a href="#"><img src="images/image2.png"/></a>
                <ul class="ch-grid">
                <li>
                    <div class="ch-item ch-img-1">
                        <div class="ch-info">
                            <h3><a class="hospital" href="#hospital">Prev</a></h3>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="ch-item ch-img-2">
                        <div class="ch-info">
                            <h3><a class="health-centre" href="#health-centre">Next</a></h3>
                        </div>
                    </div>
                </li>
                </ul>
            </article>

            <article id="health-centre">
            <a href="#"><img src="images/image3.png"/></a>
                <ul class="ch-grid">
                <li>
                    <div class="ch-item ch-img-1">
                        <div class="ch-info">
                            <h3><a class="university" href="#university">Prev</a></h3>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="ch-item ch-img-2">
                        <div class="ch-info">
                            <h3><a class="horiba-hq" href="#horiba-hq">Next</a></h3>
                        </div>
                    </div>
                </li>
                </ul>
            </article>

            <article id="horiba-hq">
            <a href="#"><img src="images/image4.png"/></a>
                <ul class="ch-grid">
                <li>
                    <div class="ch-item ch-img-1">
                        <div class="ch-info">
                            <h3><a class="health-centre" href="#health-centre">Prev</a></h3>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="ch-item ch-img-2">
                        <div class="ch-info">
                            <h3><a class="entertainment-hub" href="#entertainment-hub">Next</a></h3>
                        </div>
                    </div>
                </li>
                </ul>
            </article>
            <article id="entertainment-hub">
            <a href="#"><img src="images/image5.png" /></a>
                <ul class="ch-grid">
                <li>
                    <div class="ch-item ch-img-1">
                        <div class="ch-info">
                            <h3><a class="horiba-hq" href="#horiba-hq">Prev</a></h3>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="ch-item ch-img-2">
                        <div class="ch-info">
                            <h3><a class="vet" href="#vet">Next</a></h3>
                        </div>
                    </div>
                </li>
                </ul>
            </article>
            <article id="vet">
            <a href="#"><img src="images/image6.png"/></a>
                <ul class="ch-grid">
                <li>
                    <div class="ch-item ch-img-1">
                        <div class="ch-info">
                            <h3><a class="entertainment-hub" href="#entertainment-hub">Prev</a></h3>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="ch-item ch-img-2">
                        <div class="ch-info">
                            <h3><a class="general-hospital" href="#general-hospital">Next</a></h3>
                        </div>
                    </div>
                </li>
                </ul>
            </article>
            <article id="general-hospital">
            <a href="#"><img src="images/hospital.png"/></a>
                <ul class="ch-grid">
                <li>
                    <div class="ch-item ch-img-1">
                        <div class="ch-info">
                            <h3><a class="vet" href="#vet">Prev</a></h3>
                        </div>
                    </div>
                </li>
                </ul>
            </article>
        </div>

        <!-- Parallax foreground -->
        <div id="parallax-bg3">

        </div>

        <!-- Parallax  midground clouds -->
        <div id="parallax-bg2">
            <img id="bg2-1" src="images/blurred-buildings.png" />

        </div>

        <!-- Parallax  background clouds -->
        <div id="parallax-bg1">
            <img id="bg1-1" src="images/clouds.png" />

        </div>

    </div>

</body>

js: $(document).ready(function() {

                    redrawDotNav();

                    /* Scroll event handler */
                    $(window).bind('scroll',function(e){
                        parallaxScroll();
                        redrawDotNav();
                    });

                    /* Next/prev and primary nav btn click handlers */
                    $('a.hospital').click(function(){
                        $('html, body').animate({
                            scrollTop:0
                        }, 1000, function() {
                            parallaxScroll(); // Callback is required for iOS
                        });
                    });
                    $('a.university').click(function(){
                        $('html, body').animate({
                            scrollTop:1500
                        }, 1000, function() {
                            parallaxScroll(); // Callback is required for iOS
                        });
                    });
                    $('a.health-centre').click(function(){
                        $('html, body').animate({
                            scrollTop:3800
                        }, 1000, function() {
                            parallaxScroll(); // Callback is required for iOS
                        });
                        return false;
                    });
                    $('a.horiba-hq').click(function(){
                        $('html, body').animate({
                            scrollTop:5500
                        }, 1000, function() {
                            parallaxScroll(); // Callback is required for iOS
                        });
                    });


                    $('a.entertainment-hub').click(function(){
                        $('html, body').animate({
                            scrollTop:6800
                        }, 1000, function() {
                            parallaxScroll(); // Callback is required for iOS
                        });
                    });
                    $('a.vet').click(function(){
                        $('html, body').animate({
                            scrollTop:7700
                        }, 1000, function() {
                            parallaxScroll(); // Callback is required for iOS
                        });
                    });
                    $('a.general-hospital').click(function(){
                        $('html, body').animate({
                            scrollTop:11000
                        }, 1000, function() {
                            parallaxScroll(); // Callback is required for iOS
                        });
                    });





                    /* Show/hide dot lav labels on hover */
                    $('nav#primary a').hover(
                        function () {
                            $(this).prev('h1').show();
                        },
                        function () {
                            $(this).prev('h1').hide();
                        }
                    );

                });

                /* Scroll the background layers */
                function parallaxScroll(){
                    var scrolled = $(window).scrollTop();
                    $('#content').css('left',(0-(scrolled*.9))+'px');
                    $('#parallax-bg1').css('left',(0-(scrolled*.25))+'px');
                    $('#parallax-bg2').css('left',(0-(scrolled*.5))+'px');
                    $('#parallax-bg3').css('left',(0-(scrolled*.9))+'px');
                }

                /* Set navigation dots to an active state as the user scrolls */
                function redrawDotNav(){
                    var section1Top =  0;
                    // The top of each section is offset by half the distance to the previous section.
                    var section2Top =  $('#university').offset().left + 1000;
                    var section3Top =  $('#health-centre').offset().left +3000;
                    var section4Top =  $('#horiba-hq').offset().left +4000;
                    var section5Top =  $('#entertainment-hub').offset().left +6000;
                    var section6Top =  $('#vet').offset().left +6800;
                    var section7Top =  $('#general-hospital').offset().left +9100;

                    $('nav#primary a').removeClass('active');
                    if($(document).scrollTop() >= section1Top && $(document).scrollTop() < section2Top){
                        $('nav#primary a.hospital').addClass('active');
                    } else if ($(document).scrollTop() >= section2Top && $(document).scrollTop() < section3Top){
                        $('nav#primary a.university').addClass('active');
                    } else if ($(document).scrollTop() >= section3Top && $(document).scrollTop() < section4Top){
                        $('nav#primary a.health-centre').addClass('active');
                    } else if ($(document).scrollTop() >= section4Top && $(document).scrollTop() < section5Top){
                        $('nav#primary a.horiba-hq').addClass('active');
                    } else if ($(document).scrollTop() >= section5Top && $(document).scrollTop() < section6Top){
                        $('nav#primary a.entertainment-hub').addClass('active');
                    } else if ($(document).scrollTop() >= section6Top && $(document).scrollTop() < section7Top){
                        $('nav#primary a.vet').addClass('active');


                    } else if ($(document).scrollTop() >= section7Top){
                        $('nav#primary a.general-hospital').addClass('active');
                    } 

                }

I have tried adding this which can be seen here but it doesnt click through to the next section

js used:

    $(function() {

            var $tabs = $('#content').tabs();

            $(".ui-tabs-panel").each(function(i){

              var totalSize = $(".ui-tabs-panel").size() - 1;

              if (i != totalSize) {
                  next = i + 2;
                  $(this).append("<a href='#' class='next-tab mover' rel='" + next + "'>Next Page &#187;</a>");
              }

              if (i != 0) {
                  prev = i;
                  $(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'>&#171; Prev Page</a>");
              }

            });

            $('.next-tab, .prev-tab').click(function() { 
                   $tabs.tabs('select', $(this).attr("rel"));
                   return false;
               });


        });

Sorry about long post wanted to give as much info as possible

Thanks

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • What I have done is here [link](http://horiba.creativebridgedigital.com/test2.html) I used the code above under js used: – user2682105 Aug 22 '13 at 13:18

1 Answers1

1

You didn't insert anchor tag in href next page, you need to add it for each section of page, then automatically will go to next or previous page by clicking on that.. cause you just insert (#) so thats why nothing happened...

Amin
  • 414
  • 1
  • 11
  • 23
  • Don't forget to add for all of sections, even for next and previous page, you already have anchors, like car, primary, content, parallax-bg3, parallax-bg2, parallax-bg1 .. :-) – Amin Sep 16 '13 at 05:46
  • I forgot to say, you can also use anchors in up of your page, if you add those names, result will be same, I mean hospital, university, health care and .... – Amin Sep 16 '13 at 05:49