peachananr / onepage-scroll

Create an Apple-like one page scroller website (iPhone 5S website) with One Page Scroll plugin
http://peachananr.github.io/onepage-scroll/Demo/demo.html
9.54k stars 2.07k forks source link

No index when using $(".main").moveTo(3); #69

Open JWestarp opened 10 years ago

JWestarp commented 10 years ago

Hi,

i use the index to trigger some animations. But when I use the moveTo function the index is "undifined"

Am I doing anything wrong?

->

$(".main").onepage_scroll({
    sectionContainer: "section",
    asing: "ease", // Easing options accepts the CSS3 easing animation such "ease", "linear", "ease-in", "ease-out", "ease-in-out", or even cubic bezier value such as "cubic-bezier(0.175, 0.885, 0.420, 1.310)"
    animationTime: 2000, 
    direction: 'horizontal',
    afterMove: function(index) {
            console.log(index);
            if (index == 1) {
                // do something
            }
            if (index == 2) {
                // do something
            }
            if (index == 3) {
                // do something
            }
    },
});
$("#link").click(function() {
    $(".main").moveTo(2);
});
thasmo commented 10 years ago

You got a typo in asing: "ease" but not sure if that helps. ;) I have no problems with moveTo.

JWestarp commented 10 years ago

oops.. thx :) but this doesn't solve the problem.

i noticed that the first menu-item still got the class "active" after moveTo... because there is no id (wich triggers the css-style) my work-arround looks now like this:

$("#link").click(function() {
    $('.onepage-pagination li a').removeClass('active');
    $(".main").moveTo(2);
    $('.onepage-pagination li:nth-child(2)').addClass('active');
});
chakzefir commented 9 years ago

have anybody solved this issue ? cause i have the same trouble

$('.go_to_service').on('click', function(e){
        e.preventDefault();
        $('.main').moveTo(2);
    });
acandael commented 9 years ago

I'm having the same issue, when I click the link that should get me to the third section on my page, I get this error in the console:

Uncaught TypeError: undefined is not a function

my jQuery code looks like this:

  $(".project").on("click", function(event) {
    event.preventDefault();
    $(".main").moveTo(2);
  });
AleksyukAleksander commented 9 years ago

$('.nav-links').each(function(index){ $(this).click(function(e){ e.preventDefault(); $(".main").moveTo(index+1); }); this works but idontknow how