Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <span id="textS">GSAP</span>
<div id='box' class="box"></div>
<div class='desc'>
  GSAP Debouncing :<br>
  pls resize the window to stop / play Tween
</div>





<img id='logo' src="http://gravatar.com/avatar/5a224f121f96bd037bf6c1c1e2b686fb?s=256" height="70" width="70">
<div id='links'>
<a id='twitter' href="https://twitter.com/Diaco_ml" target="_blank"><span class='fa fa-twitter'></span></a>
<div id='pens'><a href="https://codepen.io/collection/DgYoEw/" target="_blank"><span class='fa fa-codepen'></span></a> my other Pens</div>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Oswald);

body{  
  background-color: #111; 
  width:100%;
  height:100%;
  overflow:hidden;
}

.box {  
  width: 150px;  height: 150px;  
  border-radius:10px;
  background-color: #88CE02; 
  position:absolute;
  transform:translate(-50%,-50%);
  left:50%; top:50%;
}
#textS{ 
  color:#000;
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  font-family:'Oswald', tahoma; font-size:40vw;
  text-align:center; white-space: nowrap;
  color:#000;
  opacity:0.5;
}

.desc{
  position:absolute;
  top:10px;left:10px;
  color:#eee;
  font-size:17px;
  font-family:arial;
}

#logo {
  border-radius: 50%; 
  position:absolute;
  z-index:5000;
  top:20px; right:20px;
}


#links{z-index:9999; position:absolute;bottom:0px;left:0px;width:100%;height:50px;font-size:13px;font-family:tahoma;color:#fff;}
#links a{text-decoration:none;font-size:2.3em;color:#fff;}
#twitter{position:absolute;bottom:15px;right:20px;}
#pens{position:absolute;bottom:15px;left:20px;}
              
            
!

JS

              
                /* 
a Pen by DIACO : twitter.com/Diaco_ml || codepen.io/MAW
powered by GSAP : https://www.greensock.com/
..........................................................
GsDebouncing , a simple way with GSAP api to call functions at the Start and End of Events like Scrolling and Resizing , ... etc 

conf object :
fn1 = Function to call at Start ;
fn2 = Function to call at End ;
dur = Duration of Debouncing , by defult = 0.2 ;
*/


function GsDebouncing(conf){
  var T = this ;
  T.dur = conf.dur || 0.2 ;
  T.f1 = conf.f1 || function(){} ;
  T.f2 = conf.f2 || function(){} ;
  T.toggle = 1;
  T.tw = TweenLite.delayedCall( T.dur , function(){ T.f2(); T.toggle=1; }).paused(true);
  T.run = function(){
    if( T.toggle ){ T.f1(); T.toggle=0; }; 
    if( !T.toggle ){ T.tw.restart(true) };
  }
  return T
};

/////////////////////////////////////////////////
/// Usage Examle :

var Tween = TweenMax.to('.box',2,{rotation:360,repeat:-1,ease:Linear.easeNone});
// you can use timeline too 

var myDebouncing = new GsDebouncing({
  f1 : function(){ Tween.pause() } ,
  f2 : function(){ Tween.play() }  ,
});
         
window.addEventListener('resize',myDebouncing.run) ;
document.addEventListener('scroll',myDebouncing.run) ;
              
            
!
999px

Console