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

              
                #container
  #buttons
    %button#play.bungee PLAY
    %button#pause.bungee PAUSE
    %button#reset.bungee REWIND
    %button#process.bungee REPROCESS
%link{href: "https://fonts.googleapis.com/css?family=BioRhyme|Bungee|Cabin+Sketch", rel: "stylesheet"}

#stage-container{height: "320", style: "width: 900px; height: 320px; background-color: rgb(255, 255, 255);", width: "900"}
  #stage{height: "320", style: "width: 900px; height: 320px;", width: "900"}
    %svg#stage-master{height: "320", version: "2", viewbox: "0 0 900 320", width: "900", x: "0", xmlns: "http://www.w3.org/2000/svg", y: "0"}
      %foreignobject.node{height: "320", id: "fo-ff", width: "900", x: "0", y: "0"}
#text-container
  %textarea{id: "content", rows: "2"} Followed Phrase
  .inputs
    %label.bio{for: "in-speed"} In speed
    %input#in-speed{type: "text", value: ".75"}
    %label.bio{for: "out-speed"} Out speed
    %input#out-speed{type: "text", value: ".75"}
    %label.bio{for: "stagger-delay"} Stagger delay
    %input#stagger-delay{type: "text", value: "0.1"}
    %label.bio{for: "duration"} Duration
    %input#duration{type: "text", value: "3"}
  .select-group
    .select-wrapper
      %h5.bio In effect
      %select.easing-options#ff-in-ease.bungee
        %option{value: "Back.easeOut", selected: ""} Overshoot
        %option{value: "Elastic.easeOut"} Spring
        %option{value: "Bounce.easeOut"} Bounce
        %option{value: "Circ.easeOut"} Slowing down
        %option{value: "Circ.easeIn"} Speeding up
        %option{value: "Back.easeIn"} Back up and go
        %option{value: "Power0.easeNone"} None
    .select-wrapper
      %h5.bio Out effect
      %select.easing-options#ff-out-ease.bungee
        %option{value: "Back.easeIn", selected: ""} Back up and go
        %option{value: "Elastic.easeOut"} Spring
        %option{value: "Bounce.easeOut"} Bounce
        %option{value: "Circ.easeOut"} Slowing down
        %option{value: "Circ.easeIn"} Speeding up
        %option{value: "Back.easeOut"} Overshoot
        %option{value: "Power0.easeNone"} None
    .select-wrapper
      %h5.bio Animation direction
      %select#ff-direction.bungee
        %option{value: "lr"} Left to right
        %option{value: "rl"} Right to left
        %option{value: "tb"} Top to bottom
        %option{value: "bt"} Bottom to top
        %option{value: "appear"} Appear
    .select-wrapper
      %h5.bio In scaling
      %select#ff-in-scale.bungee
        %option{value: "none"} None
        %option{value: "up"} Scale up
        %option{value: "down"} Scale down
    .select-wrapper
      %h5.bio Out scaling
      %select#ff-out-scale.bungee
        %option{value: "none"} None
        %option{value: "up"} Scale up
        %option{value: "down"} Scale down
        
              
            
!

CSS

              
                .cabin
  font-family: 'Cabin Sketch', cursive
.bungee
  font-family: 'Bungee', cursive
.bio
  font-family: 'BioRhyme', serif
#stage-container
  overflow: hidden
svg#stage-master
  background: black
  .container
    position: relative
    display: flex
    flex-flow: row nowrap
    justify-content: center
    align-items: center
    width: 900px
    height: 320px
    text-rendering: auto
    box-sizing: border-box
    text-align: center
    visibility: visible
    .copy-box, .msg-box
      position: absolute
      font-size: 24px
      transform:translateZ(0.1px)
    .motion-blur0
      filter: url("#ffBlur0")
    .motion-blur1
      filter: url("#ffBlur1")
    .motion-blur2
      filter: url("#ffBlur2")
    .motion-blur3
      filter: url("#ffBlur3")
#text-container
  margin: 10px 0 0 0
  width: 900px
  textarea
    width: 634px
button
  background: white
  color: #333
  font-size: 16px
  border: 1px solid #333
  // border-radius: 6px
  padding: 0.25em 1.0em
  margin: 0.35em 0 0.25em 0
  cursor: pointer
label
  font-size: 14px
input
  width: 30px
  margin-right: 5px
.select-group 
  margin-top: 10px
  .select-wrapper
    display: inline-block
    text-align: center
  select
    background-color: white
    background-size: 5px 17px
    width: auto
    height: 30px
    color: #333
    text-align-last: center
    font-size: 14px
    margin: 0 auto
    display: block
    border: 1px solid #333
    border-radius: none
  h5
    font-size: 14px
    margin: 0
    padding: 0
    line-height: 1.2em
              
            
!

JS

              
                /** 
 * Probably a little overkill on the options and variables but had to set this up 
 * to run in an Electron app with a bunch of user controls.
**/

console.clear();
var textArea = $("#content"),
    foreignObj = document.getElementById('fo-ff'),
    tl = new TimelineMax();

function followedPhrase() {
  
  var S = {
    content: textArea.val(),
    fontColor: 'white',
    fontSize: 64,
    streamColors: ['#f22e06','#f84e13','#fc984c','#f7dc75'],
    staggerDelay: $('#stagger-delay').val() == "" ? 0.1 : parseFloat($('#stagger-delay').val()),
    inSpeed: $('#in-speed').val() == "" ? 0.75 : parseFloat($('#in-speed').val()),
    inEase: $('#ff-in-ease').val(),
    outSpeed: $('#out-speed').val() == "" ? 0.75 : parseFloat($('#out-speed').val()),
    outEase: $('#ff-out-ease').val(),
    dir: $('select#ff-direction').val(),
    duration: $('#duration').val() == "" ? 4 : parseFloat($('#duration').val()),
    inScale: $('select#ff-in-scale').val(),
    outScale: $('select#ff-out-scale').val()
  }
  
  // will contain elements to be animated as an array in GSAP stagger animations
  var copies = [],
      blurFilters = [],
      offsetFilters = [];
  
  // create the main container which will be a flex container
  // probably not gonna look right in FireFox but my Electron app only uses Chromium. 
  // Might need to add position parameters like top: 0, left: 0 to the .copy-box & .msg-box elements
  var container = document.createElement('div');
  container.className = 'container';
  container.id = 'ff-container';
  foreignObj.appendChild(container);
  
  var stageWd = 900,
      stageHt = 320,
      outX, outY;
  
  // create the main phrase that won't have blur filter applied - will sit on top of its copies
  var msg = document.createElement('div');
  msg.className = "msg-box bungee";
  msg.innerHTML = S.content;
  msg.style.color = S.fontColor;
  msg.style.fontSize = S.fontSize+'px';
  msg.style.zIndex = 10;
  container.append(msg);
  
  var WD = $(msg).width(), 
      HT = $(msg).height(), 
      inX, outX, inY, outY, inD, outD, offIn, offOut, scaleIn, scaleOut;
  
  // determine the scale animation settings in case one was set in either of the scaling select menus
  switch( S.inScale ) {
    case "up":
      scaleIn = {from: 0, to: 1};
    break;
    case "down":
      scaleIn = {from: 20, to: 1};
    break;
    case "none":
      scaleIn = {from: 1, to: 1};
    break;
  }
  switch( S.outScale ) {
    case "up":
      scaleOut = {from: 1, to: 20};
    break;
    case "down":
      scaleOut = {from: 1, to: 0};
    break;
    case "none":
      scaleOut = {from: 1, to: 1};
    break;
  }
  
  // determine the in and out settings based on setting from the Animation direction select menu
  switch(S.dir) {
    case 'tb':
      // these are for the elements themselves
      inX = 0;
      outX = 0;
      inY = ((stageHt/2)+(HT))*-1;
      outY = (stageHt/2)+HT;
      // these are for the blur filter and offset filter stagger animations
      inD = {from: '20,150', to: '0,0'};
      outD = {from: '0,10', to: '10,150'};
      offIn = {dx: {from: '0', to: '0'}, dy: {from: '-150', to: '0'}};
      offOut = {dx: {from: '0', to: '0'}, dy: {from: '0', to: '-150'}};
    break;
    case 'bt':
      inX = 0;
      outX = 0;
      inY = (stageHt/2)+HT;
      outY = ((stageHt/2)+(HT))*-1;
      inD = {from: '20,150', to: '0,0'};
      outD = {from: '0,10', to: '10,150'};
      offIn = {dx: {from: '0', to: '0'}, dy: {from: '150', to: '0'}};
      offOut = {dx: {from: '0', to: '0'}, dy: {from: '0', to: '150'}};
    break;
    case 'lr':
      inX = ((stageWd/2)+(WD))*-1,
      outX = (stageWd/2)+WD;
      inY = 0;
      outY = 0;
      inD = {from: '150,30', to: '0,0'};
      outD = {from: '10,0', to: '150,10'};
      offIn = {dx: {from: '-100', to: '0'}, dy: {from: '0', to: '0'}};
      offOut = {dx: {from: '0', to: '-100'}, dy: {from: '0', to: '0'}};
    break;
    case 'rl':
      inX = (stageWd/2)+WD;
      outX = ((stageWd/2)+(WD))*-1;
      inY = 0;
      outY = 0;
      inD = {from: '150,30', to: '0,0'};
      outD = {from: '10,0', to: '150,10'};
      offIn = {dx: {from: '100', to: '0'}, dy: {from: '0', to: '0'}};
      offOut = {dx: {from: '0', to: '100'}, dy: {from: '0', to: '0'}};
    break;
    case 'appear':
      inX = 0;
      outX = 0;
      inY = 0;
      outY = 0;
      inD = {from: '150,30', to: '0,0'};
      outD = {from: '10,0', to: '150,10'};
      offIn = {dx: {from: '100', to: '0'}, dy: {from: '0', to: '0'}};
      offOut = {dx: {from: '0', to: '100'}, dy: {from: '0', to: '0'}};
    break;
  }
  
  // set the initial position of the main element
  tl.set(msg,{autoAlpha: 0, x: inX, y: inY},0);

  // loop through the number of colors and create copies of the main element and blur filters for each
  for( var i = 0; i < S.streamColors.length; i++ ) {
    var color = S.streamColors[i];
    var copy = document.createElement('div');
    copy.setAttribute('id',`copy-${i}`);
    copy.style.color = color;
    copy.style.fontSize = S.fontSize+'px';
    copy.className = `copy-box bungee motion-blur${i}`;
    copy.innerHTML = S.content;
    container.appendChild(copy);
    tl.set(copy,{autoAlpha: 0, x: inX, y: inY},0);
    copies.push(copy);
    var filterObj = motionFilter(`ffBlur${i}`,foreignObj);
    blurFilters.push(filterObj.blur);
    offsetFilters.push(filterObj.offset);
  } 
  
  // put the main element and the copies together in one array
  var temp = [msg];
  var all = temp.concat(copies);
  
  // create the animations
  tl.staggerFromTo(blurFilters,S.inSpeed,{attr:{stdDeviation: inD.from}},{attr:{stdDeviation: inD.to, ease: S.inEase}}, S.staggerDelay, 0)
    .staggerFromTo(offsetFilters,S.inSpeed,{attr:{dx: offIn.dx.from, dy: offIn.dy.from}},{attr:{dx: offIn.dx.to, dy: offIn.dy.to, ease: S.inEase}},S.staggerDelay,0)
    .staggerFromTo(all,S.inSpeed,{scale: scaleIn.from},{scale: scaleIn.to, ease: S.inEase}, S.staggerDelay, 0)
    .staggerTo(all,S.inSpeed,{autoAlpha: 1, x: 0, y: 0, ease: S.inEase}, S.staggerDelay, 0);
  
  tl.staggerFromTo(all,S.outSpeed,{scale: scaleOut.from},{scale: scaleOut.to, ease: S.outEase}, S.staggerDelay, S.duration)
    .staggerTo(all,S.outSpeed,{autoAlpha: 0, x: outX, y: outY, ease: S.outEase}, S.staggerDelay, S.duration)
    .staggerFromTo(offsetFilters,S.outSpeed,{attr:{dx: offOut.dx.from, dy: offOut.dy.from}},{attr:{dx: offOut.dx.to, dy: offOut.dy.to, ease: S.outEase}}, S.staggerDelay, S.duration)
    .staggerFromTo(blurFilters,S.outSpeed,{attr:{stdDeviation: outD.from}},{attr:{stdDeviation: outD.to, ease: S.outEase}}, S.staggerDelay, S.duration);
}

followedPhrase();

// creates a filter element with an feGaussianBlur and feOffSet filter for each word
function motionFilter(id,fo) {
  var filter = document.createElementNS("http://www.w3.org/2000/svg", "filter");
  filter.setAttribute('id',id);
  filter.setAttribute('filterUnits','userSpaceOnUse');
  var blur = document.createElementNS("http://www.w3.org/2000/svg", "feGaussianBlur");
  blur.setAttribute('in','SourceGraphic');
  blur.setAttribute('stdDeviation','0,0');
  var offset = document.createElementNS("http://www.w3.org/2000/svg", "feOffset");
  offset.setAttribute('dx','0');
  offset.setAttribute('dy','0');
  filter.appendChild(blur);
  filter.appendChild(offset);
  fo.appendChild(filter);
  // return the blur and offset filter objects to be added to the arrays used in the stagger animations
  return {blur: blur, offset: offset};
}


// control button listeners
$('#play').on("click", function(){
  tl.seek(0).play();
  $('#pause').text("PAUSE");
});

$('#reset').on("click", function(){
  tl.seek(0).pause();
});

$('#process').on("click", function(){
  tl.seek(0).clear();
  foreignObj.innerHTML = "";
  followedPhrase();
});

$('#pause').on("click", function(){
  if(tl.paused()) {
    tl.play();
    $(this).text("PAUSE");
  } else {
    tl.pause();
    $(this).text("UNPAUSE");
  }
});
              
            
!
999px

Console