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

fix: dtyle conflict with multiple gauges created using the "parentNode" method #367

Merged
merged 7 commits into from
Dec 10, 2021

Conversation

EliteScientist
Copy link
Contributor

When using the "parentNode" method to create gauges, the config.id remains undefined.

The code that generates the styles uses the config.id to define the id of the styles. Because config.id is undefined, this causes a style conflict resulting in every gauge in the screen being affected by the same style.

the config.id method takes precedence over parentNode which means you cannot use it at all.

I created a classId property that can be used to create a unique id for the styles for each instance. If the classId is not defined then the previous mechanism will be the default.

When multiple gauges are created utilizing the "parentNode" method, the obj.config.id is undefined. When the "generateShadow" function is called, the filter is created as "inner-shadow-" for each gauge. This creates a conflict between each gauge on the screen.

Attempting to set an "id" didn't work because this took priority and the code looked for the "id" to exist in the dom instead of using the parentNode.

I created the classId property to set any arbitrary id to be used as the filter id. This will prevent conflicts and can be used when the parentNode method is used.

If a classId is not set, it will default to the previous mechanism.
Bump version #
With some URLS, using window.location.pathname#inner-shadow-id results in an object that cannot be found. This makes the gauge disappear all together.
By using a relative anchor, it is always accessible within the scope of the page. Changed it to use url(#inner-shadow-id) which fixes the problem.
@EliteScientist
Copy link
Contributor Author

Also fixed issue where in some instances the gauge will disappear when enabling the shadow.

Fixed Typo
@robertsLando
Copy link
Collaborator

@EliteScientist What about generating a random id when it is undefined? I prefer this approach as it doesn't introduce another option that could cause confusion

@EliteScientist
Copy link
Contributor Author

@robertsLando That is another option. In my implementation I set classId to the containers id which is randomly generated value. I'll change it to generate a uuid.

@EliteScientist
Copy link
Contributor Author

@robertsLando I added a uuid generator function and am using that to generate the uuid for each gauge.

justgage.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@robertsLando robertsLando changed the title Fix: Style conflict with multiple gauges created using the "parentNode" method fix: dtyle conflict with multiple gauges created using the "parentNode" method Dec 10, 2021
@robertsLando robertsLando merged commit 8beb260 into toorshia:master Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants