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

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

              
                <canvas id="c"></canvas>
<div id="container">
  <div id="wrapper">
    <p>
      Congue platea sed dignissim elementum tellus magna tincidunt interdum odio.
    </p>
    <p>
      Urna aliquam fusce sed fringilla ad id nec netus diam.
    </p>
    <p>
      Etiam curae; libero vel fusce euismod gravida feugiat molestie habitasse.
    </p>
    <p>
      Nec mus suspendisse potenti nostra senectus non litora accumsan turpis.
    </p>
    <p>
      Faucibus eu laoreet malesuada pellentesque conubia pellentesque orci varius cum.
    </p>
    <p>
      Nisl nascetur condimentum imperdiet habitant inceptos porttitor gravida euismod morbi?
    </p>
    <p>
      Luctus, erat gravida penatibus in pharetra viverra litora fringilla nibh!
    </p>
    <p>
      Euismod mi felis sociis ridiculus netus dapibus tempus class porttitor.
    </p>
    <p>
      Luctus dignissim sed est mauris dolor risus diam, fusce praesent.
    </p>
    <p>
      Maecenas placerat primis sit hac litora nibh diam varius iaculis.
    </p>
  </div>
</div>
              
            
!

CSS

              
                body
  background-color: black
  font-family: "Montserrat", sans-serif
  font-weight: 700
  display: flex
  justify-content: center
  margin: 0
  height: 100vh
  user-select: none
  overflow: hidden

#c
  position: fixed
  top: 0
  left: 0
  display: block
  
#container
  display: block
  position: relative
  width: 50vw
  border-radius: 10px
  padding: 200px 20px
  justify-content: center
  flex-direction: column
  
#wrapper
  position: relative

p
  display: block
  position: relative
  text-align: center
  color: white
  padding: 30px 0
  font-size: 48px
  font-weight: 700
              
            
!

JS

              
                var c = document.getElementById("c");
var ctx = c.getContext('2d');
var h = window.innerHeight;
var w = window.innerWidth;
let mouseXs = w/2;
let mouseYs = h/2;
let arc = {radius: 20, lastX: mouseXs, lastY: mouseYs};

var mouseY = 0;
var followY = 0;
var wh = window.innerHeight;
var ease = 0.08;
var tween = TweenLite.to("#wrapper", 1, { yPercent: -100, paused: true });

TweenLite.set("p", { transformOrigin: "center left" });

// INIZIO SEZIONE MOUSE
c.width = w;
c.height = h;

//FUNZIONI MOUSE
function render() {
  arc.lastX += (mouseXs - arc.lastX)* ease;
  arc.lastY += (mouseYs - arc.lastY)* ease;
  
  ctx.clearRect(0,0,w,h);
  ctx.beginPath();
  ctx.arc(arc.lastX, arc.lastY, arc.radius, 0, 2*Math.PI, false);
  ctx.lineWidth = 2;
  ctx.strokeStyle = 'white';
  ctx.stroke();
  
  ctx.font = "bold 10px Montserrat";
  ctx.fillStyle = "white";
  ctx.textAlign = "center";
  ctx.fillText("HOLD", arc.lastX, arc.lastY + 4); 
  
  requestAnimationFrame(render);
}

function init() {
  requestAnimationFrame(render);

  window.addEventListener('mousemove', function(el) {
    mouseXs = el.pageX;
    mouseYs = el.pageY;
  });
  
  var tween2 = new TweenMax.to(arc, 1.2, {
    radius: arc.radius * 2,
    ease: Expo.easeOut,
    paused: true
  });
  
  window.addEventListener("mousedown", function(){
    myTimeout = setTimeout(down, 1200);
    tween2.play();
  });
  
  function down() {
    window.addEventListener("mouseup", place);
    window.addEventListener("mousemove", Muovi);
  }

  function place() {
    clearTimeout(myTimeout);
    window.removeEventListener("mousemove", Muovi);
    tween2.reverse().timeScale(3);
    if (document.getElementById("wrapper")._gsTransform.yPercent >= -20) {
      console.log("it is less than 20");
      var tweenComplete = TweenLite.to("#wrapper", 1, {yPercent: -20 });
      // tween.progress(.2);
    }
    console.log(tween.progress());
    console.log(document.getElementById("wrapper")._gsTransform.yPercent);
  }

  function Muovi(e) {
    mouseY = e.clientY;
  }
}

init();

TweenLite.ticker.addEventListener("tick", function() {
  followY += (mouseY - followY) * ease;
  if (followY <= 0) {
    followY = 0;
  } else if (followY >= wh) {
    followY = wh;
  }
  tween.progress(followY / wh);
  
  // skew effect
  var dy = (mouseY - followY) / 20;
  dy = Math.min(Math.max(dy, -5), 5);
  TweenLite.set("p", { skewY: dy });  
});
              
            
!
999px

Console