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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                .digits
  - let i = 0
  while i < 10
    .digit=i
    - i++
              
            
!

CSS

              
                *
  box-sizing border-box
  
body
  display grid
  place-items center
  min-height 100vh
  
.digits
  height 20vmin
  width 20vmin
  border 2px solid black
  position relative
  overflow hidden
  border-radius 5%
  
  
.digit
  height 100%
  width 100%
  position absolute
  background hsla(120, 80%, 50%, 0.5)
  bottom 100%
  display flex
  align-items center
  justify-content center
  font-size 10vmin
  font-weight bold
              
            
!

JS

              
                import gsap from 'https://cdn.skypack.dev/gsap'

gsap.defaults({
  ease: 'none'
})

const TL = gsap.timeline({
  paused: true,
})

const DIGITS = gsap.utils.toArray('.digit')

const PADDED_DIGITS = [...DIGITS, ...DIGITS, ...DIGITS]

for (let i = 0; i < PADDED_DIGITS.length; i++) {
  const DIGIT = PADDED_DIGITS[i]
  const DIGI_TIMELINE = gsap.timeline({
    paused: false,
    onComplete: () => gsap.set(DIGIT, { clearProps: true })
  })
  DIGI_TIMELINE
    .set(DIGIT, {
      yPercent: 0,
    })
      .to(DIGIT, {
      yPercent: 100,
      delay: i,
      duration: 1
    })
      .to(DIGIT, {
      yPercent: 200,
      duration: 1
    })
  TL.add(DIGI_TIMELINE, '- 0.5')
}

const SPEED = 6

const MANIPULATOR = gsap.timeline({
  delay: 0,
  paused: true,
})
  .fromTo(TL, {
    totalTime: 11,
  }, {
    totalTime: 21,
    duration: SPEED,
    ease: 'none',
    repeat: -1,
  })

MANIPULATOR.progress(1).progress(0);

// const SCRUB = gsap.to(MANIPULATOR, {
//   totalTime: 0,
//   duration: 0,
//   paused: true,
//   ease: 'none'
// })


// const START = 10
// SCRUB.vars.totalTime = (SPEED / DIGITS.length) * START
// SCRUB.invalidate().restart()

gsap.delayedCall(2, () => MANIPULATOR.play())


// let COUNT = 0
// document.body.addEventListener('click', () => {
//   COUNT++
//   gsap.to(MANIPULATOR, {
//     totalTime: (SPEED / DIGITS.length) * (START + COUNT),
//     duration: 1,
//   })
// })
              
            
!
999px

Console