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

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

              
                <div class="container steps">
  <div class="row">
    <div class="relative">
      <div id="trigger"></div>
      <div id="trigger2"></div>
      <div id="trigger3"></div>
      <div class="characterContainer">
        <img class="character" src="//design-voilaah.com/mnd/app/images/side/walking-man-side01.png"><br>
      </div>
    </div>    
  </div>
</div>
              
            
!

CSS

              
                body {
  padding: 0;
  margin: 0;
}
.container {
  position: relative;
  max-width: 1170px;
  margin: 0 auto;
}
.steps {
  margin: 400px auto;
}
.relative {
  position: relative;
}


#trigger {
    background-color: red;
    width: 30px; height: 30px;
    z-index: 10;
    position: absolute;
    top: 0px;
}
#trigger2 {
    background-color: red;
    width: 30px; height: 30px;
    z-index: 10;
    position: absolute;
    top: 450px;
}
#trigger3 {
    background-color: red;
    width: 30px; height: 30px;
    z-index: 10;
    position: absolute;
    top: 870px;
}


.characterContainer {
    position: absolute;
    z-index: 1;
    top: -125px;
    left: -50px;
    width: auto;
    height: 129px;
}
.character {
    border: 0;
    width: auto;
    height: 100%;    
    &.REVERSE {
        transform: rotateY(180deg);
    }
}
              
            
!

JS

              
                var tween;
var newWidth,    
    $cachedBg = $('.steps .bg'),
    $cachedCharacterContainer = $(".characterContainer"),
    $cachedCharacter = $(".character");

function n(n){
  return n > 9 ? "" + n: "0" + n;
}

// define images for all the sprites animations
var imgArrays = {},
    imgConfig = {
      "imgTemplateName" : "walking-man-{$type}{$number}.png",
      "types" : [
        { "name": "side", "reverse": "side", "count": 38 },
        { "name": "front", "reverse": "back", "count": 38 }
      ]
    };

imgConfig.types.forEach(function(value, index, array) {
  var type = value.name,
      reverseType = value.reverse,
      count = value.count;
  
  imgArrays[type] = [];
  imgArrays[type + "Reverse"] = [];
  for (var i = 1; i <= count; i++) {
     imgArrays[value.name].push("//design-voilaah.com/mnd/app/images/" + type + '/' + imgConfig.imgTemplateName.replace("{$type}", type).replace( "{$number}", n(i) ));
     imgArrays[value.name + "Reverse"].push("//design-voilaah.com/mnd/app/images/" + reverseType + '/' + imgConfig.imgTemplateName.replace("{$type}", reverseType).replace( "{$number}", n(count - i + 1) ));
     }
 });

// TweenMax can tween any property of any object. We use this object to cycle through the array
var obj = {curImg: 0};
var imgSideArray = imgArrays['side'],
    imgSideReverseArray = imgArrays['sideReverse'],
    imgFrontArray = imgArrays['front'],
    imgFrontArrayReverse = imgArrays['frontReverse'];
        

var imgSideSrcArray = imgSideArray,
    imgFrontSrcArray = imgFrontArray;


// create 2 sprites tweens
var frontSpriteTween = TweenMax.to(obj, 0.5,{
  curImg: imgFrontSrcArray.length - 1,  
  roundProps: "curImg",               
  repeat: 5,                               
  immediateRender: true,          
  ease: Linear.easeNone,      
  onUpdate: function () {
    imgFrontSrcArray = $cachedCharacter.hasClass('REVERSE') ? imgFrontArrayReverse : imgFrontArray;
    $cachedCharacter.attr("src", imgFrontSrcArray[obj.curImg]); // set the image source
  }
});

var sideSpriteTween = TweenMax.to(obj, 0.5,{
  curImg: imgSideArray.length - 1, 
  roundProps: "curImg",               
  repeat: 5,
  immediateRender: true,          
  ease: Linear.easeNone,         
  onUpdate: function () {
    imgSideSrcArray = $cachedCharacter.hasClass('REVERSE') ? imgSideReverseArray : imgSideArray;
    $cachedCharacter.attr("src", imgSideSrcArray[obj.curImg]); 
  }
});

var sideSpriteTween2 = TweenMax.to(obj, 0.5,{
  curImg: imgSideArray.length - 1, 
  roundProps: "curImg",               
  repeat: 5,                              
  immediateRender: true,          
  ease: Linear.easeNone,         
  onUpdate: function () {
    imgSideSrcArray = $cachedCharacter.hasClass('REVERSE') ? imgSideReverseArray : imgSideArray;
    $cachedCharacter.attr("src", imgSideSrcArray[obj.curImg]); 
  }
});
// init scrollmagic stuff
var controller = new ScrollMagic.Controller();

var scene = new ScrollMagic.Scene({triggerElement: "#trigger", duration: 420})
  .setPin(".characterContainer")
  .setTween(sideSpriteTween)
  .addIndicators() 
  .on("update", function (e) {
    $cachedCharacter.attr("class", "character " + e.target.controller().info("scrollDirection"));
  })
  .addTo(controller);

    var scene2 = new ScrollMagic.Scene({triggerElement: "#trigger2", duration: 400})
    .setPin(".characterContainer")
    .setTween(frontSpriteTween)
    .addIndicators()
    .on("update", function (e) {
      $cachedCharacter.attr("class", "character " + e.target.controller().info("scrollDirection"));
    })
    .addTo(controller);


    var scene3 = new ScrollMagic.Scene({triggerElement: "#trigger3", duration: 420})
    .setPin(".characterContainer")
    .setTween(sideSpriteTween)
    .addIndicators() 
    .on("update", function (e) {
      $cachedCharacter.attr("class", "character " + e.target.controller().info("scrollDirection"));
    })
    .addTo(controller);

              
            
!
999px

Console