Hello, I am designing an application with ionic in which I added in the folder “assets” library Hammer.js then a file “.js” in which I have implemented actions with this library. Unfortunately, this does not work, the events are not detected.
Here is an example of use:
HTML in ionic page
<div id="contentModel"> </div>
in JS file in asset
hammer = new Hammer.Manager( document.getElementById("contentModel"));
hammer.add(new Hammer.Pinch({ event: 'press'}));
hammer.on('press', function(ev){ console.log("toto");});
Need Help
It’s ok i found my error you can close this message
Could you please share the solution to the problem?
- You need to import the lib hammer.js in asset, and add the path in index.html.
- In your file html, create the all element that you want.
- In your file “js”, create the the object hammer as my first message. And create
var myObjectTs; function startNavigation(mynameclass){ myObjectTs = mynameclass }
- in your file “ts”, add before your class:
declare function startNavigation(mynameclass);
and in the constructor add :
startNavigation(this);
- now you can call function on your file ts when you press a element as :
hammer = new Hammer.Manager( document.getElementById("contentModel"));
hammer.add(new Hammer.Pinch({ event: 'press'}));
hammer.on('press', function(ev){myObjectTs.functionInFileTs()});
1 Like