marrio-h / universal-parallax

Easy parallax plugin using pure javascript. Also works on mobile platforms. Cross browser support.
MIT License
115 stars 24 forks source link

Can't export #11

Open sashor opened 5 years ago

sashor commented 5 years ago

Hello,

First, thanks for this awesome lib! I would like to use it using "import ..." instead of including it with a script tag. Any reason why you didn't expose the function with an "export .... "?

marrio-h commented 5 years ago

Hi,

Thank you @sashor, really glad you like it!

Haven't thought of it tbh. I really should've been working a bit more on it, but if you want to update it please feel free to do so :)

sashor commented 5 years ago

I wasn't sure how to achieve what I need while keeping the vanilla js simplicity of your lib (👌), without making it go through babel and stuff to remain ok on all browsers.

So what I did is put the universalParallax var in window (in your lib).

And on my side, importing it normally like I would but call new window.universalParallax().init... and it does the trick for my kind of use case with minor change and without breaking anything for others.

I can try to push that when I get some time to test it out of my scope if you don't.