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

Able to provide a simpler example of usage for this? #5

Open
poobutt opened this issue Nov 16, 2018 · 1 comment
Open

Able to provide a simpler example of usage for this? #5

poobutt opened this issue Nov 16, 2018 · 1 comment

Comments

@poobutt
Copy link

poobutt commented Nov 16, 2018

Would love to try it out but don't understand the Usage info in your readme.

@estrattonbailey
Copy link
Member

Hey @poobutt thanks for the issue!

First, you'll need to be using something to compile your javascript, like webpack or browserify or similar. Alternatively, you could toss <script src='https://unpkg.com/[email protected]/dist/paralless.umd.js'></script> into your page and use it directly as window.paralless.

Then:

  1. Define data attributes on the elements you want to parallax, according to the README
  2. Call paralless()() to kick things off

The docs are a little confusing because this library was built for use in a single page application SPA. In that case, what I do is create an instance and assign it to a variable like parallax, and then call that instance when the page changes.

const parallax = paralless() // does not start parallaxing yet

parallax() // start parallaxing

/**
 * Psuedo-code
 */
router.on('update', () => {
  parallax() // bind parallax to any new dom nodes
})

/**
To destroy the instance and stop parallaxing,
call the function returned from each parallax() call

  parallax()()

which is the same as

  const destroy = parallax()
  destroy()

*/

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