Forum Discussion
Rotating a shape 90° shouldn't be too complicated but...
- 1 year ago
Hi ThierryEMMANUEL I have the solution for me, but let me know if you need any tweaks to it. This leverages the GSAP library as it is the cleanest solution. In the attached video, I explain the code, and also talk through some modifications you could make. This method also uses some Storyline variables, which may help configure the functionality from Storyline so it is a bit easier to work with for none programmers.
I'll have a Pietra please. ChatGPT reckons it's one of the most expensive in France ;)
Working file attached:
Hi VicovandenEv121 . The beauty of this code is its small size. I thought I had solved the problem of preventing the rotation from starting from an intermediate position when the user clicks again before the animation is finished, by creating a variable (rotationDegree) stored in the window object, which allows it to persist between executions without resetting. Actually, chapGPT did it. Here is the modified code:
window.rotationDegree = (window.rotationDegree || 0) - 90;
let object1 = document.querySelector("[data-model-id='6nmK88deM2z']");
gsap.to(object1, { rotation: window.rotationDegree, duration: 1 });
It works for the first object! But since I want to target multiple objects, the objects share the same rotationDegree variable in their code and their first rotations are at first heretical. I guess it is normal. I'm still looking. (This is the last time I'll ask you if you don't have time. You've already earned your beer anyway.)
Hi ThierryEMMANUEL I'll have the Trappist Westvleteren 12 🍺
- ThierryEMMANUEL1 year agoCommunity Member
Is this your country? VicovandenEv121
One of the 12 Trappist beers in the world, you're a connoisseur. Looks like we're talking more about beer than Javascript in this thread.😀- VicovandenEv1211 year agoCommunity Member
I live in the Netherlands, but love special beers. And Belgian beers are amongst the best in the world ;-)
- ThierryEMMANUEL1 year agoCommunity Member
I agree.
Related Content
- 1 year ago
- 6 months ago
- 1 year ago
- 1 year ago