Jump to content
Search Community

mGorchev

Members
  • Posts

    5
  • Joined

  • Last visited

mGorchev's Achievements

  1. Hi Diaco, thanks for pointing me the right direction. I manage to made it work using the ColorPropsPlugin. I had a wrong function stack as well It needs some cleaning and some tweeks but i have what i was trying to achieve! Big thanks for the great support!
  2. Hello everyone, Im trying to generate particles in HTML5 canvas and then fade them in or out with random delay and animation duration time. Ultimately creating the effect of stars appears in the sky. So far i've been able to generate the particles with rgba() colour but was unable to animate the alpha value. In the Codepen provided if you change line 18 from _this.alpha = 0; to _this.alpha = 1; you will see that the particles are actually being drawn on the canvas. Im not sure if i can modify directly an rgba value of a canvas shape with TweenMax or i need another approach. My animate function looks like that: function animate(){ for(var i = 0; i < bubbles.length; i++){ var current = bubbles[i]; var newAlpha = i * 0.1 % 1; // TweenMax.to(current, 1, { color: 'rgba('+ current.color + ', '+ newAlpha +')', delay: 0.5, onComplete: function(){ console.log('Completed!'); } }); } loop(); } and i have the loop function to redraw the canvas on every frame: function loop(){ for (var i = 0; i < bubbles.length; i++) { bubbles[i].draw(ctx); } requestAnimationFrame(loop); } Im not sure if im doing the requestAnimationPart properly as well. CodePen: http://codepen.io/MomchilGorchev/pen/mJBBvE Any advice will be much appreciated! Thanks!
  3. Guys, thanks for the hints, great support, i think the problem is that a certain problem can be solved in many possible ways (if that is a problem thought )! I manage to solve it using the TweenMax onStart and onComplete callbacks and setting animationState variable to true or false inside them ... if(animationState !== true){ newPosition = leftPosition + slideWidth; tl = TweenMax.to(slide, 0.5, {backgroundPosition: newPosition + "px 0px", ease: Cubic.easeInOut, onStart: function(){ animationState = true; }, onComplete: function(){ animationState = false; } }); .... } ... Thanks again! Marked as solved
  4. Hey, thanks for the suggestion, but it didn't work, im doing everything inside the event handler anyway, please see the full function, its really custom, but you'll get the point. Essentially i have the Tween inside the event handler, because on click i need to get some data and construct the Tween base on it. I've put your suggestion on one of the possible scenarios (when 'next' is clicked): var phoneSlide = function(){ $('.phone-control').on('click', function(e){ var _this = $(this), parent = _this.closest('#outer-target'), slide = parent.find('.screen-slides'), index = +slide.attr('data-tooltip-info'), slideBgPosition = slide.css('background-position').replace(/%/g, '').split(' '), leftPosition = +slideBgPosition[0].slice(0, -2), slideWidth = 254, newPosition, prevTooltip, tl; if(_this.hasClass('next')){ newPosition = leftPosition - slideWidth; tl = TweenLite.to(slide, 0.5, {backgroundPosition: newPosition + "px 0px", ease: Cubic.easeInOut}); if(tl.isActive()){ e.preventDefault(); e.stopImmediatePropagation(); return false; } index !== 5 ? index++ : index = 1; slide.attr('data-tooltip-info', index); prevTooltip = $('#screen-info-' + (index - 1)); prevTooltip.length ? prevTooltip.css('opacity', 0) : $('#screen-info-5').css('opacity', 0); $('#screen-info-' + index).css('opacity', 1); } else if(_this.hasClass('prev')){ newPosition = leftPosition + slideWidth; tl = TweenLite.to(slide, 0.5, {backgroundPosition: newPosition + "px 0px", ease: Cubic.easeInOut}); if(tl.isActive()){ return false; } index !== 1 ? index-- : index = 5; slide.attr('data-tooltip-info', index); prevTooltip = $('#screen-info-' + (index + 1)); prevTooltip.length ? prevTooltip.css('opacity', 0) : $('#screen-info-1').css('opacity', 0); $('#screen-info-' + index).css('opacity', 1); } }); };
  5. Hello, I'm sorry if this question is being discussed already, i couldn't find anything in the documentation or the forum. Basically i have a button with which I'm triggering a background-position animation on a DOM element with lets say 240px. Everything is working fine there. The problem is if i click the trigger button while the animation is active, its start again and the background is moved 240+ pxls, depends how quickly I have clicked the second time. Is it possible to ignore clicks on the trigger while animation is running ? I've tried the following with no luck: var tl = TweenLite.to(element, 0.5, {backgroundPosition: newPosition + "px 0px", ease: Cubic.easeInOut}); if(tl.isActive()){ return false; } Thanks in advance! M. Gorchev
×
×
  • Create New...