WOW icon indicating copy to clipboard operation
WOW copied to clipboard

WOW not defined using npm package.

Open jasonlam-swatow opened this issue 8 years ago • 32 comments

I did this:

npm install wowjs

and required it:

import WOW from 'wowjs

and tried to use it:

let wow = new WOW({
  boxClass: 'wow',
  animateClass: 'animated',
  offset: 0,
  live: true
});

But I got Uncaught ReferenceError: WOW is not defined at console.

jasonlam-swatow avatar May 24 '16 02:05 jasonlam-swatow

@jasonlam0619 run:

npm install wow.js

Then use:

import WOW from 'wow.js'
const wow = new WOW({
  boxClass: 'wow',
  animateClass: 'animated',
  offset: 0,
  live: true
});

graingert avatar Jun 08 '16 10:06 graingert

Hi grain I used wow.js instead of wowjs, because it is not working with import ... from 'wowjs'

and then tried the code you have provided.

when I run in my html <h1 class="nomargin size-50 weight-300 wow rollIn" data-wow-delay="0.5s"> blah blah </h1> <p class="lead font-lato size-30 wow fadeInUp" data-wow-delay="0.7s"> blah blah </p>

the output is it has no animate, see the screenshot:

screen shot 2016-09-06 at 11 41 40 pm

suarezph avatar Sep 06 '16 15:09 suarezph

@graingert unfortunately, the code you mentioned does not work. Something changed?

graphan avatar Sep 20 '16 17:09 graphan

@graingert i have tried this code, but did not worked :/

kaueburiti avatar Sep 28 '16 22:09 kaueburiti

any luck here?

johhansantana avatar Dec 07 '16 20:12 johhansantana

@jsantana90 i totally give up

kaueburiti avatar Dec 07 '16 20:12 kaueburiti

Same issue here...

suncoastkid avatar Dec 19 '16 16:12 suncoastkid

Same issue. Surely rather important as most developers are using NPM dependencies these days?

shealan avatar Jan 13 '17 20:01 shealan

same issue here, anyone found any solution?

badalsurana avatar Jan 25 '17 17:01 badalsurana

Not sure if this helps, but I got it to work using require and adding it to window.

bootstrap.js

const WOW = require('wowjs');

window.wow = new WOW.WOW({
    live: false
});

whatever.js

window.wow.init();

interphased avatar Feb 09 '17 21:02 interphased

new WOW.WOW().init();

in your HTML file works instead of having to place it in your app.js to compile.

ruchernchong avatar Mar 18 '17 16:03 ruchernchong

This didn't work either. I used new WOW.WOW().init() but it still doesn't work. I can see in the rendered html that the animated class is indeed being added, but the animation doesn't run.

adammoisa avatar May 17 '17 14:05 adammoisa

@adammoisa Did you import WOW in anywhere of your scripts?

ruchernchong avatar May 17 '17 15:05 ruchernchong

I'm getting the same problem, it used to work fine with this line in the controller: new WOW().init(); and importing the script in the index.html, now I get the same error and it just won't work at all

Steven-Garcia avatar May 18 '17 10:05 Steven-Garcia

@Ruchern yes of course. As I said it adds the animated class to the HTML which I think implies the package is 'working' to some degree...

adammoisa avatar May 18 '17 11:05 adammoisa

@adammoisa I'm sorry. I did not mean that.

Do you have window.WOW = require('wowjs')?

Try either window.WOW or window.WOW() I cannot remember which one I tried before. Ever since moving to UIKit, I took WOW out.

ruchernchong avatar May 18 '17 13:05 ruchernchong

the module exports an object, the WOW constructor function is inside the returned object.

const WOW = require('wowjs').WOW

gaboesquivel avatar Aug 06 '17 00:08 gaboesquivel

window.WOW = require('wowjs').WOW worked for me

xHeinrich avatar Aug 21 '17 14:08 xHeinrich

import { WOW } from 'wowjs'
window.WOW = WOW

Perhaps this might work too.

ruchernchong avatar Aug 21 '17 14:08 ruchernchong

With require

const {WOW} = require('wowjs');

Sydney-o9 avatar Dec 23 '17 00:12 Sydney-o9

To Leverage Undefined Values make sure that your DOMm is ready and likely when a dependent variable is not defined. When the page is loaded and ready, and likely when a dependent variable is already defined. For this use $(document).ready(function() { if ($.fn.init) { new WOW().init(); } });

TanvirAmi avatar Jan 28 '18 02:01 TanvirAmi

window.WOW = require('wowjs').WOW worked for me

This works like a charm

jhoanborges avatar Jan 26 '19 03:01 jhoanborges

window.WOW = require('wowjs').WOW worked for me

Thanks bro this work for me

mugianto avatar May 10 '19 23:05 mugianto

Not sure if this helps, but I got it to work using require and adding it to window.

bootstrap.js

const WOW = require('wowjs');

window.wow = new WOW.WOW({
    live: false
});

whatever.js

window.wow.init();

Thanks bro this work for me

766 avatar May 25 '19 06:05 766

window.WOW = require('wowjs').WOW;

  function wowAnimation() {
    new WOW({
      boxClass:   'wow',
      animateClass: 'animated',
      offset: 0,
      mobile: true
    }).init();
  }

  wowAnimation();

vipertecpro avatar Aug 26 '20 15:08 vipertecpro

React + Next js + typescript Works fine:

useEffect(() => {
        const WOW = require("wowjs/dist/wow.js");
        if (typeof window !== "undefined") {
            (window as any).WOW = WOW;
        }

        new WOW.WOW().init();
    }, []);

kshvab avatar Jul 16 '22 19:07 kshvab

Hello,我是林昕,我已收到来信~

veraLX avatar Jul 16 '22 19:07 veraLX

Try this, It works for me

// import wowjs if window is not undefined

const isServer = typeof window === "undefined";
const WOW = !isServer ? require("wowjs") : null;

// then write this code in the function

useEffect(() => {
    new WOW.WOW().init();
  }, []);

I hope this is useful ; )

Aaryan6 avatar Mar 18 '23 14:03 Aaryan6

it works for me : )

  • "@sveltejs/kit": "1.15.2",
  • "wow.js": "^1.2.2" (not wowjs)
npm i --save wow.js
import { onMount } from 'svelte'

onMount(async () => {
	import('wow.js').then((WOW) => {
		new WOW.default().init()
	})
})

or

onMount(async () => {
	const wow = await import('wow.js')
	new wow.default().init()
})

harapeko avatar Apr 21 '23 14:04 harapeko

https://github.com/matthieua/WOW/issues/252#issuecomment-1517949732 Harepo how does it work for you with sveltekit? I have it implemented but none of the animations work. Did you do have to do some extra work to make it work?

Cayllen avatar May 15 '23 21:05 Cayllen