Import Wow.js using Yarn and Sage 9

I thought I do a quick writeup on adding wow.js using Yarn, since this is commonly used along with animate.css

Install

In theme directory do:
yarn add wowjs

Load

Then in common.js add:

import {Wow} from 'wowjs';

export default {
init() {
// JavaScript to be fired on all pages
const wow = new Wow();
wow.init();
},
finalize() {
// JavaScript to be fired on all pages, after page specific JS is fired
},
};

Usage

You can then use it in your views:
class="wow bounceInUp"
3 Likes

Just for anyone else who happens across this answer. I was having difficulty implementing this as outlined above and it seems that the constructor should be all upper case. This answer from patrice was the solution that worked for me: Import WOW.js not working correctly with sage 9

So first
yarn add wowjs

Then in common.js

import {WOW} from 'wowjs';

export default {
  init() {
// JavaScript to be fired on all pages
const wow = new WOW();

wow.init();
  },
  finalize() {
// JavaScript to be fired on all pages, after page specific JS is fired
  },
};
1 Like