Hi all,
I am trying to use webgazer.js, a an eye-tracking library that comes as a single javascript file.
Following a bit of research online, I added the script to the src/assets/js/
directory and added the webgazer.js file as a script in the index.html
of my app (within <head>
):
<script async src="./assets/js/webgazer.js" type="text/javascript"></script>
I then created a page using
ionic g page test-eye-tracking-page
and used the webgazer
object in test-eye-tracking-page.ts
:
export class TestEyeTrackingPage {
constructor(public navCtrl: NavController, public navParams: NavParams) {}
ionViewDidEnter() {
//start the webgazer tracker
webgazer.begin()
}
When visiting the eye tracking test page, I get the error webgazer is undefined
Alternatively, I tried to use webgazer.js as a third party module, since the gitHub repo contains a package.json
file.
Following the documentation, I added webgazer as a dependency
npm install github:brownhci/WebGazer --save
There is now a node_modules/webgazer/
repository. I then built the webgazer.js
file and added it in nodes_modules/webgazer/
.
Using the library in test-eye-tracking-age.ts
import * as webgazer from 'webgazer'
or
import 'webgazer'
leads to 'webgazer is undefined'
.
Any advice on how to use the webgazer library ?