Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                <!--control btn-->
<button onclick="pause()">Pause</button>
<button onclick="play()" >Play</button>
<button onclick="restart()">Restart</button>
<button onclick="reverse()">Reverse</button>
<button onclick="once()">loop once</button>
<button onclick="infinity()">loop infinity</button>
<button onclick="timeScale(1)">speed 1x</button>
<button onclick="timeScale(4)">speed 4x</button>
<button onclick="timeScale(10)">speed 10x</button>
<br>

<!--method 1-->
<div class="character"></div>
#1 - background position tween 

<!--method 2-->
<div class="container">
<img class="character2" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/183204/char.png" >
</div>
#2 - img/div 'x' tween . i prefer this one , check Chrome > Rendering > show paint rectangles 



              
            
!

CSS

              
                body{  
  background-color: #333;
  font-family:arial;
  color:silver;
}

.character {
  background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/183204/char.png);
  width: 150px;  height:150px; 
}

.container {
  width: 150px;  height:150px;  overflow:hidden;
}

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

              
            
!

JS

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

// you can use this methods even in GSAP timelines :



// method 1 ( div background position ) :
var M1 = TweenMax.to('.character',1,{repeat:-1,backgroundPosition: "-2400px",ease:SteppedEase.config(16)});



// method 2 ( img/div tag x position ) :
var M2 = TweenMax.to('.character2',1,{repeat:-1,x:-2250,ease:SteppedEase.config(15)});



// Control functions ( you can add whatever you want ) : 

function play(){ M1.play(); M2.play(); };

function pause(){ M1.pause(); M2.pause(); };

function restart(){ M1.restart(); M2.restart(); };

function reverse(){ M1.reverse(); M2.reverse(); };

function once(){ M1.repeat(1); M2.repeat(1); };

function infinity(){ M1.repeat(-1); M2.repeat(-1); };

function timeScale(X){ 
  TweenLite.to([M1,M2],1,{timeScale:X});
  //M1.timeScale(X); M2.timeScale(X); 
};


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

Console