How to add ease to this, with jQuery Easing plugin.

Posted by user1691441 on Stack Overflow See other posts from Stack Overflow or by user1691441
Published on 2012-10-10T03:35:16Z Indexed on 2012/10/10 3:36 UTC
Read the original article Hit count: 237

Filed under:
|

I've asked this question previously before, and had a bit of help, but my lack of jQuery skills still didn't accomplish the job. I was wondering if anyone else could help me out with this.

I've tried adding easing: "easeIn" right after the duration section, but still didn't work for me. if anyone could help me out that would be wonderful. I'm using the jquery easing plugin

$(function() {

function scroll(direction) {

    var scroll, i,
            positions = [],
            here = $(window).scrollTop(),
            collection = $('.part');

    collection.each(function() {
        positions.push(parseInt($(this).offset()['top'],10));
    });

    for(i = 0; i < positions.length; i++) {
        if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
        if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
    }

    if (scroll) {
        $.scrollTo(scroll, {
            duration: 350       
        });
    }

    return false;
}

$("#next,#prev").click(function() {        
    return scroll($(this).attr('id'));        
});

$(".scrolltoanchor").click(function() {
    $.scrollTo($($(this).attr("href")), {
        duration: 350
    });
    return false;
});

});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about easing