-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
p5.js events confict with Swiper #6245
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you! |
As a quick hack, you could add this to your project: const oldUpdateTouchCoords = p5.prototype._updateTouchCoords;
p5.prototype._updateTouchCoords = function(e) {
if (e.touches) {
oldUpdateTouchCoords.call(this, e);
}
} This will only call the actual p5 method if I'm not sure we want to deal with this in p5 core though, if this library is dispatching its own touch events that aren't actual DOM touch events. Maybe an issue should be opened on that repo? |
Thank you for answering, unfortunately This is what I tried, not working const prototype = Object.getPrototypeOf(p5)
const oldUpdateTouchCoords = prototype._updateTouchCoords
prototype._updateTouchCoords = function (e) {
if (e.touches) {
oldUpdateTouchCoords.call(this, e)
}
}
Object.setPrototypeOf(p5, prototype) |
Is that undefined inside of your |
I'm not sure I fully understand but From what I can find, according to Swiper.js they no longer use these events and just rely on pointer events. |
Hi! Yes, |
Honestly I am a little bit confused too and I am trying to clarify my thoughts, but no success till now. Going deeper, here you can find the piece of code of This is the code of And this is the code pf p5.js |
@giodum Just from the screenshots here I think what is happening is that Swiper have an event called I don't know why that is done but in any case, this is an issue with Swiper as it should not be emitting |
Just found that this is a known issue in Swiper: nolimits4web/swiper#6450 I will close this issue for now as there is nothing to fix on p5.js' side. Thanks. |
Thank you for your help. |
Most appropriate sub-area of p5.js?
p5.js version
1.6.0
Web browser and version
All browsers
Operating System
MacOSX - Ventura 13.0.1
Steps to reproduce this
Hi everybody, I am facing a very frustrating problem while using inside my Nuxt 3 project p5.js: there are some conflict problems with Swiper.js (I am using version 9.3.2).
It seems that p5.js listens to same name events triggered by Swiper.js, in particular
touchstart
,touchmove
andtouchend
. So, when I move through the slides of a Swiper carousel I get an error from p5.js.This is an example of the error I get in the console (same for
touchmove
andtouchend
):The error is generated inside p5.js in the function
_updateTouchCoords
, because the event e does not havetouches
property. I think this is due to the fact that the evente
has been rised up by Swiper.I would really need to find a solution to prevent these errors. So I tried, but with no success, to detach the event listening (I will not use them).
Unfortunately documentation about that is not clear and it is really hard to understand where fix it.
I tried a lot of possibilities, no one with positive results:
_detatchListener
method (ex.p5.Element._detachListener('touchEnd', p5Instance._curElement)
)p5Instance.canvas.removeEventListener('touchend')
) but it would need the exact name of the function to removep5Instance._events['touchend'] = function () {}
or overriding methods insidep5Instance
prototype)Would anybody have a solution to fix this problem?
Snippet:
The text was updated successfully, but these errors were encountered: