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

              
                
<button id="start">Start</button>
<button id="stop">Stop</button>


<svg xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="1.5" clip-rule="evenodd" viewBox="0 0 259 117">
  <g id="wheel">
    <path fill="#fff" d="M108.927 86.351c-15.579 28.04-50.993 38.156-79.033 22.576C1.854 93.348-8.262 57.934 7.318 29.894 22.897 1.854 58.311-8.262 86.351 7.318c28.04 15.579 38.156 50.993 22.576 79.033zm-2.371-1.318c-14.852 26.732-48.613 36.376-75.345 21.523C4.48 91.704-5.164 57.943 9.688 31.211 24.541 4.48 58.302-5.164 85.033 9.688c26.732 14.853 36.376 48.614 21.523 75.345z"/>
    <path fill="#fff" stroke="#000" stroke-width="1.16" d="M106.884 85.215c-14.957 26.919-48.949 36.633-75.861 21.68C4.111 91.942-5.595 57.948 9.361 31.03 16.825 17.597 29.029 8.448 42.728 4.511 56.48.559 71.739 1.859 85.222 9.35c26.912 14.953 36.618 48.947 21.662 75.865zM58.271 57.913c.012-.017.032-.098.038-.112a.345.345 0 00-.076-.146c.013-3.931 6.447-51.438 5.892-51.501-4.225-.484-15.496.455-18.662 1.876-.29.13 14.243 49.63 12.61 49.953-.819.162-16.51-49.454-17.354-49.181-3.948 1.273-10.933 4.505-13.61 6.985-.41.381 31.831 42.066 31.4 42.427-.35.292-34.693-39.58-35.035-39.277a51.973 51.973 0 00-8.809 10.089c-.772 1.156 41.508 25.914 43.568 28.629l-.001.019.001.023c.016.01.038.216.038.216zm-.071.03c.017-.053-40.634-17.418-40.634-17.418l3.641 11.333 36.551 6.263h.023l.419-.178-.001.004-.004.01.005-.014zm-.419.178h-.023l-.002.002c-.145.011-35.042-1.251-35.042-1.251l4.14 14.902 30.872-13.617.053-.036h.003-.001zm.426-.138c1.094.542 33.855 39.944 34.237 39.611 3.299-2.866 8.249-8.097 10.23-12.173.347-.714-44.112-25.56-44.376-27.522-.01.009-.019.014-.027.014a.383.383 0 01-.064.07.045.045 0 00-.019-.006l.007-.02-.214.131c-.051.013-.361.189-.419.256L28.164 75.19l5.126 19.748s20.225-31.904 24.272-36.594c0 0 .565-.304.617-.341v.001c-1.392 4.061-24.062 46.599-23.401 46.93 5.322 2.658 10.833 4.367 16.32 5.191.787.119 6.333-52.235 7.118-52.153.784.082-3.193 52.6-2.412 52.646a50.694 50.694 0 0014.069-1.114c.846-.189-13.141-50.927-12.311-51.16.893-.25 16.601 50.001 17.474 49.701 4.591-1.578 8.881-3.839 12.697-6.728.455-.345-29.352-42.087-29.554-43.313v-.001h0c-.002-.012-.001-.02.004-.024l.005-.002-.009.026.008-.005.02-.015zm.662-.606c.213-.302 35.85-36.372 35.398-36.756-1.991-1.69-6.51-5.659-8.849-7.111-.548-.34-26.78 43.78-26.953 44.022l.014-.042.009-.028c1.612-4.729 23.377-45.958 22.601-46.338a52.105 52.105 0 00-12.537-4.269c-.846-.172-8.452 45.557-10.064 50.607l-.024.071.001-.001-.008.023-.026.088-.007.028c.094-.078.244-.177.445-.294zm-.194.265s47.366-19.924 46.91-20.888c-2.443-5.153-2.949-7.822-7.024-11.968-.507-.516-39.747 32.668-39.747 32.668l-.065.089c-.167.105-.28.162-.335.165l.01-.037-.012.009.029-.077.016-.048.003-.01.004-.012c-.069.096-.096.153-.08.168l.003.002.019-.017.006-.006-.007.019-.003.009.004.001.008-.001-.004.018-.002.009c.062-.032.151-.063.267-.093zm-.365.16l-.012.097a.12.12 0 00.018-.02c.112.246 47.35 22.09 47.679 21.379 2.173-4.701 3.873-12.132 4.361-17.132.145-1.484-51.79-4.204-51.932-4.226a.016.016 0 01-.01-.001l-.001-.001a.188.188 0 01-.087-.033l-.01.014c-.006-.013.028-.108.069-.132l-.013.031-.001.002.017-.009.014-.005c-.014.075-.01.12.011.132l.008.002h.003c.03-.002.089-.058.175-.163.15 0 51.842-1.634 51.748-2.82-.312-3.902-1.328-8.529-2.472-12.257-.351-1.14-49.252 15.049-49.276 15.077a.59.59 0 00-.197.029l.001-.004.005-.027-.016.008-.007.004.017-.039-.009-.001-.006-.004a.283.283 0 00-.078.098l.001.001z"/>
    <path fill="#404040" stroke="#000" d="M12.987 38.317C.062 49.567 11.438 93.67 29.554 96.095L12.987 38.317z"/>
    <path fill="#fff" stroke="#000" stroke-width="1.16" d="M68.281 63.767c-3.116 5.608-10.198 7.632-15.804 4.516-5.607-3.115-7.629-10.197-4.513-15.805 3.116-5.608 10.198-7.632 15.804-4.517 5.607 3.116 7.629 10.198 4.513 15.806z"/>
  </g>
  <path id="pleuel02" fill="#fff" stroke="#000" d="M266.584 55.612h-88.063c-2.819.897-2.487 4.684 0 5.109h88.063c1.785-1.565 1.736-3.368 0-5.109z"/>
  <g id="pleuel">
    <path  fill="#fff" stroke="#000" d="M181.036 55.612H89.748c-2.923.897-2.578 4.684 0 5.109h91.288c1.85-1.565 1.799-3.368 0-5.109z"/>
    <circle cx="179.126" cy="58.208" r="1.25" fill="#fff" stroke="#000"/>
    <circle cx="92.5" cy="58.208" r="1.25" fill="#fff" stroke="#000"/>
  </g>

  <path d="M191.962 44.541h60.954c8.594 9.334 8.729 18.412 0 27.222h-60.954V44.541z"/>
  <path fill="none" stroke="#000" stroke-width="6" d="M251.137 46.457v23.491"/>
  <path fill="none" stroke="#000" stroke-width="6" d="M193.137 46.457v23.491"/>

  <circle class="check" cx="58" cy="58" r="34.5" fill="none" stroke="green" stroke-width=".55"/>
    <circle class="check" cx="58" cy="58" r=".5" fill="none" stroke="green" stroke-width=".55"/>
</svg>


              
            
!

CSS

              
                
body{
  background-color:grey;
}
button{
  font-size: 20px;
  padding: 5px;
  width: 100px;
  height: 33px;
  background-color: #696868;
  border: none;
  border-radius: 5px;
  margin: 10px;
  outline: none;
  cursor: pointer;
}
              
            
!

JS

              
                console.clear();

gsap.set("#pleuel", {transformOrigin: "98.5% center"});
gsap.set("#wheel", {transformOrigin: "center center"});

var wheel = gsap.to("#wheel", {rotation: 360, ease: "none", paused:true})
var schub = gsap.to("#pleuel02", {x: '-=80', duration:1, repeat:1, yoyo:true, ease: "none", paused:true})

var xValue = 34.5;  //radius
var yValue = 22.5;

var master = gsap.to({foo: 0}, {foo: 1, duration: 25, repeat:0, onUpdate: function() {
  let prog = this.progress();
  
  gsap.set('#pleuel, #pleuel02', {x: (Math.cos(prog * Math.PI * 2)) * xValue - xValue});
  //gsap.set('#pleuel02', {x: (Math.cos(prog * Math.PI * 2)) * xValue - xValue});
  
  gsap.set("#pleuel", {rotation: Math.sin(prog * Math.PI * 2) * - yValue});
  
  wheel.progress(prog);
}});



// Animate the master's progress for example
//gsap.to(master, {duration: 1, progress:0, repeat: -1, ease:'power4.in'});



 master.pause();


var start = document.querySelector("#start");
start.addEventListener("click", function (){ 
  master.play(0);
  var smooth = gsap.to(master, {timeScale:3, duration: 10, ease: "power1.inOut"});
  //gsap.to(master, {timeScale: 1, duration: 3, ease: "power1.out"});
});


var stop = document.querySelector("#stop");
stop.addEventListener("click", function (){ 

  gsap.to(master, {timeScale: 0, duration:4, ease: "power1.inOut", repeat:1, onComplete: function(){master.pause(0)}});
});
              
            
!
999px

Console