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

Angular Example? #132

Open
Steven4294 opened this issue Nov 9, 2018 · 9 comments
Open

Angular Example? #132

Steven4294 opened this issue Nov 9, 2018 · 9 comments

Comments

@Steven4294
Copy link

Is there an angular example anywhere? Can't seem to get this working in my angular project... Thanks! :)

@Steven4294
Copy link
Author

bump 👍

1 similar comment
@hewford
Copy link

hewford commented Feb 11, 2019

bump 👍

@anystar
Copy link

anystar commented May 14, 2019

Start by adding the stylesheet in angular.json build section. Don't worry about the JS file, we'll deal with that.
"node_modules/jarallax/dist/jarallax.css"

To get Jarallax working in Angular I found that in my component I had to import Jarallax like so.

import { jarallax } from 'jarallax';

And then in ngInit I have to run

jarallax(document.querySelectorAll('.jarallax'));

And then in the component stylesheet add

.jarallax { width: 100%; height: 300px; }

I cannot get the settings to work and neither data attributes.

@thegreatyamori
Copy link

If you get the error: jarallax.esm.js:109 Uncaught ReferenceError: global is not defined at Module../node_modules/jarallax/src/jarallax.esm.js

Adding this line to polyfills.ts should resolve node global error
(window as any).global = window;

@wikimodels
Copy link

wikimodels commented Oct 15, 2019

I cannot get jarallax working in my angular 8 project. It shows back-ground images, no errors displayed. But no parallax effect either. Before angular project I tested jarallax with a common web site. Everything was fine.

@solidsanity
Copy link

solidsanity commented Oct 17, 2019

I cannot get jarallax working in my angular 8 project. It shows back-ground images, no errors displayed. But no parallax effect either. Before angular project I tested jarallax with a common web site. Everything was fine.

Hopefully this helps you all. With a little trial and error I got it working in my Angular 8 project...

  1. Install the NPM module for Jarallax

  2. Add these files to your angular.json file under scripts
    "node_modules/jarallax/dist/jarallax.min.js", "node_modules/jarallax/dist/jarallax-element.min.js", "node_modules/jarallax/dist/jarallax-video.min.js"

  3. In your component add the import
    import { jarallax, jarallaxElement, jarallaxVideo } from 'jarallax';

  4. Add the initializers in onInit()
    jarallaxVideo(); jarallax(document.querySelectorAll('.jarallax')); jarallaxElement();

  5. Add this to your polyfills.ts file
    (window as any).global = window;

  6. Finally, I found that the liteready module used to determine if the dom is ready breaks angular's lifecycle. So if you are using jaralax on subpages, you'll notice the jarallax elements do not work. To fix this, just add the following to your onInit().
    jarallax(document.querySelectorAll('[data-jarallax-element]'));

@bdairy
Copy link

bdairy commented Mar 22, 2023

  • import { jarallax, jarallaxElement, jarallaxVideo } from 'jarallax';

Angular could not find jarallaxVideo or jarallaxElements in 'jarallax'

it is strange,, using angular 15

image

@fayeBabacar78
Copy link

Hi @bdairy, I'm having the same using with the same Angular version. Did you come to a solution?

@degrootsde
Copy link

  • import { jarallax, jarallaxElement, jarallaxVideo } from 'jarallax';

Angular could not find jarallaxVideo or jarallaxElements in 'jarallax'

it is strange,, using angular 15

image

In typings.d.ts (node_modules/jarallax), jarallaxVideo is missing. You can add it and it should work.:

/** this is missing in typings.d.ts. */
export function jarallaxVideo(jarallaxInstance?: typeof jarallax): void

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

9 participants