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

              
                <p class="scroll">scroll</p>
<div class="wrapper">   
  <div class="block block1">
    <svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewbox="0 0 164.8 426.8" class="svg svg1"><title>path-1</title><path d="M164.8 0.5s-197 29-159.5 159.5S204.3 284.5 85 426.5" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"></path></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-1.svg" alt="Oak Leaf" class="leaf leaf1"/>
    <div class="container  container1"></div>
  </div>
  <div class="block block2">
    <svg class="svg  svg2" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 118.7 180.5"><title>path-2</title><path class="path  path2" d="M118.2 0.1S101.2 142.1 0.2 180.1" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-2.svg" alt="3 Pronged Autumn Leaf" class="leaf leaf2"/>
    <div class="container  container2"></div>
  </div>
  <div class="block block3">
    <svg class="svg svg3" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 181.1 297.7"><title>path-3</title><path  class="path  path3" d="M180.9 0.5s-266 101-152 297" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-2.svg" alt="3 Pronged Autumn Leaf" class="leaf leaf3"/>
    <div class="container  container3"></div>
  </div>
  <div class="block block4">
    <svg class="svg svg4" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 180.9 51.4"><title>path-4</title><path class="path  path4" d="M0.5 14s-1 28 65 0 70-11 115 37" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-3.svg" alt="Autumn Leaf" class="leaf leaf4"/>
    <div class="container  container4"></div>
  </div>
  <div class="block block5">
    <svg class="svg svg5" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 49.9 293.9"><title>  path-5</title><path class="path  path5" d="M45.1 0.3S-0.9 69.3 37.1 142.3 14.1 296.3 0.1 293.3" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-1.svg" alt="Oak Leaf" class="leaf leaf5"/>
    <div class="container  container5"></div>
  </div>
  <div class="block block6">
    <svg class="svg svg6" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 111.5 261.7"><title>  path-6</title><path class="path  path6" d="M111.2 0.4S-68.8 97.4 30.2 261.4" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-1.svg" alt="Oak Leaf" class="leaf leaf6"/>
    <div class="container  container6"></div>
  </div>
  <div class="block block7">
    <svg class="svg svg7" id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 86.05 103.55"><title>path-7</title><path class="path  path7" d="M0.38,0s-11,69,85,103" transform="translate(0.5 0.08)" style="fill:none;stroke-miterlimit:10" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-3.svg" alt="Autumn Leaf" class="leaf leaf7"/>
    <div class="container  container7"></div>
  </div>
  <div class="block block8  block13">
    <svg class="svg svg8" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 400 113.8"><title>  path-8</title><path  class="path  path8" d="M0.5 46.6s32 159 240-14c137-96 159 54 159 54" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-1.svg" alt="Oak Leaf" class="leaf leaf8"/>
    <svg class="svg svg13" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 206.6 185.5"><title>path-13</title><path class="path  path13" d="M206.1 0S195.1 140 0.1 185" style="fill:none" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-2.svg" alt="3 Pronged Autumn Leaf" class="leaf leaf13"/>
    <div class="container  container8"></div>
    <div class="container  container13"></div>
  </div>
  <div class="block block9">
    <svg class="svg svg9" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 97.4 205.7"><title>  path-9</title><path class="path  path9" d="M97.2 0.5S-55.8 76.5 23.2 205.5" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-1.svg" alt="Oak Leaf" class="leaf leaf9"/>
    <div class="container  container9"></div>
  </div>
  <div class="block block10  block14">
    <svg class="svg svg10" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 255.8 118.7"><title>path-10</title><path class="path  path10" d="M0.5 0.1S47.5 211.1 255.5 69.1" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-3.svg" alt="Autumn Leaf" class="leaf leaf10"/>
    <svg class="svg svg14" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 204.4 66.8"><title>path-14</title><path class="path  path14" d="M0.4 0.3S46.4 63.3 204.4 66.3" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-2.svg" alt="3 Pronged Autumn Leaf" class="leaf leaf14"/>
    <div class="container  container10"></div>
    <div class="container  container14"></div>
  </div>
  <div class="block block11">
    <svg class="svg svg11" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 27.7 243.4"><title>path-11</title><path class="path  path11" d="M7.3 0.2s-19 41 7 85 7.3 70.8-9.9 91c-3.7 26.1-9.3 32 8.3 67" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>
    <img src="https://static.indigoimages.ca/2016/Shop/leaf-2.svg" alt="3 Pronged Autumn Leaf" class="leaf leaf11"/>
    <div class="container  container11"></div>
  </div>
  <div class="block block12">
    <svg class="svg svg12" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 75 98.8"><title>path-12</title><path class="path  path12" d="M53.1 0.3S127.1 81.3 0.1 98.3" style="fill:none;" class="path  path1" stroke-dasharray="5, 10"/></svg>

    <img src="https://static.indigoimages.ca/2016/Shop/leaf-3.svg" alt="Autumn Leaf" class="leaf leaf12"/>
    <div class="container  container12"></div>
  </div>
</div>

              
            
!

CSS

              
                html, body {
  background: #e27a56;
  height: 100%;
  text-align: center;
  width: 100%;
}
.scroll {
  font: italic 700 84px/1.5 'playfair display';
  color: #FBFDFE;
  letter-spacing: 0.03em;
  position: relative;
  top: 215px;
  z-index: 0;
}
.wrapper {
  position: relative;
  width: 940px;
  margin: 155px auto 1255px;
  background: rbga(255, 255, 255, 0.8);
  overflow: hidden;
  font-size: 0;
}
.block {
  height: 300px;
  width: 100%;
  background: #f3f4f6;
  margin: 20px auto 0;
  position: relative;
}
.block1, .block3 {
  background: #e1dbd4;
}

.block4, .block5, .block7, .block11 {
  background: #f0ead6;
}

.block4, .block5, .block7, .block8, .block10, .block11  {
  width: 460px;
  display: inline-block;
}
.block4, .block7, .block10{
  margin-right: 20px;
}

.leaf {
  width: 60px;
  position: absolute;
  z-index: 15;
  opacity: 0;
}

.leaf1 {
  top: 100px;
  left: 70px;
}
.leaf2 {
  top: 195px;
  left: 675px;
  width: 65px;
}
.leaf3 {
  top: 60px;
  left: 25px;
  width: 30px;
}
.leaf4 {
  top: 30px;
  left: 380px;
  width: 35px;
}
.leaf5 {
  top: 180px;
  left: 245px;
}
.leaf6 {
  top: 140px;
  left: 20px;
  width: 40px;
}
.leaf7 {
  top: 10px;
  left: 445px;
  width: 25px;
}
.leaf8 {
  top: 95px;
  left: 10px;
  width: 30px; 
}
.leaf9 {
  top: 162px;
  left: 8px;
}
.leaf10 {
  top: 60px;
  left: 175px;
  width: 35px;
}
.leaf11 {
  top: 245px;
  left: 330px;
  width: 55px;
}
.leaf12 {
  top: -40px;
  left: 185px;
  width: 35px;
}
.leaf13{
  width: 55px;
  top: 200px;
  left: 115px;
}
.leaf14{
  width: 40px;
  top: 10px;
  left:345px;
}
.svg {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  // display: none;
}
.path {
  stroke: #aaa;
}
.container {
  position: absolute;
}
.svg1, .container1 {
  position: absolute;
  width: 165px;
  top: 135px;
  left: 110px;
}
.svg2, .container2 {
  width: 118.7px;
  top: 235px;
  left: 710px;
}
.container3, .svg3 {
  width: 181.1px;
  top: 80px;
  left: 40px;
}
.container4, .svg4 {
  width: 181px;
  top: 50px;
  left: 380px;
}
.container5, .svg5 {
  width: 50px;
  top: 210px;
  left: 280px;
}
.container6, .svg6 {
  width: 111.5px;
  top: 175px;
  left: 40px;
}
.container7, .svg7 {
  width: 86px;
  top: 25px;
  left: 440px;
}
.container8, .svg8 {
  width: 400px;
  top: 110px;
  left: 20px;
}
.container13, .svg13 {
  width: 206.6px;
  top: 240px;
  left: 150px;
}
.container9, .svg9 {
  width: 97px;
  top: 200px;
  left: 50px;
}
.container10, .svg10 {
  width: 256px;
  top: 90px;
  left: 180px;
}
.container14, .svg14 {
  width: 190px;
  top: 30px;
  left: 360px;
}
.container11, .svg11 {
  width: 28px;
  top: 270px;
  left: 370px;
}
.container12, .svg12 {
  width: 75px;
  top: -15px;
  left: 222px;
}
              
            
!

JS

              
                var controller = new ScrollMagic.Controller();

for (var num = 1; num < 15; num++ ){

var svg = $('.svg'+ num),
  leaf = $('.leaf' + num),
  // pathString = $('.path' + num),
  pathString = $('.path' + num).attr('d'),
  pathCubic = Snap.path.toCubic(pathString),
  arrayPath = [],
  quantity = 45,
  duration = svg.height(),
  position = {
    x: pathCubic[0].x,
    y: [pathCubic[0].y]
  };
  
  

// function to measure how to keep element vertically centered
function calcOffset() {
  var center = $(window).scrollTop() + (window.innerHeight / 2) - (leaf.height() / 2),
    offset = leaf.position().top,
    distance = center - offset;
}

// grab svg and turn it into x & y coords
function setUpPoint(segment) {
  for (var i = 0; i < segment.length; i += 2)  {
    //create a new object for the point so it can be passed to the bezier plugin
    var point = {};
    point.x = segment[i];
    point.y = segment[i + 1];
    arrayPath.push(point);
  } //loop end
  console.log(arrayPath.length + ' this is ' + num);
}
  
// loop through the curves collection
for (var i = 0; i < pathCubic.length; i++) {
  var segment = pathCubic[i],
    point;
  // 1st element returned in the array is a letter, remove it
  segment.shift();
  //call the function to set up the points based on the segment returned
  point = setUpPoint(segment);
  
}

var thisTL = new TimelineMax()
  .add(TweenMax.to(leaf, 1, {'opacity':1}))
  .call(drawThePaths)
  .add(TweenMax.to(leaf, duration, {
    bezier: {
      values: arrayPath,
      type: "cubic",
      autoRotate: true
    },
    ease: Linear.easeNone,
    onUpdate: calcOffset
  }));

  
function drawPath(path, options) {
    options = options || {}
    var duration = options.duration || svg.height
    var easing = options.easing || 'ease-in-out'
    var reverse = options.reverse || false
    var undraw = options.undraw || false
    var callback = options.callback || function () {}
    var length = options.length || path.getTotalLength()

    var dashOffsetStates = [length, 0]
    if (reverse) {
        dashOffsetStates = [length, 2 * length]
    }
    if (undraw) {
        dashOffsetStates.reverse()
    }


    // Clear any previous transition
    path.style.transition = path.style.WebkitTransition = 'none';

    var dashArray = path.style.strokeDasharray || path.getAttribute("stroke-dasharray");

    if (dashArray != '') {
        var dashLength = dashArray.split(/[\s,]/).map(function (a) {
            return parseFloat(a) || 0
        }).reduce(function (a, b) {
            return a + b
        })
        var dashCount = length / dashLength + 1
        var a = new Array(Math.ceil(dashCount)).join(dashArray + " ")
        path.style.strokeDasharray = a + '0' + ' ' + length
    } 
    // console.log(dashLength);
    path.style.strokeDashoffset = dashOffsetStates[0];
    path.getBoundingClientRect();
    path.style.transition = path.style.WebkitTransition =
        'stroke-dashoffset ' + duration + 'ms ' + easing;
    path.style.strokeDashoffset = dashOffsetStates[1]
    setTimeout(function() {
        path.style.strokeDasharray = dashArray //set back original dash array
        callback()
    }, duration)
}

var path = document.querySelector('.path' + num);
function drawThePaths() {
    drawPath(path, {
        callback: function () {
            drawPath(path, {
                undraw: true,
                callback: drawThePaths
            })
        }
    })
}
  console.log(path);
  
  
  // drawThePaths()
  
// build scene
var scene1 = new ScrollMagic.Scene({
    triggerElement: ".container" + num,
    duration: duration
  // ,
  //   reverse: false
  })
  // .add(draw, element)
  .setTween(thisTL)
  .addTo(controller);
  
} //end loop
              
            
!
999px

Console