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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <svg class="burgerSVG" viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMin meet" >
  <defs>
   
      <g class="burgerLines" stroke="#ededed" fill="none" stroke-width="2" stroke-linecap="round">
        <line x1="153.22" y1="13.46" x2="181.22" y2="0.46"/>
        <line x1="152.22" y1="30.46" x2="184.22" y2="41.46"/>
        <line x1="27.22" y1="11.46" x2="0.22" y2="0.46"/>
        <line x1="25.22" y1="31.46" x2="0.22" y2="43.46"/>
      </g>   
    <linearGradient id="redGrad" x1="400" y1="593.7" x2="400" y2="155.33" gradientUnits="userSpaceOnUse">
      <stop offset="0.43" stop-color="#252121"/>
      <stop offset="0.44" stop-color="#362625"/>
      <stop offset="0.46" stop-color="#5f302e"/>
      <stop offset="0.49" stop-color="#853a36"/>
      <stop offset="0.52" stop-color="#a5433e"/>
      <stop offset="0.56" stop-color="#c14a44"/>
      <stop offset="0.6" stop-color="#d75049"/>
      <stop offset="0.64" stop-color="#e8554c"/>
      <stop offset="0.7" stop-color="#f3584f"/>
      <stop offset="0.78" stop-color="#fa5a51"/>
      <stop offset="1" stop-color="#fc5a51"/>
    </linearGradient>   
 <polygon id="arrow" points="0 10 20 0 20 20 0 10" fill="#1D84B5" opacity="0.3"/>
 </defs>
 <text x="50%" y="100" class="choose">CHOOSE YOUR BURGER</text>
 <text x="50%" y="99" class="choose2">CHOOSE YOUR BURGER</text>
 <use class="arrowL arrow" xlink:href="#arrow" x="100" y="75"/>
 <use class="arrowR arrow" xlink:href="#arrow" x="601" y="56" transform="rotate(180 650 75)"/>
 <rect class="meat" x="35" y="293" width="730" height="13" rx="6" ry="6" stroke="#996251" fill="none" stroke-width="1" opacity="0"/>
 <line class="meatTrack" x1="42" y1="300" x2="758" y2="300" fill="none" stroke="#FC5A51" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" opacity="0.5"/> 
 <line class="meatFilling" x1="42" y1="300" x2="760" y2="300" fill="none" stroke="#996251" stroke-linecap="round" stroke-miterlimit="10" stroke-width="13" stroke-dasharray="0" stroke-dashoffset="0"/>
 
      <g class="burgerGroup">
       <g class="burgerScale">
        <path class="bunBot" d="M5.5,110.3h104a0,0,0,0,1,0,0V117a9.34,9.34,0,0,1-9.34,9.34H14.84A9.34,9.34,0,0,1,5.5,117V110.3A0,0,0,0,1,5.5,110.3Z" fill="#ffca63"/>
        <g class="tomatoGroup">
          <rect x="6.31" y="47.3" width="45.95" height="8" fill="#ffb7b3" stroke="#fc5a51" stroke-miterlimit="10" stroke-width="4"/>
          <rect x="62.74" y="47.3" width="45.95" height="8" fill="#ffb7b3" stroke="#fc5a51" stroke-miterlimit="10" stroke-width="4"/>
        </g>
        <path class="lettuce" d="M2,31.3c5.55,0,5.55,8,11.1,8s5.55-8,11.1-8,5.55,8,11.1,8,5.55-8,11.1-8,5.55,8,11.1,8,5.55-8,11.1-8,5.55,8,11.1,8,5.55-8,11.1-8,5.55,8,11.11,8,5.55-8,11.11-8" fill="none" stroke="#5af96c" stroke-linejoin="bevel" stroke-width="5"/>
        <g class="cheeseGroup">
          <rect class="slice" x="2" y="81.8" width="111" height="5" rx="2.5" ry="2.5" fill="#FCDF6C"/>
          <polygon class="hang" points="49.5 85.3 69.5 99.3 88.5 85.3 49.5 85.3" fill="#FCDF6C"/>
        </g>
        <g class="pickleGroup">
          <rect x="4.5" y="72.8" width="20.84" height="5" fill="#cdf953"/>
          <rect x="32.89" y="72.8" width="20.84" height="5" fill="#cdf953"/>
          <rect x="61.28" y="72.8" width="20.84" height="5" fill="#cdf953"/>
          <rect x="89.66" y="72.8" width="20.84" height="5" fill="#cdf953"/>
        </g>
        <path class="bacon" d="M0,62.8c9.58,0,9.58,4,19.17,4s9.58-4,19.16-4,9.58,4,19.17,4,9.58-4,19.17-4,9.59,4,19.17,4,9.59-4,19.17-4" fill="none" stroke="#f4a4d2" stroke-miterlimit="10" stroke-width="5"/>
       <g class="bunTop">
        <path  d="M109.5,24.65H5.5S9.62,0,57.5,0C103.32,0,109.5,24.65,109.5,24.65Z" fill="#ffca63" fill-rule="evenodd"/>
       <path fill="#FDE7BD" d="M43.08,11.78a2.57,2.57,0,1,1-2.57-2.57A2.57,2.57,0,0,1,43.08,11.78Zm34,0a2.57,2.57,0,1,1-2.57-2.57A2.57,2.57,0,0,1,77.06,11.78Zm-17,0A2.57,2.57,0,1,1,57.5,9.21,2.57,2.57,0,0,1,60.07,11.78Zm8.5-5.15A2.57,2.57,0,1,1,66,4.06,2.57,2.57,0,0,1,68.57,6.63Zm-17,0A2.57,2.57,0,1,1,49,4.06,2.57,2.57,0,0,1,51.58,6.63Z"/>
        </g>
 </g>
       <rect class="dragHit" width="118" height="228" fill="transparent" />
      </g> 
 <g class="ingredients">
 <text x="97" y="400" class="filling">ORIGINAL</text> 
 <text x="223" y="400" class="filling">CHEESE PLEASE</text> 
 <text x="346" y="400" class="filling">PICKLE ME PINK</text> 
 <text x="465" y="400" class="filling">BACON TAKE</text> 
 <text x="586" y="400" class="filling">TOMATO PARTY</text> 
 <text x="712" y="400" class="filling">LETTUCE EAT</text> 
  </g>
 <g class="burgerLineContainer"/>
</svg>
              
            
!

CSS

              
                body {
  background-color:#252627;
  overflow: hidden;
  text-align:center;
}

body,
html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}


svg{
  width:100%;
  height:100%;
/*  position:absolute;
 top:100px; */
  
  visibility:hidden;
 overflow:visible;
  
}

.choose, .choose2{
 font-family:"ff-cocon-web-pro"	;
 text-anchor:middle;
 font-size:2.7em;
 fill:none;
 stroke:#1D84B5;

 stroke-width:6;
 letter-spacing:0.1em;
}
.choose2{
 fill:#36B9CA;
 stroke:none;

 stroke-width:2;
 
}
.filling{
  font-family:"balboa-plus-inline"	;
 fill:#EF3E36; 
 stroke:#EF3E36;
 text-anchor:middle;
 font-size:2.3em;
 letter-spacing:-1px;
}

text{
  user-select:none;

}

.dragHit{
 -webkit-tap-highlight-color:rgba(0,0,0,0);
}
              
            
!

JS

              
                var xmlns = "http://www.w3.org/2000/svg",
  xlinkns = "http://www.w3.org/1999/xlink",
  select = function(s) {
    return document.querySelector(s);
  },
  selectAll = function(s) {
    return document.querySelectorAll(s);
  },
    burgerLineContainer = select('.burgerLineContainer'),
    burgerSVG = select('.burgerSVG'),
    dragHit = select('.dragHit'),
    tomatoGroup = select('.tomatoGroup'),
    lettuce = select('.lettuce'),
    cheeseGroup = select('.cheeseGroup'),
    hang = select('.hang'),
    pickleGroup = select('.pickleGroup'),
    bacon = select('.bacon'),
    bunTop = select('.bunTop'),
    meat = select('.meat'),
    burgerGroup = select('.burgerGroup'),
    burgerScale = select('.burgerScale'),
    ingredients = select('.ingredients'),
    meatFilling = select('.meatFilling'),
    meatTrack = select('.meatTrack'),
    initPos = {x:40},
    maxPos = {x:650},
    dragRange = maxPos.x - initPos.x,
    numStages = 5,
    firstTime = true,
    step = dragRange/numStages,
    burgerLines = select('.burgerLines'),
    burgerPosArr = [],
    oldId = -1, currentId = -1,
    burgerLineProps = [
     {x:8, y:272, color:'#FFCA63', meat:'0% 15.4%'},
     {x:128, y:261, color:'#FCDF6C', meat:'17% 32.6%'},
     {x:250, y:249, color:'#CDF953', meat:'33.8% 49.6%'},
     {x:375, y:238, color:'#F4A4D2', meat:'51.1% 66.2%'},
     {x:496, y:225, color:'#FC5A51', meat:'68.4% 83%'},
     {x:618, y:212, color:'#5AF96C', meat:'85.4% 100%'}]
  

TweenMax.set('svg', {
  visibility: 'visible'
})

TweenLite.defaultEase = Elastic.easeOut.config(1.16,0.8);

/*  TweenMax.set(meatFilling, {
   drawSVG:'44% 58%',
  
  ease:Expo.easeOut
 }) */ 

TweenMax.set([cheeseGroup, pickleGroup.querySelectorAll('rect'), bacon, tomatoGroup, lettuce, '.filling'], {
 alpha:0,
 transformOrigin:'50% 50%'
})

TweenMax.set(bunTop, {
 y:64
})

TweenMax.set(burgerGroup, {
 y:200,
 x:initPos.x
})

function setDraggable(){
 
 Draggable.create(burgerGroup, {
  type:'x',
  //lockAxis:true,
  trigger:dragHit,
  bounds:{minX:initPos.x, maxX:maxPos.x},
  onDrag:onDrag,
  onPress:onPress,
  cursor:'pointer',
 onRelease:onRelease,
  liveSnap:function(endValue){
   return Math.round(endValue / step) * step +initPos.x
  }
 })
 
 onDrag();
 
 playBurgerLines(0)

}

function onPress(){
 
   var percent = (burgerGroup._gsTransform.x - initPos.x)/dragRange;

   var id = percent*numStages;

   TweenMax.to(burgerScale,1, {
    scale:1.1,
    transformOrigin:'50% 78%'
   })
 }

function playBurgerLines(id){
 
  var bl = burgerLines.cloneNode(true);
  burgerLineContainer.appendChild(bl);
  var lineProps = burgerLineProps[id];
  TweenMax.set(bl, {
   x:lineProps.x,
   y:lineProps.y,
   stroke:lineProps.color
  })

  var burgerLineTl = new TimelineMax({delay:0,onComplete:removeBurgerLines, onCompleteParams:[bl]});
  var lines = bl.querySelectorAll('line');
  burgerLineTl.fromTo(lines, 0.2,{  
   drawSVG:'0% 0%'  
  }, {
   drawSVG:'20% 60%',
   ease:Linear.easeNone
  })
  .to(lines, 1, {
   drawSVG:'100% 100%',
   ease:Expo.easeOut

  }) 
 
}

function onRelease(){
  var percent = (burgerGroup._gsTransform.x - initPos.x)/dragRange;

  var id = percent*numStages;
  TweenMax.to(burgerScale, 0.3, {
   scale:1,
   ease:Power3.easeOut
  }) 
   var lineProps = burgerLineProps[id];
   playBurgerLines(id);
}
function onDrag(e){
 
 var percent = (burgerGroup._gsTransform.x - initPos.x)/dragRange;

 oldId = currentId;
 var id = percent*numStages;
 
 if(oldId == id){
  return;
 }
currentId = id;
 var lineProps = burgerLineProps[id];
 
 TweenMax.to(meatFilling, 0.61, {
 drawSVG:lineProps.meat,  
  ease:Power3.easeOut/* ,
  onComplete:playBurgerLines,
  onCompleteParams:[id] */
 }) 
 
 
 TweenMax.set('.filling', {
  y:0
 })
 TweenMax.staggerTo('.filling', 0, {
  cycle:{
   alpha:function(i){
    return (i == id) ? 1 : 0;
   } 
  },
  ease:Sine.easeOut
 },0)
 TweenMax.staggerFrom('.filling', 0.6, {
  cycle:{
   y:function(i){
    return (i == id) ? 40 : 0;
   }   
  },
  ease:Elastic.easeOut.config(0.6,0.8)
 },0)
 
 TweenMax.set('.arrow', {
  autoAlpha:1
 })
 
 if(percent == 0){
  TweenMax.to('.arrowL',0.5, {
   autoAlpha:0,
   ease:Sine.easeOut
  })
  if(firstTime){firstTime = false;return;}
  burgerTl.play('none');  
 }
 if(percent == 0.2){
  burgerTl.play('cheese')
 }
 if(percent == 0.4){
  burgerTl.play('pickle')
 }
 if(percent == 0.6){
  burgerTl.play('bacon')
 }
 if(percent == 0.8){
  burgerTl.play('tomato')
 }
 if(percent == 1){
  TweenMax.to('.arrowR',0.5, {
   autoAlpha:0,
   ease:Sine.easeOut
  })  
  burgerTl.play('lettuce')
 }
 


 
}

var introTl = new TimelineMax({onComplete:setDraggable}).timeScale(0.5);
introTl.from([burgerGroup, meat, meatFilling, meatTrack], 1, {
 alpha:0,
 ease:Sine.easeIn
})
.fromTo(meatFilling, 1, {
 
 drawSVG:'24% 78%',
},{
 drawSVG:'44% 58%',
 ease:Expo.easeOut
},'-=1')
 .from(burgerGroup, 1, {
 x:350,
 ease:Expo.easeInOut
},'+=0.3')
.from(meatTrack, 1, {
 drawSVG:'50% 50%',
 ease:Expo.easeInOut
},'-=1')
.from(meat, 1, {
 attr:{
  width:110
 },
 x:318,
 ease:Expo.easeInOut
},'-=1')
.to(meatFilling, 1, {
 drawSVG:"0% 58%",
 ease:Expo.easeInOut
},'-=1')

var burgerTl = new TimelineMax({paused:true})
burgerTl.addLabel('none')
.from(bunTop, 1, {
 y:56,
 immediateRender:false,
 ease:Elastic.easeOut.config(0.6,0.8)
})


 .addPause()

 .addLabel('cheese')
 .to(bunTop, 1, {
 y:53
})
.to(cheeseGroup, 1, {
 alpha:1
},'-=1')
.from(hang, 1, {
 x:-80,
 scaleY:0
},'-=1')

 .addPause()

.addLabel('pickle')
 .to(bunTop, 1, {
 y:44
})
.staggerTo(pickleGroup.querySelectorAll('rect'), 1, {
 alpha:1,
 ease:Expo.easeOut
},0.06,'-=1')
.staggerFrom(pickleGroup.querySelectorAll('rect'), 1, {
scaleX:0,
 ease:Expo.easeOut
},0.06,'-=' + burgerTl.recent().duration())
/* .call(function(){
 TweenMax.to(meatFilling, 1, {
  drawSVG:'34% 49.8%',
  ease:Expo.easeInOut
 })
 }, null, '-=1')
 */
.addPause()

.addLabel('bacon')
 .to(bunTop, 1, {
 y:32
})
.to(bacon, 1, {
 alpha:1,
 ease:Expo.easeOut
},'-=1')
.from(bacon, 1, {
 scaleX:0
},'-=1')

 .addPause()

.addLabel('tomato')
 .to(bunTop, 1, {
 y:16
})
.to(tomatoGroup, 1, {
 alpha:1,
 ease:Expo.easeOut
},'-=1')
.staggerFrom(tomatoGroup.querySelectorAll('rect'), 1, {
 //scaleY:0,
 cycle:{
  x:[-10, 10]
 }
},0,'-=1')

.addPause()

.addLabel('lettuce')
 .to(bunTop, 1, {
 y:0
})
.to(lettuce, 1, {
 alpha:1
},'-=1')
.from(lettuce, 1.62, {
 drawSVG:'50% 50%',
 ease:Expo.easeOut
},'-=1')

function removeBurgerLines(el){
 burgerLineContainer.removeChild(el)
}
//burgerTl.timeScale(0.5);

              
            
!
999px

Console