Jump to content
Search Community

Diaco last won the day on December 20 2017

Diaco had the most liked content!

Diaco

Business
  • Posts

    1,215
  • Joined

  • Last visited

  • Days Won

    86

Posts posted by Diaco

  1. Hi blue-infinity  :)

     

    you can get all the tweens of a particular target with getTweensOf() 

     

    and then use something like this simple loop or whatever you want : 

     

    TweenMax.to('.box', 0.5, {x: 100, yoyo: true, repeat: -1});
    TweenMax.to('.box', 0.5, {rotation: 360,backgroundColor:'red', yoyo: true, repeat: -1});
    
    document.getElementById("btn").onclick = function() {
      var Tweens = TweenMax.getTweensOf('.box'); 
      for(var i=Tweens.length; i--{
        Tweens[i].repeat(0).progress(1).kill();
      }
    }
    • Like 1
    • Thanks 1
  2. Hi chriswyl :)

     

    pls use svgOrgin instead of transformOrigin , like this : 

    TweenMax.set("#mytext", {rotation:30,svgOrigin:"200 100"})
    Draggable.create("#mytext", {type:"x,y"});
    

    and if you have bunch of rotated elements , something like this little function can help you : 

     

    function svgInlineRotated(svgElem){
      var t = svgElem.getAttribute("transform") ,
      v = t.split('(')[1].split(')')[0].split(' ') 
      TweenMax.set(svgElem, {rotation:v[0],svgOrigin:v[1]+' '+v[2]})
    };
    
    svgInlineRotated(document.getElementById("mytext"))
    
    //TweenMax.set("#mytext", {rotation:30,svgOrigin:"200 100"})
    
    Draggable.create("#mytext", {type:"x,y"});

     

    pls check this out : 

    See the Pen RaVPEB by MAW (@MAW) on CodePen

     

     

     

     

     

    • Like 4
  3. yep it's one of the GSAP engine options .

     

    and onComplete will remove listener but if you kill before tween complete , you should to remove that with this :

    ticker.removeEventListener("tick", render); 

    and another way is this ( without addListener ) :

    var tick = 0;
    TweenMax.to('.ball', 30 ,{x:200 ,
      onStart : function(){ tick = 0 },
      onUpdate : function(){
        tick++ ;
        if ( tick%60 == 0 ){ // your function call or whatever }
      }
    });
    • Like 1
  4. Hi mimeartist  :)

     

    you can try something like this :

     

    var ticker = new com.greensock.Ticker(1); // tick once per second
    
    ticker.addEventListener("tick", render);
                      
    function render(){ console.log('hi') }; // render is your function to call and can be whatever you want
    
    TweenMax.to('.ball', 30 ,{x:200 ,
      onStart:function(){ ticker.addEventListener("tick", render); },
      onComplete:function(){ TweenLite.delayedCall(0.01,function(){ ticker.removeEventListener("tick", render) } ) } 
    });
    • Like 4
  5. To call function at 30fps you can use something like this :

     

    function caller(fps,fn){
      var x = 0;
      this.call = function(){ x++; if(x % fps == 1 ){ fn() }; }
    };
    
    var nCaller = new caller( 30 , render ); // call function 30fps ( max to 60 )
    
    TweenLite.ticker.addEventListener('tick',nCaller.call); // call function 60fps
    
    function render(){
      console.log('render')
    };
  6. You read that correctly... :)

     

    but check what you got : invalid pause tween value: true "

     

    that's why i said use paused instead of pause .

     

    pls check this out : 

    See the Pen yOVxeZ by MAW (@MAW) on CodePen

     

    btw , you can defined paused tween in this way too :

    TweenLite.to( obj , 1, { .... } ).paused( true );
    • Like 2
  7. Hi Ninili  :)

     

    if i understand correctly , the short answer is nope , the order in which you declare the transform properties makes no difference.

     

    as you can read in CssPlugin Doc : http://greensock.com/docs/#/HTML5/Plugins/CSSPlugin/

     

    In regular CSS, the order that you list the transforms matters but GSAP always applies them in the same order for consistency: translation (x, y, z), then scale, then rotationX, then rotationY, then skew, thenrotation (same as rotationZ) although in terms of constructing the matrix, the math is technically done in the reverse of that order. 

    • Like 3
  8. Hi xtn  :)

     

    nope , for now there isn't any built-in solution , but i think in your case , the simplest way is one of these :

    /// method 1 :
    
    var elem = document.getElementById('blueBox');
    // set() step :
    var oldBackground = window.getComputedStyle(elem,null)["background-color"] || '' ;
    TweenLite.set(elem,{backgroundColor:'#fff'});
    
    // revert step :
    TweenLite.to(elem,1,{backgroundColor:oldBackground});
    
    /////////////////////////////////////////////////////////////////////
    
    /// method 2 :
    
    var elem = document.getElementById('redBox');
    // set() step :
    TweenLite.set(elem,{backgroundColor:'#fff'});
    
    // revert step :
    TweenLite.set(elem,{clearProps:'backgroundColor'});
    TweenLite.from(elem,1,{backgroundColor:'#fff'});

    i don't know what's your scenario/code , but you can use this too :

    TweenLite.from( elem , 1 , { backgroundColor:'#fff' , paused:true });

    and then play that when you want 

    • Like 4
  9. Hi sorciereus  :)

     

    pls add this to your css : transform: translate(-50%,0%);

     

    and yep , for the separate delays and smoothest tween ( use x/y & subpixels instead of letterSpacing and pixels ) that's better to use GSAP SplitText plugin .

    • Like 4
  10. Hi guys :)

     

    If i understood correctly you need to detect devices width/height , Touch support , maybe sensors , vibrator or ... etc , right !? ...  

     

    So simply you just need to check those specs for your needs .

     

    otherwise what's the difference between desktop and mobile !?

  11. Hi Acmafali :)

     

    with MorphSVGPlugin you can Morph these SVG tag : <path> <polyline> <polygon> ,  not group of svg elements ( < g > tag )
      
    There's a utility function, MorphSVGPlugin.convertToPath() that can convert primitive shapes like <circle>, <rect>, <ellipse>, <polygon>, <polyline>, and <line> directly into the equivalent <path> that looks identical to the original and is swapped right into the DOM.
    • Like 3
×
×
  • Create New...