lukehaas / Scrollify

A jQuery plugin that assists scrolling and snaps to sections.
MIT License
1.8k stars 578 forks source link

Removed JQuery dependency #380

Open cyruscook opened 5 years ago

cyruscook commented 5 years ago

I wanted to use this on a website I'm building that doesn't have JQuery, so I rewrote the plugin to use vanilla JS.

It's seems to be working fine, and I'm implementing it into my own project right now, however I wondered if you'd like to include my changes in the base repo? There's practically no reason to use JQuery as it takes 100ms to load (on my computer) and nearly everything is achievable without it.

If you do want to use my code, please tell me as I will have to make some changes.

lukehaas commented 5 years ago

This is an amazing contribution, thank you. I will review your PR and try it out on the example pages. If it's all good, I'll certainly want to merge this in.

lukehaas commented 5 years ago

One thing to note, as you're using modern JavaScript, we'll need to introduce Babel to transpile this for older browser support.

cyruscook commented 5 years ago

Ah, ok, hadn't been thinking about that. Would that involve a development file and a production file? I guess that would also mean that we could compress the production file which would be beneficial.

I've given you access to my fork btw if that helps (https://github.com/cyruscook/Scrollify/invitations)

cyruscook commented 5 years ago

I believe line 917 (if(panel.originalEvent)) is checking if panel is a JQuery event obj? I'm not too sure why that is however, as if I'm not mistaken panel is meant to be either the index or name of a panel. Do you know what that's meant to be for?

lukehaas commented 5 years ago

Regarding (if(panel.originalEvent)) I think the intention here was to enable something like this: $('a').click($.scrollify.move)

But I don' think I ever documented this so it's probably not used like that by anyone. Happy for you to remove this.

cyruscook commented 5 years ago

I've compressed the file and run it through babel. I've fixed a lot of things, but I've added a Known Issues section to the readme. I'm currently in the process of debugging them.

cyruscook commented 5 years ago

I'm having some trouble currently, could you help me?

When offset is called on page load, it returns incorrect values, which is why the page snaps. If you check the array heights, its been populated with these incorrect heights. For some reason though, it seems that running the function again makes it work - I'm guessing if this is a problem with the page not fully loading yet?

lukehaas commented 5 years ago

@cyruscook I'll take a look into that