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.

Make it possible to pass in a DOM Element instead of an id

See original GitHub issue

Is your feature request related to a problem? Please describe. The current implementation requires you to add an id to a container or canvas, and pass that id when initialising tsparticles. Since most frameworks make it possible to get access to DOM references it would be nice if that was also supported.

This would allow frameworks like Svelte or Ember to implement a wrapper as an action or modifier respectively. (Other frameworks might have similar functionality.)

Describe the solution you’d like Make it possible to initialise tsparticles like this:

tsparticles.load(canvasOrContainerElement, options)

Describe alternatives you’ve considered Keep the current id string only api

Additional context

Potential Svelte wrapper api:

<div use:tsparticles={options}></div>

Potential Ember wrapper api:

<canvas {{tsparticles this.options}}></canvas>

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
issue-label-bot[bot]commented, Jul 6, 2020

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.98. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

0reactions
matteobrunicommented, Jul 7, 2020

The id is not linked by the Dom with the set method, is used by tsParticles internally to retrieve same containers and avoid duplicates by destroying the old and create a new one. In the load method the id is used to retrieve the DOM element and it’s set to the particles container too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: Passing a DOM element instead of id to .play() method
I am trying to call the play() method: which takes an id of a node, searches it using document.getElementById() and executes the media ......
Read more >
In JavaScript, can I just pass the id of an element as ... - Quora
If the former, then obviously yes. · If the latter, i.e. you mean a reference to an HTML element obtained via its id...
Read more >
HTML DOM Element id Property - W3Schools
The id property sets or returns the value of an element's id attribute. Note. An id should be unique within a page. See...
Read more >
How To Access Elements in the DOM - DigitalOcean
The easiest way to access a single element in the DOM is by its unique ID. You can get an element by ID...
Read more >
class vs id - this vs that - in the front-end development?
If an element has the id attribute, we can access its DOM node from the global window object directly, such as window['the-id'] or...
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