Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm designing a portfolio website and I'm trying to get a list of projects to display sequentially on the click of a checkbox, I've got it working but there's an issue. If you click on the checkbox repeatedly, it misses projects out, I can't work out why that would be? The setInterval finishes far before the transitions do so I thought the fix may be delaying the setInterval so that each iteration waited until it's transition was finished but I can't make it work. I'm happy to completely refactor it but I have no idea what direction to take! Essentially I need a system I can stop or start at any point which will allow the current transition to finish then reverse direction. Could this be done in pure CSS?

What I have tried:

I've tried loops and array methods but settled on setInterval as it seemed to be the easiest to break out of and restart. I've tried to make the setInterval iteration wait until the transition has ended using transitionend. I read something about promises that seemed like it might work but after fiddling around with it a lot, didn't get anywhere.

Simplified Codepen here
Posted
Comments
Mike Hankey 21-Jul-22 11:59am    
Disable Checkbox until transition finished?
MrLupine 24-Jul-22 13:35pm    
Thanks for your response Mike! No, it's not the checkbox that I want to stop moving, something in the function is causing things to be omitted from the list of projects, I assume I need to pause the setInterval until the transition ends but I have no idea how to do it!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900