Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

direktorn

Members
  • Posts

    1
  • Joined

  • Last visited

direktorn's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi, I want to use GSAP together with Websockets. I'm not that experienced with JS and async operations. The idea is to receive (Subscribe) to websocket events that will trigger an animation. The purpose is to display upcoming TV Programs on a website, just like notifications. They need to be animated the way my tween works now. If I get this working i'm planing to place them in a timeline instead of using delays, but as I'm new to tweens this was the easiest way for me This works with my current code (see attached) but the nature of Websocket and the way I implement things I have two issues. If I post multiple events to my websocket they fire and my DOM change during animation. I would need to have some sort of queue so that TweenMax is running to a "end" first. After my first tween is done I have not really found i good way to "rest" the scene so I can trigger a new animation. I have tried clearProps and KillAll but not sure if I have been successful (mostly related to point 1 above) Do we have any brave sole that have used GSAP with Websockets (or Ajax) to deal with multiple events? Thanks in advance. Sorry for the formatting. I'm using a timer to reload the page, this was a ugly way that allowed me to "reset" the DOM. I have the same method if my Websocket crashes. var conn = new ab.Session('ws://control.nebuchadnezzar.local:8080', function() { conn.subscribe('NextShow', function(topic, data) { console.log(data); for(key in data.Program){ ticker.innerText = data.Program[key]; TweenMax.to("#bar", 2, {left:1450,ease:Back.easeOut}); TweenMax.to("#ticker", 2, {left:1560,ease:Back.easeOut, delay:0.5}); TweenMax.to("#logo", 2, {left:1450,ease:Back.easeOut, delay:0.5}); TweenMax.to("#ticker", 2, {left:1920,ease:Power2.easeOut, delay:10}); TweenMax.to("#logo", 2, {left:1920,ease:Power2.easeOut, delay:10}); TweenMax.to("#bar", 2, {left:1920,ease:Power2.easeOut, delay:10}); TweenMax.to("#logo", 2, {opacity:0, delay:11}); TweenMax.to("#ticker", 2, {opacity:0, delay:11}); TweenMax.to("#bar", 2, {opacity:0, delay:11}); console.log(ProgramEPG); setTimeout(function(){ location.reload(); },1000*30); } }); }, function() { console.warn('WebSocket connection closed'); location.reload(); }, {'skipSubprotocolCheck': true, 'maxRetries': 60, 'retryDelay': 500} );
×