Scrollify icon indicating copy to clipboard operation
Scrollify copied to clipboard

Removed JQuery dependency

Open cyruscook opened this issue 6 years ago • 8 comments

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.

  • First off, I use tabs instead of spaces, but I can revert that.
  • Secondly, I put my { on a new line, however I can revert that too.
  • Thirdly, I couldn't get the animations to be the same when animating it with vanilla JS. I'm not too sure why this is, however there will be a difference both in speed and interpolation when using the new code (however I've gotta say I prefer this version's).
  • Fourth, I'm not using NodeJS so I haven't debugged it for that, however I suspect it won't be working for that.

cyruscook avatar May 02 '19 19:05 cyruscook

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 avatar May 03 '19 08:05 lukehaas

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

lukehaas avatar May 03 '19 10:05 lukehaas

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 avatar May 03 '19 13:05 cyruscook

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?

cyruscook avatar May 03 '19 13:05 cyruscook

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.

lukehaas avatar May 03 '19 13:05 lukehaas

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 avatar May 03 '19 18:05 cyruscook

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?

cyruscook avatar May 03 '19 19:05 cyruscook

@cyruscook I'll take a look into that

lukehaas avatar May 06 '19 17:05 lukehaas