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

              
                <div id="back"></div>
<div id="YourGem">
  <div id='GSAP'>GSAP</div>
  <div id='Gem'></div> 
</div>
<div id="target">
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80">
  <path fill="#006838" d="M10.43 80L0 69.57V10.43L10.43 0h59.14L80 10.43v59.14L69.57 80"/>
  <g opacity=".2">
    <path fill="#D7DF23" d="M14.995 72L8 65.005v-50.01L14.995 8h50.01L72 14.995v50.01L65.005 72"/>
    <path fill="#231F20" d="M64.176 10L70 15.824v48.353L64.176 70H15.824L10 64.176V15.824L15.824 10h48.352m1.657-4H14.167l-1.172 1.172-5.824 5.824L6 14.166V65.835l1.172 1.172 5.824 5.824 1.17 1.17H65.835l1.172-1.172 5.824-5.824 1.17-1.17V14.166l-1.172-1.172-5.824-5.824L65.834 6z"/>
  </g>
  <path opacity=".5" fill="#8DC63F" d="M10 64.176V15.824L15.824 10h48.352L70 15.824"/>
  <path opacity=".5" fill="#8DC63F" d="M15.912 9.922h48.353l5.823 5.823v48.353l-5.823 5.824"/>
  <path opacity=".3" fill="#8DC63F" d="M15.775 9.994l-5.822 5.82L0 10.418 10.5 0M64.225 9.994l5.822 5.82L80 10.418 69.5 0M15.775 70.006l-5.822-5.82L0 69.582 10.5 80M64.225 70.006l5.822-5.82L80 69.582 69.5 80"/>
</svg>
</div>

<div id='desc'>Pls Drag & Throw to find one of the<br>
  <span>GSAP Member Clup 7 Gems !</span>
  <div id='FpM'>pls check in 
    <a href="https://codepen.io/MAW/full/wKWVmG/" target="_blank">Fullpage Mode</a>
  </div>
</div>

<div id='setV'>
Warning ! pls don't change this to Crazy :
<select  onchange="setV(this)">
  <option value="1">Normal</option>
  <option value="1.25">a bit Crazy</option>
</select>
</div>


<div id='box'>
  <div id='close' class="fa fa-times-circle"></div>
  <img id='logo' src="http://gravatar.com/avatar/5a224f121f96bd037bf6c1c1e2b686fb?s=256"  alt="Smiley face" width="100"><br>
  <div id="boxTitle">
  Congratulations ! You've found a GEM :
  <span id='gem'><span>
  </div>
  <div id='info'></div>
  <div id='Rmore'>Learn more about <a id='boxL' href='#' target="_blank">DrawSVGPlugin.</a></div>
</div>

              
            
!

CSS

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

body,html,#back{width:100%; height:100%; padding:0px; margin:0px;}
body{ 
  -webkit-perspective: 600px;
  perspective: 600px;
  background-color: #222;
  overflow:hidden;
  font-family:tahoma;
  color:silver;
  -webkit-user-select: none;  
  -moz-user-select: none;    
  -ms-user-select: none;      
  user-select: none;
}

a{ color:#88CE02; text-decoration:none; }
a:hover { text-decoration:underline; }

#target {  
  position:absolute;
  width: 80px;  height: 80px;  
  border-radius:10px;
}
#back{
  background-color: #81e500;
  opacity:0;
  position:absolute;
}
#YourGem{
  position:absolute;
  transform:translate(-50%,-50%);
  left:50%; top:50%;
  text-align:center; white-space: nowrap;
  color:#222;
}
#GSAP{
  font-family:'Oswald', tahoma; 
  font-size:9vw;
}
#Gem{
  font-size:22px;
  margin-top:-15px;
  font-weight:600;
}
#desc{
  white-space: nowrap;
  position:absolute;
  transform:translate(-50%,-50%);
  left:50%; top:50%;
  text-align:center;
  font-size:25px;
  font-family:'Oswald', tahoma; 
}
#desc span{ color:#88CE02; font-size:31px; }
#FpM{font-family:tahoma; font-size:16px; margin-top:40px; color:gray;}
#box{
  width:80%; height:70%;
  position:absolute;
  transform:translate(-50%,-50%);
  left:50%; top:50%;
  background:rgba(0,0,0,0.85);
  border-radius:7px;
  overflow:hidden;
  border:3px solid rgba(255,255,255,0.2);
  text-align:center;
  color:#FFF;
  opacity:0;
}
#boxTitle,#logo{display:inline}
#logo{
  border-radius:50%;
  margin-top:25px;
}
#gem{
  font-size:30px;
  font-family:'Oswald', tahoma; 
  color:#88CE02; 
}
#close{
  position:absolute;
  right:15px;  top:12px;
  font-size:22px;
  cursor: pointer;
}
#Rmore{
  position:absolute;
  left:17px;  bottom:12px;
  font-size:14px;
  color:gray;
}
#box svg{
  position:absolute;
  opacity:0.2;
  left:-150px;  top:50px;
}
#setV{ 
  position:absolute;  
  right:10px; 
  top:10px; 
  font-size:12px;
  color:silver;
}
#info{
  color:#fff;
  opacity:0.7;
  width:85%;
  text-align: justify;
  margin:auto;
  margin-top:30px;
  line-height:25px;
}
@media(max-width: 700px) {
  #GSAP{ font-size:15vw; }
  #Gem{ margin-top:-10px; }
}
@media(max-width: 600px) {
  #box{  width:100%; height:100%;}
  #logo{  margin-top:40px; }
}

#DiacoDesignLink,#pens{
  color: #fff;
}
              
            
!

JS

              
                /* a Pen by Diaco m.lotfollahi  : https://diacodesign.com */
var DOC=document,W=window;
function $(X){return DOC.querySelector(X)};
var TL=TweenLite,Throw=ThrowPropsPlugin,M=Math,
    close=$('#close'),
    fText=$('#Gem'),
    bText=$('#gem'),
    bLink=$('#boxL'),
    target=$('#target'),
    info=$('#info'),
    UX,UY,oldX=0,oldY=0,oR,R,TW=80,des=1,T,V=1,w,h,B;
    function DB(){
      w=W.innerWidth; h=W.innerHeight;
      B={minX:0,maxX:w,minY:0,maxY:h};
      D[0].applyBounds(B);
    };
    var flash=TL.fromTo('#back',0.2,{opacity:1},{opacity:0,paused:true,immediateRender:false}),
    boxT=TL.fromTo('#box',0.3,{autoAlpha:0},{autoAlpha:1,paused:true}),
    A = DOC.createElement('audio');
A.src = 'http://www.freesound.org/data/previews/260/260626_4759914-lq.mp3'; 
A.volume=.25; 
var D = Draggable.create(target,{
  onPress:function(){
    oldX=this.x;oldY=this.y;
    if(des){TL.to("#desc",0.2,{autoAlpha:0}); des=0;};
  },
  zIndexBoost:false , minDuration:5,
  onDragEnd: function(){ 
    Throw.to(target,{throwProps:{x:{velocity:"auto"},y:{velocity:"auto"}},onUpdate:Up});
  }
});
DB();
function Up(){
  var Tt=target._gsTransform,TX=Tt.x,TY=Tt.y,TB={minX:TX,maxX:TX+TW,minY:TY,maxY:TY+TW};
  if(TB.minX<B.minX||TB.maxX>B.maxX){UX=1}else{UX=0};
  if(TB.minY<B.minY||TB.maxY>B.maxY){UY=1}else{UY=0};
  if(UX || UY){
    T = M.floor(M.random()*Gems.length) ;
    fText.innerHTML = Gems[T]+' is Awesome !...' ;
    if(UX){TL.set(target,{x:TB.minX<B.minX?0:w-TW})};
    if(UY){TL.set(target,{y:TB.minY<B.minY?0:h-TW})};
    var vx = Throw.getVelocity(target,"x"),vy = Throw.getVelocity(target,"y"); 
    Throw.to(target,{throwProps:{x:{velocity:UX?-vx*V:vx},y:{velocity:UY?-vy*V:vy}},
      onUpdate:Up,onComplete:function(){ 
        bText.innerHTML='GSAP '+Gems[T];
        bLink.innerHTML=Gems[T];
        info.innerHTML=PDes[T];
        bLink.setAttribute('href','http://greensock.com/docs/#/HTML5/'+links[T]);
        boxT.play(0);
      }
    });
    oldX=TX; oldY=TY; flash.play(0); A.currentTime=0; A.play();
  };
  R = M.atan2(TY-oldY,TX-oldX);
  if(oR!=R){ 
    var nR = M.round(R*180/M.PI);
    TL.set(target,{rotation:nR});
    oR=R; 
  }
};
close.addEventListener('click',function(){boxT.reverse()});
W.addEventListener("resize",DB);
function setV(X){V=X.value};


/* a Pen by Diaco m.lotfollahi  : https://diacodesign.com */


var Gems = ['TweenMax','Draggable','ThrowProps','SplitText','SvgMorph','Physics2D','DrawSVG'],
links=['GSAP/TweenMax/','Draggable/','ThrowPropsPlugin/','Utilities/SplitText/','','Plugins/Physics2DPlugin/','Plugins/DrawSVGPlugin/'],
PDes=[
  "TweenMax extends TweenLite, adding many useful (but non-essential) features like repeat() , repeatDelay() , yoyo() , and more. It also includes many extra plugins by default, making it extremely full-featured. you the step of loading the common ones like CSSPlugin , RoundPropsPlugin , BezierPlugin , AttrPlugin, DirectionalRotationPlugin as well as EasePack , TimelineLite , and TimelineMax.",
  "Provides a surprisingly simple way to make virtually any DOM element draggable, spinnable, tossable, and even flick-scrollable using mouse and/or touch events, plus Draggable integrates beautifully (and optionally) with ThrowPropsPlugin.",
  "ThrowPropsPlugin allows you to smoothly glide any property to a stop, honoring an initial velocity as well as applying optional restrictions on the end value.ThrowPropsPlugineven integrates VelocityTracker so that you can have it 'watch' certain properties to keep track of their velocities for you and then use them automatically when you do a throwPropstween.",
  "SplitText makes it easy to break apart the text in an HTML element so that each character, word, and/or line is in its own &lt;div&gt; , making complex animation simple. SplitText automatically works around various browser inconsistencies and recognizes line breaks appropriately. Plus it is highly configurable.",
  "MorphSVGPlugin provides advanced control over tweens that morph SVG paths",
  "Provides simple physics functionality for tweening an Object's x and y coordinates (or 'left' and 'top') based on a combination of velocity, angle, gravity, acceleration, accelerationAngle, and/or friction.serves as a way to easily create interesting physics-based effects with the GreenSock animation platform.",
  "DrawSVGPlugin allows you to progressively reveal (or hide) SVG strokes to make them look like they're being drawn. It does this by controlling the stroke-dashoffset and stroke-dasharray CSS properties."
];
              
            
!
999px

Console