01-12-2023 19:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-12-2023 19:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I want to animate a circle
<svg class="background">
<circle id="demo" cx="0" cy="168" r="50" fill="white" />
<animate attributeName="x" begin="click" from="0" to="168" dur="1" />
</svg>
consider there are other elements too like time and hr
when i click the circle it animates, but it animates when i click other elemets too.
why is this happening?
My temporary solution was to label other elements with pointer-events hidden.
Answered! Go to the Best Answer.
Accepted Solutions
01-12-2023 23:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-12-2023 23:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You will want to use the click event listener and animation execution as detailed in https://dev.fitbit.com/build/guides/user-interface/javascript/
First, make sure to set the attribute pointer-events="visible" on your circle, "demo"
Then in js:
import * as document from "document";
let myCircle = document.getElementById("demo");
myCircle.addEventListener("click", (evt) => {
myCircle.animate("click");
});
I don't know if "click" is some kind of predefined animation trigger (I wouldn't expect your animation to work at all without js) but you may want to set your animation's begin attribute to something like "enable" instead, in which case the click event listener would look like:
myCircle.addEventListener("click", (evt) => {
myCircle.animate("enable");
});
01-12-2023 20:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-12-2023 20:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
What does your click event listener setup look like in js?
01-12-2023 20:04 - edited 01-12-2023 20:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-12-2023 20:04 - edited 01-12-2023 20:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
nothing, i didn't add any in .js

01-12-2023 23:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-12-2023 23:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You will want to use the click event listener and animation execution as detailed in https://dev.fitbit.com/build/guides/user-interface/javascript/
First, make sure to set the attribute pointer-events="visible" on your circle, "demo"
Then in js:
import * as document from "document";
let myCircle = document.getElementById("demo");
myCircle.addEventListener("click", (evt) => {
myCircle.animate("click");
});
I don't know if "click" is some kind of predefined animation trigger (I wouldn't expect your animation to work at all without js) but you may want to set your animation's begin attribute to something like "enable" instead, in which case the click event listener would look like:
myCircle.addEventListener("click", (evt) => {
myCircle.animate("enable");
});
01-13-2023 04:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-13-2023 04:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
thanks it worked

01-13-2023 12:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
01-13-2023 12:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
You absolutely can animate in svg only:
Just make sure to close the animated element AFTER the animation like shown in the examples
