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

How to use in Angular 7 #57

Open
CarlosMal opened this issue Jun 12, 2020 · 1 comment
Open

How to use in Angular 7 #57

CarlosMal opened this issue Jun 12, 2020 · 1 comment

Comments

@CarlosMal
Copy link

CarlosMal commented Jun 12, 2020

(I'm sorry for my English)
I am trying to use ifVisible in angular 7 but I can't use it, can someone help me please?
What am I missing or what do I fail?

install it with npm and ifvisible,

in my package.json
"ifvisible": "1.1.0",

in my angular.json

"scripts": [
            "./node_modules/ifvisible/src/ifvisible.js"
          ],

my .ts

import {IfVisible} from "ifvisible / src / ifvisible.js";
const ifvisible = new IfVisible (window, document);

using it in a function:

 ifvisible.setIdleDuration (300);
   console.log (ifvisible);

I get this error:

TypeError: ifvisible_src_ifvisible_js__WEBPACK_IMPORTED_MODULE_6 __. IfVisible is not a constructor
TypeError: ifvisible_src_ifvisible_js__WEBPACK_IMPORTED_MODULE_6 __. IfVisible is not a constructor

@NevenLiang
Copy link

NevenLiang commented Sep 21, 2020

@CarlosMal Theres is no needs to add it to angular.json. You can use it in Angular like this.

import * as ifvisible from 'ifvisible.js';

ifvisible.on('idle', () => {
  console.log('it is idle now ...');
});

ifvisible.on('wakeup', () => {
  console.log('it wakes up!');
});

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