jarallax icon indicating copy to clipboard operation
jarallax copied to clipboard

Angular Example?

Open Steven4294 opened this issue 6 years ago • 9 comments

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

Steven4294 avatar Nov 09 '18 20:11 Steven4294

bump 👍

Steven4294 avatar Nov 14 '18 00:11 Steven4294

bump 👍

hewford avatar Feb 11 '19 19:02 hewford

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.

anystar avatar May 14 '19 01:05 anystar

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;

thegreatyamori avatar Oct 05 '19 04:10 thegreatyamori

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.

wikimodels avatar Oct 15 '19 01:10 wikimodels

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]'));

solidsanity avatar Oct 17 '19 14:10 solidsanity

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

Angular could not find jarallaxVideo or jarallaxElements in 'jarallax'

it is strange,, using angular 15

image

bdairy avatar Mar 22 '23 10:03 bdairy

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

fayeBabacar78 avatar May 09 '23 11:05 fayeBabacar78

  • 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

degrootsde avatar Mar 30 '24 07:03 degrootsde