Time based instead of click #118
-
There are some awesome animations here that I would really love to use but is there a way that instead of being click based event to pass a param like for example I was trying to achieve this with this CodePen: https://codepen.io/yuanchuan/pen/MWjxRrL |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Wrap the customElements.define("my-doodle",class extends HTMLElement{
connectedCallback(){
setInterval( ()=> this.querySelector("css-doodle").update() , 2000 )
}
}) |
Beta Was this translation helpful? Give feedback.
-
Yes, better solution While you were typing I had already written: If you can't change the original component behavior; add a click handler that cancels all other clicks: customElements.define("my-doodle",class extends HTMLElement{
connectedCallback(){
let doodle = this.querySelector("css-doodle");
doodle.addEventListener("click", (evt)=>evt.stopPropagation() ,true );
setInterval(()=>{
doodle.update();
},2000)
}
}) |
Beta Was this translation helpful? Give feedback.
-
Actually.. to be complete and correct The Easy fix: customElements.define("my-doodle",class extends HTMLElement{
connectedCallback(){
setTimeout(()=>{
let doodle = this.querySelector("css-doodle");
doodle.addEventListener("click", (evt)=>evt.stopPropagation() ,true );
setInterval(()=>{
doodle.update();
},2000);
});
}
}) |
Beta Was this translation helpful? Give feedback.
-
Yes, that is the great escape; |
Beta Was this translation helpful? Give feedback.
-
laggyAnimation.mp4So I have an Issue where the animation is lagging, I used:
And:
|
Beta Was this translation helpful? Give feedback.
Wrap the
<css-doodle>
in your own Web Component<my-doodle>
: