Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks #46

Open
joaqib opened this issue Jun 27, 2018 · 2 comments
Open

Callbacks #46

joaqib opened this issue Jun 27, 2018 · 2 comments

Comments

@joaqib
Copy link

joaqib commented Jun 27, 2018

Hi tsuyoshiwada,

First of all thanks for the project because it seems amazing.
The problem I am encountering is that I am not able to create callbacks functions for the scroll.
The example option is in typescript but even if I change it to Plain JS and pass the object as the options, it does not work for me.

I just convert this code into JS and the console.log does not execute before the scrolls

`const scroller = new SweetScroll({

// Stop scrolling case of trigger element that contains the is-disabled class.
before: (offset: Offset, $trigger: Element | null, scroller: SweetScroll): boolean | void => {
console.log('Before!!', offset, scroller);
if ($trigger && $trigger.classList.contains('is-disabled')) {
return false;
}
},
});`

I have search Github for code using the callbacks of the sweet-scroll library without any success.
I hope this does not bother as I feel is more my fault than yours but I am in a complete roadblock.

Thanks for everything in advance!

@joaqib
Copy link
Author

joaqib commented Jun 28, 2018

Experimenting I just discovered that the callbacks are only executed when a method is called but not on the scroll, Is that the desired behavior??

@enoversum
Copy link

enoversum commented Oct 4, 2018

I was asking this myself, and it works as follows:

`document.addEventListener('DOMContentLoaded', function() {
var scroller = new SweetScroll({
// your options

  // After completion
  after: function after(offset, $trigger, scroller) {
    // what needs to be done after completion
  },
}, '#content');

}, false);`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants