samedi 31 janvier 2015

Famo.us Multiple Touch Events Prevent Click Event


I have a surface that on 'click' on touch devices needs to fire an event even when other touches are occurring on the screen.


I'm using the FastClick shim provided by Famo.us, but it doesn't seem to handle touchstart->touchend clicks while other touch events are present on the window.


I've set up a codepen portraying my issue. Once you have the codepen open on a touch device, press and hold a finger down anywhere on the screen and then try to trigger the click event on the surface - you'll see it doesn't work.


The code is very basic:



var Engine = require('famous/core/Engine');
var Surface = require('famous/core/Surface');
var EventHandler = require('famous/core/EventHandler');
var Transform = require('famous/core/Transform');
var Timer = require('famous/utilities/Timer');
var FastClick = require('famous/inputs/FastClick');

var StateModifier = require('famous/modifiers/StateModifier');
var Modifier = require("famous/core/Modifier");


var context = Engine.createContext();

var handler = new EventHandler();

// a modifier that centers the surface
var centerModifier = new Modifier({
origin : [0.5, 0.5],
align: [0.5, 0.5]
});

var center = context.add(centerModifier);


var button = new Surface({
size:[150,150],
properties: {
color: '#222',
backgroundColor: '#CCC',
textAlign: 'center',
lineHeight: '150px'
},
content: 'Tap/Click me!'
});

button.on('click', function() {
button.setContent("Tapped!!");
Timer.setTimeout(function(){
button.setContent('Tap/Click me!');
},750);
});

center.add(button);


Given that I'm developing an app for a multi user touch table:


How can I listen for click events on surfaces while other touches are firing elsewhere on the screen?





Aucun commentaire:

Enregistrer un commentaire