Pen Settings



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


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


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.


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.


  <li> 1. top box not correctly positioned (should be equally spaced)</li>
  <li> 2. progress() is triggering onComplete handler</li>
  <li>3. Nothing should be moving at start</li>

<div id="container"></div>


                .symbol {
  width: 100px;
  height: 100px;
  position: absolute;
  z-index: 1;
  border: 1px solid khaki;

.seven {
  background-color: blue;

.bell {
  background-color: yellow;

.cherry {
  background-color: red;

.purplediamond {
  background-color: purple;

.bar {
  background-color: brown;

.wild {
  background-color: orange;

#container {
  border: 1px solid black;
  top: 100px;
  left: 140px;
  width: 200px;
  height: 500px;
  position: absolute;
  fill: none;
  overflow: visible;


                var spinningtweens = [];
var slowingtweens = [];
var container = $("#container"),
  tl; //tweens need a container to work, it seems

var symbols = ["seven", "cherry", "bell", "purplediamond", "wild", "bar"];
var animationsstopped = 0;

var symbolheight = 100;

function CreateSlots() { //create slots in reel

  var reel = 0;
  var slot;

  for (slot = 0; slot <= 3; slot++) { //for each slot per reel  // '=' because for the 'dummy' symbol to fill in the blank spot

    var symbol = randomSymbol();
    var element = $('<div id=\"symbol0' + "_" + slot + '\"  class=\"' + symbol + ' symbol \" />'); //create new slot in HTML - graphics and size are defined in CSS

      "top": "-100px"
    }); //start just out of sight

    container.append(element); //tweens need a container to work, it seems


function createanimations() {
  var reel = 0;
  var slot;
  var element;
  for (slot = 0; slot <= 3; slot++) { //for each slot per reel  // '=' because for the 'dummy' symbol to fill in the blank spot

    element = document.getElementById("symbol0_" + slot);

    //create animation that spins the symbol
    var tween = new TweenMax(element, 1, {
      top: (3 * symbolheight) + "px",
      ease: Linear.easeNone,
      onComplete: tweenComplete,
      paused: true,
      immediateRender: false,

    }); //create new tween
    tween.slot = slot; //save what position it is

    spinningtweens[slot] = tween; //save data in our data structure

    //create animation that slows and stops the symbol
    var tween2 = new, 1 * (slot), {
      top: slot * symbolheight + "px",
      ease: Back.easeOut,
      immediateRender: false,
      onComplete: completestop,
      paused: true,

    tween2.slot = slot; //save what position it is

    slowingtweens[slot] = tween2; //save data in our data structure

  console.log("createanimations() finish");

function randomSymbol() {

  var rnd = Math.floor((Math.random() * symbols.length)); //randomly generate the type of slot
  return symbols[rnd]; //just return last symbol in list

function tweenComplete() {
  console.log("spinning tween completed.  slot:" + this.slot);

function completestop() {
  //check that all symbols have stopped slowing
  console.log("slowing tween completed.  animationsstopped:" + animationsstopped + " slot:" + this.slot);


function resetslots() {
  var reel = 0;
  var slot;
  var progress, slowprogress;

  animationsstopped = 0; //sometimes if you spam the stop button it miscounts

  for (slot = 0; slot <= 3; slot++) { //for each slot per reel // '=' because for the 'dummy' symbol to fill in the blank spot

    progress = (slot + 1) / (3 + 1);
    slowprogress = 0;
    console.log("resetting progress of slot:" + slot + " reel:" + reel + " to:" + progress + " slowprogress:" + slowprogress);

    slowingtweens[slot].pause(); //stop it
    slowingtweens[slot].progress(slowprogress); //Why the f does setting this trigger the oncomplete handler
    spinningtweens[slot].pause(); //stop it
    spinningtweens[slot].progress(progress, true); //I have suppressEvents set to true!  Why the F is it still triggering the oncomplete event when i set it to 1??  Bug??
    console.log("progress set");



$(document).ready(function() {
  console.log("main.js ready");

  CreateSlots(); //create the slot and each animation

}); //end ready