question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Particles not loading on mobile devices

See original GitHub issue

Contact Details

No response

What happened?

Everything is up and running properly on desktop, but when I switch to an iPad Min 2 or iPhone 7, the particles fail to load. I should note, I’m running the same functions as in the README - particlesInit and particlesLoaded. The particlesInit function prints to the console fine, but instead of particlesLoaded printing to the console, I get this error -

Unhandled Promise Rejection: TypeError: element.addEventListener is not a function. (In ‘element.addEventListener(event, handler, addOptions)’, ‘element.addEventListener’ is undefined)

The error traces to the commented line in this function -

function manageListener(element, event, handler, add, options) {
  if (add) {
    let addOptions = {
      passive: true
    };

    if (typeof options === "boolean") {
      addOptions.capture = options;
    } else if (options !== undefined) {
      addOptions = options;
    }

    //specifically, this line below 
    element.addEventListener(event, handler, addOptions);
  } else {
    const removeOptions = options;
    element.removeEventListener(event, handler, removeOptions);
  }
}

Version

1.36.0

Which library are you using?

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

tsParticles Configuration

const particlesInit = (main) => {
          console.log(main);
     };

    const particlesLoaded = (container) => {
        console.log(container);
    };
    
    return (
        <Particles
            init={particlesInit}
            loaded={particlesLoaded}
            options={{
                background: {
                    color: {
                        value: "#0d47a1",
                    },
                },
                fpsLimit: 60,
                fullScreen: {
                    enable: true
                },
                interactivity: {
                    events: {
                        onClick: {
                            enable: true,
                            mode: "push",
                        },
                        onHover: {
                            enable: true,
                            mode: "repulse",
                        },
                        resize: true,
                    },
                    modes: {
                        bubble: {
                            distance: 400,
                            duration: 2,
                            opacity: 0.8,
                            size: 40,
                        },
                        push: {
                            quantity: 4,
                        },
                        repulse: {
                            distance: 200,
                            duration: 0.4,
                        },
                    },
                },
                particles: {
                    color: {
                        value: "#ffffff",
                    },
                    links: {
                        color: "#ffffff",
                        distance: 150,
                        enable: true,
                        opacity: 0.5,
                        width: 1,
                    },
                    collisions: {
                        enable: true,
                    },
                    move: {
                        direction: "none",
                        enable: true,
                        outMode: "bounce",
                        random: false,
                        speed: 6,
                        straight: false,
                    },
                    number: {
                        density: {
                            enable: true,
                            value_area: 800,
                        },
                        value: 80,
                    },
                    opacity: {
                        value: 0.5,
                    },
                    shape: {
                        type: "circle",
                    },
                    size: {
                        random: true,
                        value: 5,
                    },
                },
                detectRetina: true,
            }}
        />
        </div>
    );

What browsers are you seeing the problem on?

Chrome, Safari

Relevant log output

No response

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
stylessardcommented, Oct 30, 2021

Updated to iOS 15 and works perfectly now, so that must’ve been it. Thanks, Matteo!

0reactions
matteobrunicommented, Oct 29, 2021

I have to check which features are not supported in iOS 12, maybe some of them is breaking.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Particles not loading on mobile devices - getting error #2427
I've got everything up and running properly on desktop, but when I switch to an iPad or iPhone, the particles fail to load....
Read more >
ParticleSystem position bug on mobile devices? - Unity Answers
On mobile devices they started to behave strangely (appearing at wrong positions), so I narrowed the problem down to this:.
Read more >
Simple particle system not displaying on Android
Hi guys, I've been having no clue how to get this emitter to display on Android, although it displays correctly in the Mobile/Android...
Read more >
WiFi Connectivity Troubleshooting Guide - Particle docs
Place your device in DFU Mode by pressing RESET and MODE simultaneously, releasing RESET, and then releasing MODE once the status LED blinks...
Read more >
[MCPE-80348] Particle command not giving an output - Jira
This has been an ongoing problem for quite some time. The fact it gives no output is likely due to Android and Console...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found