• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Touché: bringing touch events to non-touch browsers (how touching!). No dependencies. No code bloat.

Touché

Mouse event to touch event mapping for testing touch interfaces with desktop browsers. This means that touchstart, touchmove, and touchend are hooked up to mousedown, mousemove, and mouseend, respectively. This is generally recommended for testing purposes.

Inspired by Phantom Limb (https://github.com/brian-c/phantom-limb), but seeking less bloat (no graphics) and more conformance to the properties of actual touch objects.

Live Demo

http://davidbcalhoun.com/a/touche.html

Try it in your desktop browser!

Examples

Hook me up!

You hook up events just like you would on a device (libraries will use the same methods):

document.addEventListener('touchstart', function(e){}, false);
document.addEventListener('touchmove', function(e){}, false);
document.addEventListener('touchend', function(e){}, false);

Interacting with the touch events

The main difference with touch events are the touch event arrays, which Touché gladly simulates for you:

  1. touchstart has e.touches
  2. touchmove has e.touches and e.changedTouches
  3. touchend has e.changedTouches

Because a mouse cursor is representative of just one finger, these simulated arrays will only contain one element (i.e. e.touches[0]) corresponding to one touch.

Example:

document.addEventListener('touchstart', function(e){
	e.touches[0].target;   // example: "[object HTMLPreElement]"
	e.touches[0].screenX;
	e.touches[0].screenY;
}, false);

Support

Tested to work on:

  • Chrome 13+
  • Safari 5.1+
  • Firefox 7+

More Repositories

1

energize.js

A tiny JavaScript snippet to make links snappy on touch devices
JavaScript
181
star
2

jstoxml

JavaScript object to XML converter (useful for RSS, podcasts, GPX, AMP, etc)
JavaScript
168
star
3

tle.js

🛰️ Satellite TLE tools in JavaScript: get lat/lon of satellites, get look angles, plot orbit lines, extract individual TLE elements, etc
JavaScript
127
star
4

eslint-plugin-test-selectors

Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.
JavaScript
27
star
5

jsconf-2014

JSConf 2014 talk: Realtime Satellite Tracking in the Browser
JavaScript
21
star
6

mobile-console

Debug console bookmarklet for mobile devices. Overrides console.log, replacing it with an on-screen console that appears at the bottom of the window. mobile-console also logs all messages to a remote server, which can write the messages to a log or display them on a desktop browser.
7
star
7

transcoder

A simple utility for web developers to convert to base64, hex, binary, md5, etc, as well as useful tools such as a CSS minifier, jsMin, Closure Compiler (coming soon), and a JavaScript-based QR code generator. With desktop drag and drop capability!
PHP
6
star
8

negative-scroll-blur

Make stuff blurry when there's negative top scroll
JavaScript
5
star
9

trackthatsatellite.com

100% clientside satellite tracker
JavaScript
5
star
10

normalize-mobile.css

Normalize.css for mobile minus desktop fixes (also minus IE star/underscore hacks)
5
star
11

gps-time.js

Small utility to convert times between GPS epoch (midnight January 6, 1980) and Unix epoch (midnight January 1, 1970), taking into account leap seconds.
JavaScript
5
star
12

s5mod

Modification and updates to the s5 presentation platform
JavaScript
3
star
13

jest-bug-test-file-stub

JavaScript
3
star
14

link-aggregator

Pulls together topical links from a variety of sources, ranking them by popularity
JavaScript
3
star
15

react-hover-slideshow

Iterates through an image slideshow based on cursor/touch position.
JavaScript
3
star
16

covid-19-map-south-carolina

Interactive map of COVID-19 cases by zip code in South Carolina
JavaScript
2
star
17

simple-cors-server

Simple HTTP server with CORS enabled (similar to Python's SimpleHTTPServer)
JavaScript
2
star
18

deep-object-assign-with-reduce

Deep merging of objects with the same function signature as Object.assign() (useful for overriding default options objects)
JavaScript
2
star
19

frontendstuff

frontendstuff.com
JavaScript
2
star
20

Leveler

Brings older JavaScript implementation up to the level by providing new methods (string trim, Date.now, etc.)
JavaScript
1
star
21

covid-19-data-south-carolina

JavaScript
1
star
22

little-time

Minimalist timestamp manipulator and formatter inspired by moment.js
JavaScript
1
star
23

flickryql

Flickr + YQL
1
star
24

page-curl

Flipboard-style page curl effects
1
star
25

sudoku

Simple sudoku solver in JavaScript (just for fun!)
JavaScript
1
star
26

react-hook-visible-satellites

React hook that returns satellites currently visible in the sky overhead.
JavaScript
1
star
27

parse-scraped-times

Helper for managing the insane variations in writing times in HTML. Needed for getting published/updated times of articles and websites in general.
JavaScript
1
star
28

cbsi-tech-talks

CBSi Tech Talks stuff - notes, etc
1
star
29

gallery-flickr

Useful Flickr widget for YUI3
JavaScript
1
star
30

writers-friend

Distraction-free simple writing experience for the local browser (no network calls)
JavaScript
1
star