hammerjs / simulator Goto Github PK
View Code? Open in Web Editor NEWSimulate gestures for testing purposes.
License: MIT License
Simulate gestures for testing purposes.
License: MIT License
For unit-testing parts of our web application I want to simulate touch events. Could you provide some examples for this? (I am using the HammerJS jQuery plugin and the Jasmine framework).
It seems this is not published to npm/bower.
I have been trying to use this in webdriverio tests. When running driving an instance of chrome, hammer doesn't detect touch support, so listens for mouse events instead. The simulator can only emit touch/pointer events, meaning this cannot be used for tests as it stands.
When I use Simulator.gestures.pinch
, I expect a pinch event to eventually fire with the scale I specify as an option. So, in the following test case:
package.json:
{
"dependencies": {
"hammer-simulator": "0.0.1",
"hammerjs": "2.0.8"
}
}
index.html:
<body>
<div class="test-element"></div>
<script src="node_modules/hammerjs/hammer.js"></script>
<script src="node_modules/hammer-simulator/index.js"></script>
<script src="test.js"></script>
</body>
test.js:
(function () {
'use strict';
var element = document.querySelector('.test-element');
var hammertime = new Hammer(element);
hammertime.get('pinch').set({enable: true});
hammertime.on('pinch', function (event) {
console.log('event.scale', event.scale);
});
Simulator.gestures.pinch(element, {
scale: 2.0
});
}());
I expect that an event.scale
of 2
will eventually be logged. However, the final value to be printed is only 1.9230769230769231
. Is this expected or is it a bug?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.