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

              
                .l-wrapper
  a.anchor.js-hover(href="")
    .button 
      .button-bg
        .bg1
        .bg2
      .button-text VIEW DETAILS
    .text
      .text-ele.text-above
        span.letter S
        span.letter U
        span.letter P
        span.letter E
        span.letter R
      .text-ele.text-below 
        span.letter M
        span.letter T
        span.letter .
        span.letter F
        span.letter U
        span.letter J
        span.letter I
    .img
      img(src='https://assets.codepen.io/256691/mtfuji.jpg')
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Yaldevi:wght@400;500;600&display=swap');
// font-family: 'EB Garamond', serif;
// font-family: 'Yaldevi', sans-serif;

body {
  font-size: 10px;
}

.tp-dfwv {
  position: fixed;
}

.l-wrapper {
  width: 700px;
  margin: 100px auto;
}

.anchor {
  position: relative;
  display: flex;
  justify-content: center;
}

.button {
  z-index: 3;
  position: absolute;
  top: 50%;
  right: 36%;
  margin-top: -177px;
  margin-right: -100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Yaldevi', sans-serif;
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  width: 200px;
  height: 200px;
  border-radius: 100%;
  color: #fff;
  background-color: #f2baba;
  text-decoration: none;
  
  &-text {
    z-index: 2;
  }
  
  &-bg {
    z-index: 1;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    .bg1,
    .bg2 {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(0);
      width: 100%;
      height: 100%;
      border-radius: 100%;
      content: "";
    }
    
    .bg1 {
      z-index: 1;
      background-color: #e88787;
    }
    
    .bg2 {
      z-index: 2;
      background-color: #d83131;
    }
  }
}

.text {
  z-index: 2;
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  font-family: 'EB Garamond', serif;
  font-size: 10rem;
  text-align: center;
  width: 100%;
  color: #d62828;
  mix-blend-mode: color-burn;
  
  &-ele {
    transform-style: preserve-3d;
    perspective: 1000px;
  }
  
  &-above {
    transform: translateX(-243px);
  }
  
  &-below {
    transform: translateX(185px);
  }
  
  .letter {
    display: inline-block;
    will-change: transform;
    backface-visibility: hidden;
  }
}

.img {
  position: relative;
  z-index: 1;
  width: 100%;
  overflow: hidden;
  
  img {
    width: 100%;
    height: auto;
  }
}
              
            
!

JS

              
                // based on an effect from this site.
// https://hobokenyogi.com/

console.clear()

import {Pane} from "https://cdn.skypack.dev/tweakpane@3.0.5";
import * as EssentialsPlugin from "https://cdn.skypack.dev/@tweakpane/plugin-essentials@0.1.2"


/**
* set tweakpane
*/
const PARAMS = {
  duration: 0.55,
  cubicBezier: true,
  ease: 'Power2.easeOut'
};

const pane = new Pane()
pane.registerPlugin(EssentialsPlugin)

pane.addInput(PARAMS, 'duration', {
  min: 0.1, max: 3.0,
})

pane.addInput(PARAMS, 'cubicBezier')
const cubicBezier = pane.addBlade({
  view: 'cubicbezier',
  value: [0.2, 1.0, 0.25, 1.0],

  expanded: true,
  label: 'cubicBezier',
  picker: 'inline',
})

let ceVal = CustomEase.create("CustomEase", 
      cubicBezier.value.comps_[0] + ',' +
      cubicBezier.value.comps_[1] + ',' +
      cubicBezier.value.comps_[2] + ',' +
      cubicBezier.value.comps_[3] + ','
    )

pane.addInput(PARAMS, 'ease', {
  options: {
    'Strong.easeInOut': 'Strong.easeInOut',
    'Linear.easeNone': 'Linear.easeNone',
    'Power0.easeIn': 'Power0.easeIn',
    'Power1.easeIn': 'Power1.easeIn',
    'Power2.easeIn': 'Power2.easeIn',
    'Power3.easeIn': 'Power3.easeIn',
    'Power4.easeIn': 'Power4.easeIn',
    'Quad.easeIn': 'Quad.easeIn',
    'Cubic.easeIn': 'Cubic.easeIn',
    'Quart.easeIn': 'Quart.easeIn',
    'Quint.easeIn': 'Quint.easeIn',
    'Elastic.easeIn': 'Elastic.easeIn',
    'Back.easeIn': 'Back.easeIn',
    'Bounce.easeIn': 'Bounce.easeIn',
    'SlowMo.easeIn': 'SlowMo.easeIn',
    'SteppedEase.easeIn': 'SteppedEase.easeOut',
    'Circ.easeIn': 'Circ.easeIn',
    'Expo.easeIn': 'Expo.easeIn',
    'Sine.easeIn': 'Sine.easeIn',
    'Power0.easeOut': 'Power0.easeOut',
    'Power1.easeOut': 'Power1.easeOut',
    'Power2.easeOut': 'Power2.easeOut',
    'Power3.easeOut': 'Power3.easeOut',
    'Power4.easeOut': 'Power4.easeOut',
    'Quad.easeOut': 'Quad.easeOut',
    'Cubic.easeOut': 'Cubic.easeOut',
    'Quart.easeOut': 'Quart.easeOut',
    'Quint.easeOut': 'Quint.easeOut',
    'Elastic.easeOut': 'Elastic.easeOut',
    'Back.easeOut': 'Back.easeOut',
    'Bounce.easeOut': 'Bounce.easeOut',
    'SlowMo.easeOut': 'SlowMo.easeOut',
    'SteppedEase.easeOut': 'SteppedEase.easeOut',
    'Circ.easeOut': 'Circ.easeOut',
    'Expo.easeOut': 'Expo.easeOut',
    'Sine.easeOut': 'Sine.easeOut',
    'Power0.easeInOut': 'Power0.easeInOut',
    'Power1.easeInOut': 'Power1.easeInOut',
    'Power2.easeInOut': 'Power2.easeInOut',
    'Power3.easeInOut': 'Power3.easeInOut',
    'Power4.easeInOut': 'Power4.easeInOut',
    'Quad.easeInOut': 'Quad.easeInOut',
    'Cubic.easeInOut': 'Cubic.easeInOut',
    'Quart.easeInOut': 'Quart.easeInOut',
    'Quint.easeInOut': 'Quint.easeInOut',
    'Elastic.easeInOut': 'Elastic.easeInOut',
    'Back.easeInOut': 'Back.easeInOut',
    'Bounce.easeInOut': 'Bounce.easeInOut',
    'SlowMo.easeInOut': 'SlowMo.easeInOut',
    'SteppedEase.easeInOut': 'SteppedEase.easeInOut',
    'Circ.easeInOut': 'Circ.easeInOut',
    'Expo.easeInOut': 'Expo.easeInOut',
    'Sine.easeInOut': 'Sine.easeInOut'
  }}
)

const btn = pane.addButton({
  title: 'Change Ease & Dur'
})

/*
* 
*/
const target = document.querySelector('.js-hover')
const button = document.querySelector('.button')
const buttonBg1 = button.querySelector('.button .bg1')
const buttonBg2 = button.querySelector('.button .bg2')
const texts = document.querySelector('.text-ele')
const lettersAbove = document.querySelectorAll('.text-above .letter')
const lettersBelow = document.querySelectorAll('.text-below .letter')
const imgWrapper = document.querySelector('.img')
const img = imgWrapper.querySelector('img')

let tl = new gsap.timeline({ paused: true, reversed: true })
tl.add('anime')
setTimeline()

btn.on('click', reset)

const mouseEnterEventListener = mouseEnter.bind(this)
const mouseLeaveEventListener = mouseLeave.bind(this)
addEventListener()

function addEventListener() {
  target.addEventListener('mouseenter', mouseEnterEventListener)
  target.addEventListener('mouseleave', mouseLeaveEventListener)
}

// function removeEventListener() {
//   target.removeEventListener('mouseenter', mouseEnterEventListener)
//   target.removeEventListener('mouseleave', mouseLeaveEventListener)
// }

function setTimeline() {
  ceVal = CustomEase.create('CustomEase', 
      cubicBezier.value.comps_[0] + ',' +
      cubicBezier.value.comps_[1] + ',' +
      cubicBezier.value.comps_[2] + ',' +
      cubicBezier.value.comps_[3] + ','
    )
  const ease = PARAMS.cubicBezier ? ceVal : PARAMS.ease
  
  tl.to(imgWrapper, {
    duration: PARAMS.duration,
    scale: 0.9,
    ease: ease
  }, 'anime')
  tl.to(img, {
    duration: PARAMS.duration,
    scale: 1.2,
    ease: ease
  }, 'anime')
  const letterOpt = {
    duration: PARAMS.duration*0.8,
    rotateY: 120,
    skewY: 15,
    x: -35,
    y: -35,
    autoAlpha: 0,
    stagger: 0.11,
    ease: ease
  }
  tl.to(lettersAbove, letterOpt, 'anime')
  tl.to(lettersBelow, letterOpt, 'anime')
  tl.to(button, {
    duration: PARAMS.duration,
    top: "50%",
    right: "50%",
    x: "50%",
    y: "-50%",
    marginTop: 0,
    marginRight: 0,
    ease: ease
  }, 'anime')
  tl.to(buttonBg1, {
    duration: PARAMS.duration,
    delay: PARAMS.duration*0.3,
    scale: 1,
    ease: ease
  }, 'anime')
  tl.to(buttonBg2, {
    duration: PARAMS.duration,
    delay: PARAMS.duration*0.5,
    scale: 1,
    ease: ease
  }, 'anime')
}

function mouseEnter() {
  tl.play()
}

function mouseLeave() {
  tl.reverse()
}

function reset() {
  tl.clear()
  setTimeline()
  // gsap.killTweensOf([imgWrapper, img, lettersAbove, lettersBelow, button, buttonBg1, buttonBg2])
  
  // const opt = {
  //   clearProps: 'all'
  // }
  // gsap.set([imgWrapper, img, lettersAbove, lettersBelow, button, buttonBg1, buttonBg2], opt)
}
              
            
!
999px

Console