Coder Social home page Coder Social logo

gianlucaguarini / tocca.js Goto Github PK

View Code? Open in Web Editor NEW
661.0 31.0 61.0 30 MB

Super lightweight script (~1kb) to detect via Javascript events like 'tap' 'dbltap' 'swipeup' 'swipedown' 'swipeleft' 'swiperight' on any kind of device.

Home Page: http://gianlucaguarini.github.io/Tocca.js/

License: MIT License

JavaScript 78.44% HTML 21.56%

tocca.js's Introduction

Tocca.js

Build Status

NPM version NPM downloads

MIT License

CDNJS

Super lightweight script ( ~1kB ) to detect via Javascript events like 'tap' 'longtap' 'dbltap' 'swipeup' 'swipedown' 'swipeleft' 'swiperight' on any kind of device.

Demo

Donations

If this project helped getting your job done consider making a donation for all the time I spend to bring it to you

Donate

Installation

Npm

$ npm install tocca

Bower

$ bower install Tocca.js -save

Usage

Include the script into your page:

<script src="path/to/Tocca.js"></script>

Once you have included Tocca.js you will be able to catch all the new events:

elm.addEventListener('tap',function(e){});
elm.addEventListener('dbltap',function(e){});
elm.addEventListener('longtap',function(e){});
elm.addEventListener('swipeleft',function(e){});
elm.addEventListener('swiperight',function(e){});
elm.addEventListener('swipeup',function(e){});
elm.addEventListener('swipedown',function(e){});

It works with jQuery as well:

$(elm).on('tap',function(e,data){});
$(elm).on('dbltap',function(e,data){});
$(elm).on('longtap',function(e,data){});
$(elm).on('swipeleft',function(e,data){});
$(elm).on('swiperight',function(e,data){});
$(elm).on('swipeup',function(e,data){});
$(elm).on('swipedown',function(e,data){});

Tocca.js supports also the inline events if you are using Riot.js!

<div ontap="function(e){})"></div>
<div ondbltap="function(e){})"></div>
<div onlongtap="function(e){})"></div>
<div onswipeleft="function(e){})"></div>
<div onswiperight="function(e){})"></div>
<div onswipeup="function(e){})"></div>
<div onswipedown="function(e){})"></div>

API and Examples

Anytime you will use a Tocca.js event the callback function will receive a special event object containing the following properties

  • x { Int }: latest x position of pointer at the end of the event
  • y { Int }: latest y position of pointer at the end of the event
  • originalEvent { Object }: the original javascript native event that has been triggered
  • distance: this property is available only for the swipe events
  • x { Int }: the x absolute difference between the beginning and the end of the swipe gesture
  • y { Int }: the y absolute difference between the beginning and the end of the swipe gesture

Examples:

elm.addEventListener('dbltap',function (e){
  console.log(e.x);
  console.log(e.y);
});
elm.addEventListener('swipeup',function (e){
  console.log(e.x);
  console.log(e.y);
  console.log(e.distance.x);
  console.log(e.distance.y);
});

// with jQuery

$(elm).on('dbltap',function (e,data){
  console.log(data.x);
  console.log(data.y);
});
$(elm).on('swipeup',function (e,data){
  console.log(data.x);
  console.log(data.y);
  console.log(data.distance.x);
  console.log(data.distance.y);
});

Anyway you can combine Tocca.js with the default javascript touch events:

  • touchmove
  • touchstart
  • touchend
  • touchcancel

To disable the default touch behaviours (zoom on double tap, scroll on swipe...) on a certain element via javascript you can always use the following snippet:

elm.addEventListener('touchmove',function(e){e.preventDefault()});
elm.addEventListener('touchstart',function(e){e.preventDefault()});
elm.addEventListener('touchend',function(e){e.preventDefault()});

Configuration

Whenever you want to configure the plugin events settings you can do that simply specifying two constants before including Tocca.js into the page

<script>
var SWIPE_THRESHOLD = 100, // default value
  DBL_TAP_THRESHOLD = 200, // range of time in which a dbltap event could be detected,
  LONG_TAP_THRESHOLD = 1000, // range of time after which a longtap event could be detected
  TAP_THRESHOLD = 150, // range of time in which a tap event could be detected
  TAP_PRECISION = 60 / 2, // default value (touch events boundaries)
  JUST_ON_TOUCH_DEVICES = false, // default value ( decide whether you want to use the Tocca.js events only on the touch devices )
  IGNORE_JQUERY = false; // default value ( will not use jQuery events, even if jQuery is detected )
</script>
<script src="path/to/Tocca.js"></script>

In Tocca.js 1.1.0 you can also configure/get the internal options via function:

window.tocca({
  useJquery: your new option
  swipeThreshold: your new option
  tapThreshold: your new option
  dbltapThreshold: your new option
  longtapThreshold: your new option
  tapPrecision: your new option
  justTouchEvents: your new option
})

console.log(window.tocca()) // will always return the current internal options

Browser Support

Actually the script has been tested on all the modern browsers but it need a better testing phase over several platforms: Chrome 29+ Firefox 23+ Opera 12+ Safari 5+

It works on mobile/tablet browsers and on desktop browsers as well.

On the old browsers all the Tocca.js events cannot be triggered.

Changelog

2.0.9

  • fixed: removed const variables

2.0.8

  • fixed: 70

2.0.7

  • fixed: 69

2.0.6

  • update: improve multiple touches events detection

2.0.5

2.0.4

2.0.3

  • fixed: #51 #54
  • fixed: the PointerUp event is not always dispatched on Chrome and Android devices, prioritize always the touch* over pointer* events

2.0.1

2.0.0

1.1.0

  • added: the possibility to configure via function the internal tocca options
  • added: the IGNORE_JQUERY option

1.0.1

1.0.0

Thanks to @AndyOGo for his help on this release

  • fixed: #34 #35
  • fixed: more reliable and performant events on the hybrid devices
  • fixed: multiple events dispatched on tap

0.2.0

  • added: longtap event and the LONG_TAP_THRESHOLD variable
  • fixed: inconsistencies and issues across the hybrid devices

0.1.7

  • added: longtap event and the LONG_TAP_THRESHOLD variable

0.1.5

  • added: support for the inline events

0.1.4

  • fixed: dbltap #16
  • updated: node devDependecies updated

0.1.3

  • fixed: dbltap issue #14

0.1.2

  • updated: no more deferred tap events, a tap event gets triggered immediately if it's in the TAP_THRESHOLD time range
  • updated: a tap event will always come first a dbltap event

0.1.1

  • updated: better and faster tap events detection
  • updated: node devDependecies updated
  • added: DBL_TAP_THRESHOLD option

0.1.0

  • bugfix: optimizing the support for the microsoft hybrid devices (IE10/IE11)

0.0.8

  • 'touchcancel' event removed to fix and android issue on page scroll

0.0.7

  • nothing important (just a workaround to fix the tests on the motherfucker Phantomjs)

0.0.6

  • bugfix: do not set the mouse event listeners on any touch device and vice versa
  • added: new JUST_ON_TOUCH_DEVICES option to block all the Tocca.js events on the no-touch devices

0.0.5

  • tap precision option included

0.0.4

  • dpltap renamed dbltap
  • new demo added demo-fun.html

0.0.3

  • Tests added

0.0.2

  • Android Bug fix

What does Tocca mean?!

'Tocca' is the second person singular of the imperative Italian verb 'Toccare' that means to touch.

tocca.js's People

Contributors

gianlucaguarini avatar dependabot[bot] avatar prateekbh avatar danieljmaxwell avatar allcode avatar peterdavehello avatar eionrobb avatar gkapkowski avatar jdsharp avatar kennynaoh avatar

Stargazers

 avatar DJABHipHop avatar Jaron Wanderley avatar Arseni avatar  avatar PeterYuan avatar Arsh Khan avatar  avatar Daniele avatar Raymond Tijhaar avatar Vyacheslav avatar Byron Cole Lawlis avatar Meutho avatar Nikita Akimov avatar xygengcn avatar Kainoa Kanter avatar Harold AO avatar Youness Id bakkasse avatar greyliances avatar  avatar Maksim Stashkevich avatar  avatar Subhan Bakh avatar Raimon Grau avatar sen ✦ avatar Nikita avatar ¡Támb! avatar Nick Reese avatar Christoph Kröppl avatar LE avatar pedoc avatar  avatar  avatar neiroc avatar Mimi Kim avatar Steven Gliebe avatar Dmitry Krivyakov avatar William Crawford avatar Dmitry avatar Aliaksei avatar Andrew Holgate avatar  avatar Alexander Duvalin avatar Roman Hossain Shaon avatar Andrew Mason avatar Dominic Seitz avatar Muhammad Ubaid Raza avatar Carlos Teixeira avatar  avatar  avatar ant cosentino avatar  avatar Tao avatar ZPM avatar Даниил Пронин avatar Nelson Reis avatar Alon Valadji avatar Mark Chenoweth avatar Vincent Agnano avatar  avatar  avatar Welkin Wong avatar Bojan Vidanovic avatar vulcangz avatar Deniss Azema avatar  avatar Sven Hohlfeld avatar Jirayu Sukheepoj avatar Christophe Beveraggi avatar nasatome avatar Ming-jun Lu avatar Yvan avatar Fabian Wolf avatar Christopher Ribeiro avatar Jef Lippiatt avatar  avatar Aaron Iker avatar uber morlock avatar Icemic avatar RedHoodSu avatar Clement Fradet Normand avatar Luís Bastião Silva avatar  avatar Benjamin Pinel avatar Cody Marcoux avatar  avatar Adam Skorupka avatar Luke Carl Thompson avatar  avatar Andre Sayej avatar Illia Sakovich avatar Andreas avatar Michele Granato avatar Hamsterwork avatar Fawad Mukhtar avatar Ahmet Simsek avatar Viggo Gao avatar ianva avatar Robert Abramski avatar  avatar

Watchers

David Yu avatar Jaime Olmo avatar 404 avatar Neil avatar  avatar 옷 CLEm ツ avatar Jasmine Hegman avatar James Cloos avatar Abbu Ali avatar  avatar  avatar Misha Korablin avatar Krister Kari avatar akbarwibawa avatar Michael Anthony avatar MiaTakeshi avatar Angel Estrada avatar Graham Little avatar Roland Pihlakas avatar 2ACES  avatar Shogo Nakano / なかの avatar  avatar Manu M avatar Mahda Greene-Moon avatar Jakob Nylin avatar  avatar Fadi Alkhateeb avatar Paul avatar  avatar  avatar Faizel Garoeb avatar

tocca.js's Issues

Swipe gestures in Android WebView

Thanks for the great script. Out of everything I've tried this is by far the best one (and lightest in terms of code).

One small problem is that if I call my webpage in an Android App (using WebView), the swipe gestures do not work. Tap works fine, and swiping works in the Chrome app on Android so I'm not sure why the swiping isn't.

I'm not sure if this is an issue with your script or an issue with WebView perhaps disabling certain javascript.

Question: Any angularjs examples for swipe events?

i would like to override the default swipe events to stop select elements etc from being opened when a user is swiping on a mobile.

I have added the Tocca.js to my page and in the page controller I am attempting to bind the

and addEventListeners for the swipe events so that i can just ignore the default behaviour something like this:

  1. get form element
  var elm = document.getElementsByTagName("form");
  1. attach listeners
  elm.addEventListener('swipeleft',helpSwipe(e));
  elm.addEventListener('swiperight',helpSwipe(e);
  elm.addEventListener('swipeup',helpSwipe(e));
  elm.addEventListener('swipedown',helpSwipe(e));
  1. manipulate event behaviour
  function helpSwipe(e) {
  var touches = evt.changedTouches || (evt.originalEvent && evt.originalEvent.changedTouches);
  if (evt.type === 'touchstart') {
    initialTouchStartY = touches ? touches[0].clientY : 0;
    return true; // don't block event default
  } else {
    evt.stopPropagation();
    evt.preventDefault();

    // prevent scroll from triggering event
    if (evt.type === 'touchend') {
      var currentLocation = touches ? touches[0].clientY : 0;
      if (Math.abs(currentLocation - initialTouchStartY) > 20) return false;
    }
  }
  }

the problem i have at the moment is that in stage two it is not allowing me to attach the listener to the elm - elm.addEventListener is not a function. I am sure i am missing something very simple thats why i am asking for angularjs example to see.

many thanks

Issue with longtap and native pinch and zoom

Hi, I think I've found a bug in tocca. It seems that a 'longtap' event is triggered when you use the native pinch and zoom to zoom in to an image on the page. Increasing the longtapThreshold doesnt seem to help.

Question : how to use Tocca in a js file with 'import'

For example in a React File, does the simple import is enough to make it work ?
Thanks a lot for your help !

import tocca from 'tocca';

class MyComponent extends React.Component  {
     componentDidMount() {
      const element = document.getElementById("my_target")
      element.addEventListener('tap',function(e){
          console.log("Element tapped")
      });
    }

     render() {
       <div id="my_target">
          TARGET
       </div>
          
    }
}

Checking of touch devices is wrong

Checking of touch devices is wrong I think. There is problem with some browsers including chrome. So I changed the 'isTouch' assignment to /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent). Now it is fine I think.

Can you please check it? I think my solution is not robust.

Single-click/tap interpruted as double on Windows/Andriod Chrome

I appreciate your code.

Unfortunately, it did not work as intended on my blog.

Any single click/tap would take me back to the home page. Even clicking on a link meant to point elsewhere.

I also found that swiping was far too sensitive... one could not even highlight some text on the page without unexpectedly being thrust onto another page.

I disabled every other plugin and switched themes to no avail.

The single-click/tap issue only presented itself on Win/Android Chrome in my tests. Although I found that highlighting text would trigger a swipe action on FF/IE/Edge as well as Chrome.

It was driving me crazy, so I had to disable it. I read through the issues and I'm surprised that I am the only person reporting this.

An aside: IMO there is no useful purpose for Tocca to work on desktop browsers. I would recommend detecting mobile vs. desktop browsers and at least having the option to enable/disable the script on desktop browsers.

reduce swipe sensitivity

Is it possible to reduce sensitivity of the left / right swipe gestiture? When I fast scroll the page I always load a new sie because my vertical swipe Action is not straight enough. So now the swipe is too sensitive for me.
Is there a way to adjust a Minimum vertical Distance before Action Starts?
Ps: I am using tocca.js with the wordpress Plugin.
Cheers, pEtEr

Duplicated Events

Hi.
I'm using Vuejs and when I create an event it duplicates it.


<img
     @tap="tapped"
      src="xxxx"
>

var vm = new Vue({
  el: "#app",
  methods:{
    tapped(){
      console.log('tapped')
    }
  }
})

I get "tapped" twice with each tap. The same with all the events I tryied.

Swiping event

Hi! I am trying to build something like this: http://damusnet.github.io/react-swipe-views/
I am using Tocca.js for swipeLeft and swipeRight events.
I think that having new events like 'swiping' or 'swipingLeft' would give more power to this library since in for 'native like' ux on mobile we need it.

pinch event..

hi..
i want to pinch event. is it possible to implement pinch event using touchstart,touchmove and touchend in tocca.js?

inline Events working?

I just played around with the demo, and its working perfectly.

Not when I change the code to Inline Events it's not working anymore.

<div onlongtap="function(e){ alert('World'); })" id="test"></div>

I "long tap" and nothing happens! WhenI use "addEventListener", it is working again. Could you help me?

use tap and dbl tap for the same elem

Hello,

$('img').on('dbltap',function(e,data){ alert('dbltap'); }); $('img').on('tap',function(e,data){ alert('tap'); });

How i can prioritize the event dbltap ? If dbltap, don't launch tap event.. Thanks.

Option "justTouchEvents" doesn't work

Regardless of setting "justTouchEvents" to true or false, tap (and other) event is emitted. The reason are these lines of code https://github.com/GianlucaGuarini/Tocca.js/blob/master/Tocca.js#L55-L59. In browser with support for pointer events, event names are set as Pointer* and they are listened to on lines https://github.com/GianlucaGuarini/Tocca.js/blob/master/Tocca.js#L246-L248. Therefore simple code as this results in two logs in console:

$(document).on('tap click', function(e) {
    console.log(e);
});

Click events do not fire in Chrome Win 8.1 touch laptops

OS: Win 8.1 (touch enabled)
Browser: Chrome 42.0

The "tap" events do not fire when the mouse is used to perform an interaction. A mouse click does not fire a "tap" event. Touch interactions however do work correctly and fire a "tap" event.

This issue has been reproduced on several touch enabled Win 8.1 laptops. This seems to affect only Chrome. Both Firefox and IE work fine i.e. they do fire "tap" events on click.

On investigation, it appears that isTouch is true on Chrome and when this is the case, mouse events are not registered.

https://github.com/GianlucaGuarini/Tocca.js/blob/master/Tocca.js#L158

I'm wondering why the lib is listening only to touch events when a touch device is detected? Shouldn't it listen to both touch and click since it could be a touch and click device?

My suggestion would be to not listen to click events only if the user has explicitly asked for that via JUST_ON_TOUCH_DEVICES. In all other cases, it should listen to both.

Understanding tocca.js events - help required

So this is how I've used tocca for touch events.
bar1 = $("#myDIv").find('.dragMarker');
bar1.on('touchstart',setCurrent);
bar1.on('mousedown',setCurrent);

function setCurrent(e,data) {
    current = 1;
    reset();
}

I want to pass an integer like this:

$.mousedown(setCurrent(i))

function setCurrent(j) {
    return function(event) { 
        current = j;
        reset();
    }
}

How to combine it so that I can link both actions to the same function? ie. function setCurrent(e,data,i)

Thanks :)

Swipe not detected on Opera mobile on Android

Swipe is not detected on Opera mobile on Android.

Using
$("#content_div").on('swipeleft',function(e,data){
...
});
$("#content_div").on('swiperight',function(e,data){
...
}

Other browser like the default Android browser work fine.

Best, Michael

click & tap triggered twice

Hi,

I'm using Tocca.js and so far it works great. I'v got problems when I bind more then 1 event to a event-handler. if I use ''click' and 'tap' both event-handlers attached to events are triggered. When I use somekind of toggle function this is not working. how can I prevent this from happening?

'swipe' event not working without 'preventDefault()' on 'touchmove' event

Hi there !

I use tocca since a while, but recently I encounter a really weird case.

Since days (suspect chrome updates), 'swipe' event does not work anymore without

elm.addEventListener('touchmove', e => e.preventDefault());

(on the same element)

So, am I the only one who encounter this issue ?
May I use a trick to do not copy this thing each time I use a 'swip' event ?
Is a Tocca fix possible ?

Cheers,

Use tags

It seems you are not using git tags. Are you able to implement this so that it is possible to define a version number when installing through bower?

ontap event handler not called on parent element

If a "tap" event listener is set using ontap on a parent element, taps to the children elements don't seem to trigger that listener. Try tapping/clicking on the "inner" and "outter" elements on this jsFiddle as an example.

However, when using addEventListener, the event handler on the parent is called even when the tap event originates from a child. Modified jsFiddle.

Shouldn't these two methods of setting an event listener be equivalent in this case? (for reference, using onclick on the parent element does work for clicks on its children)

Thanks for this awsome library! 😺

TypeError on Mobile Safari UI/WKWebView 13.1.X

The iOS users of my Cordova app started exhibiting the problem after they upgraded their system to latest iOS version. Now tocca exhibits this problem:

TypeError: undefined is not an object

This is shown here in the latest version of tocca in this particular code:

var pointer = getPointerEvent(e)
currX = pointer.pageX <- Here pointer is undefined

This issue is shown randomly I was not able to reproduce with my iPhone SE, I will try to understand which devices affect the problem with more debugging.

I am using Tocca with this configuration.
window.tocca({
useJquery: false
});

Double-tap doesn't seem to work on KitKat Chrome or Safari iOS 8

Thanks for this lib. It's fabulous and I'm using it successfully in a couple projects. However, I recently wanted to add 'double-tap to go fullscreen' functinoality, but I've been unable to make dbltap work. I don't think it's just me: your demo does not seem to register double-taps either.
Thanks!

ontap

I get a issue,ontap event have no effective

<div class="couponDetail" ontap="{getCouponUrl}" >
       <div class="leftDiv">
            <span>{couponInfor.couponValue.number}<i class="discount">折</i></span>
       </div>
       <div class="rightDiv">
             <div class="couponItem">
                 <p>{couponInfor.couponName}</p>
                 <p class="tip">{couponInfor.condition}</p>
           </div>
       </div>
</div>

and ontap event will trigger 2 times at Android app sometimes

[Feature] Timestamp

Just a suggestion....perhaps a timestamp could be appended to the events for swipe?

longtap is triggered when scrolling content

I'm listening longtap event on list items. It always trigger longtap on the item which my finger touch on when I scroll the list for a long time.

I'm using v2.0.4 on chrome android

conflicts with other swipe elements

I use Tocca to swipe between pages and it works great, except where a nested element is also responding to swipes. Typically this appears with Google maps and image sliders.

Is there a way to exclude these nested elements from Tocca's attention? If not, please consider for enhancement.

Start from v2.0.5, tap/swipe events cannot be triggered on Android Chrome 79.0

I found that the the tap, swipeup, swipedown, swipeleft, swiperight event cannot be triggered on the offical demo when I use Chrome on Android, only dbtap and longtap event can be triggered.

I tried on the same page structure and replace the version of Tocca.js, found that the tap event cannot be trigged on v2.0.5, v2.0.6, but can be trigger on v2.0.3, v2.0.4

Chrome Version: 79.0.3945.93
Android Version: 9 (Sony Xperia XZ1, update 47.2.A.11.228)

use zepto to replace tocca

I want to use zepto ,

func (e){
     window.counter++;
 }
<div ontap="func"></div>

this function will trigger when I click 'ontap' event ,but I don't want to use tocca ,I don't konw how to do it?

Tap event triggered when doubletapped?

Hi,

First of all I have to say that it is an awesome library which I use in all my recent projects.

But one strange thing is every time I doubletap a tap event is also fired. Is there a way to stop this behaviour?

Thanks
Vasanth

Tap and Swipe occur twice

Hi,

Great script. I've come across a problem that might be my implementation, when I swipe on an Android device (HTC One) the swipe action is called twice.

imgs = $('#imagelist');
imgs.on('tap',updateHtml)
imgs.on('swipeleft',updateHtml)
imgs.on('swiperight',updateHtml)
imgs.on('touchmove touchstart touchend',function(e){e.preventDefault()})

function updateHtml (e,data){
    e.preventDefault();
    if(e.type == "tap") {
        console.log("Tapped");
    }
    else if (e.type == "swipeleft") {
        console.log("Swipe Left");  
    }
    else if (e.type == "swiperight") {
        console.log("Swipe Right");
    }
}

Any ideas on why this might be happening, it works fine in a Chrome browser.
Thanks.

iOS 8 tap issues

Thanks for an awesome library, I've been using something similar that I wrote myself for https://github.com/techlayer/espresso.js

Was wondering why the tap event isn't firing immediately after a touchEnd, but instead waits 200ms? Can't seem to wrap my head around that design decision, but you must have a reason.

On iOS 8 both a tap and a click event seem to get fired. Check this thread:
ftlabs/fastclick#262

This article sheds some light on the iOS 8 issues:
http://developer.telerik.com/featured/300-ms-click-delay-ios-8/

while the delay is still in place for “fast taps”, it has been removed for “slow taps”

import tocca from 'tocca';

I'm not using jQuery, and while it compiles successfully, I get an error on the frontend;

Uncaught ReferenceError: jQuery is not defined

Tried to search for similar issues but couldn't find any. I have useJquery set to false in the options.

swipe won't work crome 62.0.3202 android 5.1.1 SM-J320F build/LMY47V

But it works - Tocca.js 2.0.1 - on same android with firefox 57.0

But demo here detects events with Chrome 62.0.3202 fine

So yes some pages on my sites have:

html,
body {
	height: 100%;
}
body {
	width: 100%;
	overflow-x: hidden;

or

html,
body {
	height: 100%;
}
body {
	width: 100%;
	overflow-y: auto;

That's all that I had dug out.

testing page here https://englishextra.github.io/ - swipeup or swipedown

Important : the events are set to passive.

var mousewheeldown = document[getElementsByClassName]("mousewheeldown")[0] || "";
var swipeup = document[getElementsByClassName]("swipeup")[0] || "";
if (mousewheeldown && swipeup) {
	if (hasTouch) {
		mousewheeldown[style].display = "none";
		if (root.tocca) {
			root[_addEventListener]("swipeup", revealStart, {passive: true});
			root[_addEventListener]("swipedown", concealStart, {passive: true});
		}
	} else {
		if (hasWheel) {
			swipeup[style].display = "none";
			if (root.WheelIndicator) {
				var indicator;
				indicator = new WheelIndicator({
						elem: root,
						callback: function (e) {
							if ("down" === e.direction) {
								revealStart();
							}
							if ("up" === e.direction) {
								concealStart();
							}
						},
						preventMouse: false
					});
			}
		}
	}
	if (hasTouch || hasWheel) {
		guesture[classList].add(bounceInUpClass);
		guesture[style].display = "block";
	}
}

caniuse says android chrome 62 and webview 62 support passive listeners

Tocca.js 2.0.1 swipeup and swipedown works in chrome 49.2623.91 on android 6.0.1; P024 build/MMB29M

Doesnt work on my site with Opera 43.02246

No events triggered during mobile debug of desktop Chrome

In the latest version of Chrome tocca works perfect. But when trying to debug app in "simulated" mobile mode, tocca will not emit any events.

After some investigation it turned out that, during initialization of tocca Chrome contains window.PointerEvent object but during testing with a mouse (simulating touch gestures) the browser will not emit any pointer events.

event.preventDefault() not working with jQuery

I am using Backbone router which makes it neccesary to preventDefault on hyperlinks. When I change 'tap' to 'click' it works like expected.

$(document).on('tap', 'a.bb', function(event) {
	event.preventDefault();

	console.log('CLICK');
	var href = $(this).attr('href');
	Backbone.history.navigate(href, true);
});

how to integrate with riot.js

I import Tocca and riot(2.0.12), but it doesn't work.

<div ontap="{test}"></div>
this.test = function(){
    ...
}

Is it conflict with the nature event of riot ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.