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="container" class=" w-96 h-screen flex items-end border-2 border-red-500">
    <!-- Text -->
    <div id="insights-shipping-text" class="border-2 border-blue-500 text-2xl">
      <p class="border border-green-500">
        Okay...Unboxing your biz… this is a testing text to make the paragraph larger</p>
      <br>
      <br>
      <p class="border border-green-500">
        Hm mm...hm mm...oh!...interesting...I see...
      </p>
      <br>
      <br>
      <p class="flex">
          <button class="btn">Yup</button>
          <button class="btn ml-6">No. Tell me.</button>
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        Okay...Let’s talk shipping…
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        The _____ industry offers an average of ___ shipping options at checkout.
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        _(Company Name)____ offers ___
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        We know variety is the spice of logistics…
        But it is possible to offer too many options.
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        Remember...less is more…
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        Unless it’s less than 2 shipping options…
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        and those options aren’t speedy enough...
      </p>
      <br>
      <br>
      <p class="border border-green-500">
        Then less is less.
      </p>

    </div>
</div>
              
            
!

CSS

              
                .btn{
     border: 1px solid black;
  padding: 8px 12px;

}
              
            
!

JS

              
                gsap.registerPlugin(SplitText);

let textContainer = $('#insights-shipping-text')
let textContainerHeight = textContainer.height()
let containerHeight = $('#container').height()
let dynamicText = gsap.utils.toArray("#insights-shipping-text p");

let main_tl = gsap.timeline();
let tl = gsap.timeline();
let initialPercentage = 100
gsap.set(textContainer, { y: textContainerHeight - $(dynamicText[0]).height()  });
let newValue = textContainerHeight - $(dynamicText[0]).height()

dynamicText.forEach((paragraph, i) => {
  
  let $this = $(paragraph)
  let $nextSibling = $(dynamicText[i + 1])
  
  let bottom = $this.offset().top + $this.height()
  let nextSiblingBottom = $nextSibling.length 
  ? $nextSibling.offset().top + $nextSibling.height()
  : null
  
  let subs = nextSiblingBottom - bottom
  
  let mySplitText = new SplitText(paragraph, { type: "words,chars" })
  let chars = mySplitText.chars
  
  tl.from(chars, {
    opacity: 0,
    duration: 0.01,
    ease: "power2",
    stagger: 0.05,
    onStart: (index) => {
      console.log(i);
      console.log('index', index)
    },
    onComplete: () => {
      newValue = newValue - subs
      if($nextSibling.length){
        gsap.to(textContainer, {y: newValue })
      }
      
    }
  })
  
});

              
            
!
999px

Console