Barrett
Content Type
Profiles
Forums
Store
Blog
Product
Showcase
FAQ
Downloads
Posts posted by Barrett
-
-
Hi All,
I'm currently trying to create function that controls a sprite 4420px wide. The sprite is masked and only displays 170px width at any time. On a button click the sprite moves -170px to display the next image and so on. However when the last image of the sprite is reached I want to loop back to the first frame.
The if statement only seems to be recognised if the 'style.left == 0'.
Please see my function below any help would be appreciated.
Thanks
addListeners = function () { angleLeft.addEventListener('click', angleLeftClick, false) } leftClick = new TimelineMax({ delay: 0, }); function angleLeftClick() { if (sprite.style.left == -4250) { leftClick.to(sprite, 0, { x: 0, }) console.log("clicked"); } else { leftClick.to(sprite, 0, { x: "-=170", }) } }
-
That's great thanks Jonathan.
- 1
-
Hi Jonathan,
Thank you for your reply. It has work perfectly.
What would I need to change to remove the 2 decimal places.
Thanks
Barrett
-
Hi,
I am new to the GreenSock forum and would greatly appreciate some insight and help. I have found some great posts with useful answers concerning 'Counters' however none with a separator. I apologise if I have missed one or if this post is in the wrong place.
I'm trying to add a comma to the below code to give the 'thousands' a decimal place eg 2,100.
var counter = { var: 0 }; var tal = document.getElementById("tal"); TweenMax.to(counter, 5, { var: 2100, onUpdate: function () { tal.innerHTML = Math.ceil(counter.var); }, ease:Circ.easeOut });
In the past I have used countUp.js to achieve this. But was wondering if TweenMax has a simple way to execute with out adding an additional js file.
Any help would be appreciated.
Thanks
Barrett
if else Statement
in GSAP
Posted
Hi Shaun, Acccent,
Both of these solutions worked perfectly. Thank you for your help and quick reply.
Thanks
Barrett