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

              
                <svg id="mainSVG" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
  <defs>
 <path id="splashSmall" d="M3.71,15.48c-.06,0-1.41-3.45-3-7.71S.38,0,3.58,0s4.56,3.43,3,7.71S3.78,15.48,3.71,15.48Z" fill="#80DEEE"/>
 <path id="splash" d="M6.59,27.46c-.11,0-2.51-6.12-5.36-13.68S.67.05,6.35,0s8.09,6.08,5.37,13.69S6.7,27.46,6.59,27.46Z" fill="#80DEEE"/>

 </defs>
<g id="whole">
          <line id="wordLine" x1="308" x2="492" y1="340" y2="340" stroke="#EFF0F4" stroke-width="7" opacity="1"/>
       <g  class="startDragger dragger" fill="#EFF0F4">
        <path id="moreM" class="letter" d="M344.5,275.11h6.72v51.12h-7V287.94l.35,2.25L332,319.12h-5l-12.58-28.23.35-2.95v38.29h-7V275.11h6.72l15,33.75Z" />
        <rect id="moreO" class="letter" x="366.74" y="277.9" width="28" height="45" rx="13" ry="13" fill="none" stroke="#EFF0F4" stroke-miterlimit="10" stroke-width="7.4"/>
        <g id="splashGroupL" opacity="0">
          <use xlink:href="#splash" />
          <use xlink:href="#splash" />
         <use xlink:href="#splash" />
          <use xlink:href="#splash" />
          <use xlink:href="#splash" />
         </g>
        <rect id="hitStart" x="305" y="272.98" width="90" height="54.64" opacity="0"/>
        </g>
        <g class="endDragger dragger" fill="#EFF0F4">
          <path id="moreR" class="letter"  d="M439.11,326.23h8.5l-11.78-22.37a15.23,15.23,0,0,0,2.56-1.08,13,13,0,0,0,5.22-5.19,17.12,17.12,0,0,0,0-15.5,12.8,12.8,0,0,0-5.2-5.19,16,16,0,0,0-7.79-1.83H410.35v51.16h7.17V304.61H428.2Zm-21.59-44.34h13.4a6.44,6.44,0,0,1,6.06,3.78,10.54,10.54,0,0,1,0,8.34,6.59,6.59,0,0,1-2.44,2.79,6.71,6.71,0,0,1-3.62,1h-13.4Z"/>
          <polygon id="moreE" class="letter" points="490.12 281.93 490.12 275.11 464.45 275.11 460.76 275.11 457.28 275.11 457.28 326.23 460.76 326.23 464.45 326.23 490.12 326.23 490.12 319.41 464.45 319.41 464.45 304.25 486.25 304.25 486.25 297.43 464.45 297.43 464.45 281.93 490.12 281.93"/>
          <rect id="hitEnd" x="411.61" y="272.98" width="83.17" height="54.64" opacity="0"/>
        </g>
      </g>   
</svg>

              
            
!

CSS

              
                body {
 background-color: #2878e1;
 overflow: hidden;
 display: flex;
 align-items: center;
 justify-content: center;
}

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

svg {
 width: 100%;
 height: 100%;
 visibility: hidden;
}
.dragger {
 -webkit-tap-highlight-color: transparent;
}

              
            
!

JS

              
                class MoreApp {
 
 
 select = (s) => {return document.querySelector(s);}
 selectAll = (s) => {return document.querySelectorAll(s);} 
 mainTl = new TimelineMax();
 mainSVG = this.select('#mainSVG');
 whole = this.select('#whole');
 moreO = this.select('#moreO');
 moreM = this.select('#moreM');
 moreR = this.select('#moreR');
 moreE = this.select('#moreE');
 wordLine = this.select('#wordLine');
 endDragger = this.select('.endDragger');
 startDragger = this.select('.startDragger');
 allLetters = this.selectAll('.letter');
 MstartPosX = 0;
 REstartPosX = 0;
 currPosX = 0;
 distanceX = 0;
 isGoingLeft:boolean;
 wobbleEase = CustomEase.create('wobble', 'M0,0 C0.011,0.029 0.017,0.536 0.023,1.022 0.029,1.511 0.035,1.981 0.047,1.952 0.059,1.924 0.065,1.464 0.071,1.022 0.077,0.58 0.083,0.156 0.095,0.183 0.106,0.209 0.112,0.624 0.118,1.02 0.124,1.418 0.13,1.799 0.142,1.773 0.154,1.747 0.16,1.376 0.166,1.02 0.172,0.664 0.178,0.324 0.19,0.348 0.202,0.371 0.208,0.703 0.213,1.018 0.219,1.335 0.225,1.636 0.237,1.613 0.249,1.59 0.255,1.297 0.261,1.018 0.267,0.738 0.273,0.473 0.285,0.494 0.297,0.515 0.303,0.772 0.309,1.016 0.315,1.26 0.32,1.491 0.332,1.471 0.344,1.451 0.35,1.227 0.356,1.014 0.362,0.803 0.368,0.604 0.38,0.622 0.392,0.64 0.398,0.833 0.404,1.014 0.41,1.195 0.416,1.365 0.427,1.348 0.451,1.311 0.451,0.698 0.475,0.731 0.499,0.764 0.499,1.275 0.523,1.243 0.547,1.213 0.547,0.794 0.57,0.822 0.594,0.848 0.594,1.183 0.618,1.157 0.642,1.133 0.642,0.873 0.666,0.894 0.69,0.914 0.69,1.109 0.713,1.09 0.737,1.071 0.737,0.932 0.761,0.947 0.785,0.962 0.785,1.054 0.809,1.041 0.833,1.029 0.833,0.973 0.856,0.982 0.88,0.99 0.88,1.018 0.904,1.01 0.928,1.004 0.928,0.996 0.952,0.998 0.976,1 0.976,1 1,1');
 collisionEase = CustomEase.create("collisionEase", "M0,0 C0,0.086 -0.024,0.98 1,1");
 wordLineLength = Number(this.wordLine.getAttribute('x2')) - Number(this.wordLine.getAttribute('x1'));

 
  constructor(){
   

   TweenMax.set(this.allLetters, {
    transformOrigin:'50% 100%'
   })
   const tl = new TimelineMax();
   this.mainTl.add(tl);
   
   this.startDraggable = Draggable.create(this.startDragger, {
    type:'x',
    bounds:{minX:-1200, maxX:0},
    onDrag:this.onMDragUpdate,
    onPress:this.onMPress,
    onDragEnd:this.onMRelease,
    cursor:'ew-resize'
   })
    
   this.endDraggable = Draggable.create(this.endDragger, {
    type:'x',
    bounds:{minX:0, maxX:1200},
    onDrag:this.onEndDragUpdate,
    onPress:this.onEndPress,
    onDragEnd:this.onEndRelease,
    cursor:'ew-resize'
   })
   

   var introTl = new TimelineMax({delay:1});
   
   introTl.from(this.wordLine, 1, {
    drawSVG:'0% 0%',
    alpha:0,
    x:-20,
    ease:Expo.easeOut
   })
    .staggerFrom(this.allLetters,1.5, {
    alpha:0,
    x:10,
    ease:Expo.easeOut
   },0.1, '-=1')
   
   document.addEventListener("touchmove", function(event){
      event.preventDefault();
  });
  }

 onMPress =(e)=>{
  this.MstartPosX = this.startDragger._gsTransform.x;
 }
 onEndPress =()=>{
  this.REstartPosX = this.endDragger._gsTransform.x;
  
 }
 
  onMDragUpdate=()=>{
   
  
   TweenMax.set(this.moreO, {
    attr:{
     width: 28+Math.abs((this.startDragger._gsTransform.x - this.MstartPosX))
    }    
   })
  TweenMax.set(this.wordLine, {
    attr:{
     x1: 308+this.startDragger._gsTransform.x
    }    
   })
  }
  
  onEndDragUpdate=()=>{
 
   TweenMax.set(this.moreO, {
    attr:{
     width: 28+(this.endDragger._gsTransform.x - this.REstartPosX)
    }
   })
   
  TweenMax.set(this.wordLine, {
    attr:{
     x2: 492+this.endDragger._gsTransform.x
    }    
   })   
  }
 
 onMRelease =()=>{
  
  this.isGoingLeft = true;
  
  this.startDraggable[0].disable();
  this.endDraggable[0].disable();
  this.currPosX = this.startDragger._gsTransform.x;
  this.distanceX = this.currPosX - this.MstartPosX;
  let tl = new TimelineMax({onComplete:this.updateDraggables});
   tl.to(this.endDragger, 0.3, {
    x:this.startDragger._gsTransform.x,
    //ease:Elastic.easeOut.config(0.5,0.4),
    ease:Expo.easeIn
   })  
  .to(this.moreO, 0.3, {
    attr:{
     width:28//,
     //x:'+=' + this.distanceX
    },
    //ease:Elastic.easeOut.config(0.5,0.4)
    ease:Expo.easeIn
   },0)
  .to(this.wordLine, 0.3, {
    attr:{
     x2: Number(this.wordLine.getAttribute('x1')) +this.wordLineLength
    },
    ease:Expo.easeIn
   },0)  
  
    
 } 
 
 onEndRelease =()=>{
  
  this.isGoingLeft = false;
  
  this.startDraggable[0].disable();
  this.endDraggable[0].disable();
  
  this.currPosX = this.endDragger._gsTransform.x;
  this.distanceX = this.currPosX - this.REstartPosX;
  let tl = new TimelineMax({onComplete:this.updateDraggables});
   tl.to(this.startDragger, 0.3, {
    x:this.endDragger._gsTransform.x,
    ease:Expo.easeIn
    //ease:Elastic.easeOut.config(0.5,0.4)
   })  
  .to(this.moreO, 0.3, {
    attr:{
     width:28
    },
    ease:Expo.easeIn
    //ease:Elastic.easeOut.config(0.5,0.4)
   },0)
  .to(this.wordLine, 0.3, {
    attr:{
     x1: Number(this.wordLine.getAttribute('x2')) -this.wordLineLength
    },
    ease:Expo.easeIn
   },0)    
  
 }
 
/*  detectWindowEdge = ()=>{
  console.log(window.innerWidth, this.startDragger._gsTransform.x)
 } */
 
 updateDraggables = ()=>{
  this.startDraggable[0].applyBounds({maxX:this.startDragger._gsTransform.x});
  this.endDraggable[0].applyBounds({minX:this.endDragger._gsTransform.x, maxX:window.innerWidth});
  this.startDraggable[0].enable();
  this.endDraggable[0].enable(); 
  
  this.createSplash();
  
 }
 
 createSplash = () =>{
  
  //console.log(this.isGoingLeft)
  let distance = Math.abs(this.distanceX)/2;
  let letterRotation = ((distance/20) > 20) ? 20 : (distance/20);
  letterRotation = (letterRotation < 3) ? 3 : Math.round(letterRotation);
  
  let duration = (distance/100 < 2) ? 2 : distance/100;
  duration = (distance/100 > 5) ? 5 : distance/100;
  console.log(letterRotation)
  //let randomX = this.randomBetween(25, 55);
  var tl = new TimelineMax();
  tl.set('#splashGroupL', {
   alpha:1
  })
.set('#splashGroupL use', {
   scale:1
  })

   .staggerFromTo('#splashGroupL use', 1, {
      cycle:{
       rotation:[-20, -15, 10, 15, 0],
       x:[360, 350, 390, 400, 375],
       y:[250, 251, 247, 245, 248]
      },
      transformOrigin:'50% 50%'   
     },{
      cycle:{
        rotation:[-55, -60, 45, 67, 0],
        x:["-=30", "-=50", "+=30", "+=45", '+=0'],
        y:["-=29", "-=16", "-=15", "-=34", '-=55'],
        duration:[Math.random()+0.1, Math.random()+0.1, Math.random()+0.2, Math.random()+0.1,  Math.random()+0.1]
      },
      scale:0
  },0)
  //.staggerFromTo((this.isGoingLeft) ? [this.allLetters[0], this.allLetters[1]] : [this.allLetters[1], this.allLetters[2], this.allLetters[3]], duration, {
  .staggerFromTo(this.allLetters, duration/1, {
   cycle:{
    rotation:[-this.randomBetween(1, letterRotation), -this.randomBetween(1, letterRotation), -this.randomBetween(1, letterRotation), this.randomBetween(1, letterRotation)],
   }
  },{
   cycle:{
     rotation:[0],
    duration:[(this.randomBetween(0, 3)/10) + duration, (this.randomBetween(0, 3)/10) + duration, (this.randomBetween(0, 3)/10) + duration, (this.randomBetween(0, 3)/10) + duration]
   },
  
    ease:this.wobbleEase
    //ease:Bounce.easeOut
    //ease:Elastic.easeOut
  },0,0)
  
    
  //console.log(distance)
  TweenMax.to(this.whole, duration, {
   x:(this.isGoingLeft) ? '-=' + (distance) : '+=' + (distance),
   ease:this.collisionEase
  })
  
 }
 
 randomBetween = (min, max)=> {
  return Math.floor(Math.random() * (max - min + 1) + min);
}  
  get timeline():boolean {
    return this.mainTl;
  }
 
}


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

var app = new MoreApp();


              
            
!
999px

Console