malihu / page-scroll-to-id

Animated page scrolling to specific id within the document with jquery.
MIT License
224 stars 98 forks source link

onComplete, onStart callbacks not being triggered #13

Open RusinovAnton opened 7 years ago

RusinovAnton commented 7 years ago

Hello, thanks for library. I'm using latest version of mPageScroll2id and jQuery 1.9.1. The following snippet shows how I init it on my page:

 $("a[href^='#'], a[rel='m_PageScroll2id']").mPageScroll2id({
        highlightSelector: ".my-selector a",
        offset: 50,
        onStart: function() {
          console.log(arguments);
          console.log(this);
        },
        onComplete: function() {
          console.log(arguments);
          console.log(this);
        }
});

None of console.log is called.

RusinovAnton commented 7 years ago

@malihu Also in the example on site you're using some variable mPS2id which I cannot understand how to get:

$("a[rel='m_PageScroll2id']").mPageScroll2id({
    onStart:function(){
        myCustomFn1();
    },
    onComplete:function(){
        myCustomFn2();
    }
});

function myCustomFn1(){
    console.log(mPS2id.target.attr("id"));
}
function myCustomFn2(){
    console.log(mPS2id.scrollTo.y);
}