I have tried to use stopPropagation and stopImmediatePropagation, But it’s not working for touch input. When I use this for mouse input it’s working great. Any one help me to resolve this issue?
Thanks in advance.
Code:
BlockMouseInput.prototype.initialize = function () {
if (this.app.touch) {
this.entity.element.on('touchstart', function (e) {
console.log('touchstart');
e.stopPropagation();
}, this);
}
};
Hi @Sweetan_Mariyappan1 and welcome! Maybe you can try to use preventDefault
as well.
Thank you for the support. I have solved this problem using stopImmediatePropagation.
Code:
var BlockMouseInput = pc.createScript('blockMouseInput');
// initialize code called once per entity
BlockMouseInput.prototype.initialize = function () {
this.entity.element.on('mousedown', function (e) {
e.stopPropagation();
}, this);
if (this.app.touch) {
this.entity.element.on('touchstart', function (e) {
console.log('touchstart');
// e.event.stopPropagation();
e.event.stopImmediatePropagation();
// e.event.preventDefault();
// e.event.cancelable && e.event.preventDefault();
}, this);
this.entity.element.on('touchmove', function (e) {
console.log('touchmove');
// e.event.stopPropagation();
e.event.stopImmediatePropagation();
// e.event.preventDefault();
// e.event.cancelable && e.event.preventDefault();
}, this);
}
};
THANKYOU
3 Likes