Skip to content
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

[Bug]: Touch events cause onClick interaction to fire twice #4622

Closed
1 task done
ReadyPlayerEmma opened this issue Aug 16, 2022 · 1 comment · Fixed by #4624
Closed
1 task done

[Bug]: Touch events cause onClick interaction to fire twice #4622

ReadyPlayerEmma opened this issue Aug 16, 2022 · 1 comment · Fixed by #4624
Assignees
Labels
bug Something isn't working triage

Comments

@ReadyPlayerEmma
Copy link

Contact Details

No response

What happened?

When touching the screen on a mobile device (Android and iOS confirmed) while having onClick specified, the onClick event fires twice. This appears to be a common bug with handling touch events across several libraries. Both the touch event and click events fire and it is necessary to handle them together and detect if touch event has already run when you are evaluating the click event.

I am not sure where in the code base these events are handled or I would have tried to fix it.

tsParticles Version

2.2.1

Which library are you using?

React.js (react-particles, react-tsparticles, react-particles-js)

tsParticles Configuration

{
  background: {
    color: {
      value: 'transparent',
    },
  },
  fpsLimit: 24,
  fullScreen: { enable: false },
  interactivity: {
    detect_on: 'canvas',
    events: {
      onClick: {
        enable: true,
        mode: 'push',
      },
      resize: true,
    },
    modes: {
      push: {
        quantity: 1,
      },
    },
  },
  particles: {
    color: {
      value: '#ffffff',
    },
    collisions: {
      enable: false,
    },
    life: {
      duration: {
        sync: true,
        value: 30,
      },
      count: 1,
    },
    number: {
      density: {
        enable: true,
        area: 120000,
      },
      value: 0,
    },
    opacity: {
      value: 0.85,
    },
    shape: {
      options: {
        image: [
          {
            src: 'img/googly-eye.png',
          },
        ],
      },
      type: 'image',
    },
    size: {
      value: { min: 25, max: 50 },
    },
    rotate: {
      value: { min: 0, max: 360 },
      animation: {
        enable: true,
        speed: { min: 2.5, max: 8 },
      },
      direction: 'counterClockwise',
    },
  },
  detectRetina: true,
}

What browsers are you seeing the problem on?

Firefox, Chrome, Safari

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@matteobruni
Copy link
Collaborator

Thanks, I've never noticed that. I've seen that the "new" pointer events are recommended instead of the old mouse events. The unsupported browsers have a small market share percent and can be ignored IMO.

I think a 2.2.2 will be released today with this fix.

matteobruni added a commit that referenced this issue Aug 16, 2022
@matteobruni matteobruni mentioned this issue Aug 16, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants