diff --git a/.gitignore b/.gitignore index da23d0d..106ffc1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,26 @@ -# Logs -logs -*.log - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -# Deployed apps should consider commenting this line out: -# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git -node_modules +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Deployed apps should consider commenting this line out: +# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git +node_modules +.idea/ diff --git a/README.md b/README.md index 595fdd3..5d1b571 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,12 @@ npm install hammer-touchemulator ``` ## How to use -Include the javascript file, and call the `Emulator()` function before any other libraries that do something with the +Include the javascript file, and call `TouchEmulator.start()` before any other libraries that do something with the touch input. It will set some fake properties to spoof the touch detection of some libraries, and triggers `touchstart`, `touchmove` and `touchend` events on the mouse target. ````html - + ```` ````js @@ -42,6 +42,9 @@ document.body.addEventListener('touchend', log, false); Also, the script includes polyfills for `document.createTouch` and `document.createTouchList`. +You can stop the touch emulator with `TouchEmulator.stop()` and restart it with another call to `TouchEmulator.start()`. +In previous versions, the emulator was started by calling `TouchEmulator()`; that continues to work, too. + ## How it works It listens to the `mousedown`, `mousemove` and `mouseup` events, and translates them to touch events. If the mouseevent has the `shiftKey` property to `true`, it enables multi-touch. diff --git a/tests/manual/events-restarted.html b/tests/manual/events-restarted.html new file mode 100644 index 0000000..397e9d4 --- /dev/null +++ b/tests/manual/events-restarted.html @@ -0,0 +1,37 @@ + + + + + + + + + + + +
+ Check the console. No mouse events should be fired, only touch events. Click events are allowed. +
+ + + + diff --git a/tests/manual/events-stopped.html b/tests/manual/events-stopped.html new file mode 100644 index 0000000..11b8b46 --- /dev/null +++ b/tests/manual/events-stopped.html @@ -0,0 +1,36 @@ + + + + + + + + + + + +
+ Check the console. No touch events should be fired, only mouse events. Click events are allowed, too. +
+ + + + diff --git a/tests/manual/events.html b/tests/manual/events.html index a8ba17a..cf51970 100644 --- a/tests/manual/events.html +++ b/tests/manual/events.html @@ -5,12 +5,12 @@ - +
- Check the console. No mouseevents should be fired, only touchevents. Click events are allowed. + Check the console. No mouse events should be fired, only touch events. Click events are allowed.
- + - + diff --git a/tests/manual/img.html b/tests/manual/img.html index f7b2bba..510a3a6 100644 --- a/tests/manual/img.html +++ b/tests/manual/img.html @@ -5,7 +5,7 @@ - + no dragging of images;
diff --git a/tests/manual/leaflet.html b/tests/manual/leaflet.html index 9f4de80..5bccf35 100644 --- a/tests/manual/leaflet.html +++ b/tests/manual/leaflet.html @@ -6,7 +6,7 @@ - + diff --git a/tests/manual/modernizr.html b/tests/manual/modernizr.html index 683566a..2826e07 100644 --- a/tests/manual/modernizr.html +++ b/tests/manual/modernizr.html @@ -8,7 +8,7 @@

Can we trick Modernizr?

- + - + diff --git a/tests/web-platform-tests/touch-events/multi-touch-interactions-manual.html b/tests/web-platform-tests/touch-events/multi-touch-interactions-manual.html index f339c53..b3377ec 100644 --- a/tests/web-platform-tests/touch-events/multi-touch-interactions-manual.html +++ b/tests/web-platform-tests/touch-events/multi-touch-interactions-manual.html @@ -19,7 +19,7 @@ - + diff --git a/tests/web-platform-tests/touch-events/multi-touch-interfaces-manual.html b/tests/web-platform-tests/touch-events/multi-touch-interfaces-manual.html index da6f2ac..ec4f1dd 100644 --- a/tests/web-platform-tests/touch-events/multi-touch-interfaces-manual.html +++ b/tests/web-platform-tests/touch-events/multi-touch-interfaces-manual.html @@ -20,7 +20,7 @@ - + - +