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

              
                <div id="para1"></div>
<div id="para2"></div>
              
            
!

CSS

              
                
              
            
!

JS

              
                function typeWriterEffect(target, config) {
  const tL = gsap.timeline();
  const endFlashSpeed = 0.3;
  const character = "|";

  tL.to(
    target,
    {
      text: {
        value: config.text
      },
      duration: config.duration,
      ease: "none",
      onUpdate: function () {
        this.targets()[0].textContent += character;
      },
      onComplete: function () {
        this.targets()[0].textContent = config.text;
      }
    },
    "+=0.5"
  )
  //.to(target, endFlashSpeed, {
  //  text: config.text + character,
  //  repeat: -1,
  //  repeatDelay: endFlashSpeed,
  //  ease: "none"
  //});

  return tL;
}

function registerGSAPEffects() {
  gsap.registerEffect({
    name: "typewriter",
    effect: function (targets, config) {
      return typeWriterEffect(targets, config);
    },
    defaults: { duration: 2 }, //defaults
    extendTimeline: true
  });
}

function loadPara1() {
  var messageStr =
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Aliquet lectus proin nibh nisl condimentum id venenatis a.";

  const tL = gsap.timeline();
  tL.typewriter("#para1", {
    text: messageStr,
    duration: 4
  });

  return tL;
}

function loadPara2() {
  var messageStr =
    "Integer eget aliquet nibh praesent tristique magna sit amet purus. Risus sed vulputate odio ut enim blandit volutpat maecenas volutpat. Malesuada bibendum arcu vitae elementum curabitur. ";

  const tL = gsap.timeline();
  tL.typewriter("#para2", { text: messageStr, duration: 4 });

  return tL;
}

registerGSAPEffects();

const masterTL = gsap.timeline();

const tL1 = loadPara1();
const tL2 = loadPara2();

masterTL.add(tL1);
masterTL.add(tL2);

              
            
!
999px

Console