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 class="can">
  <svg width="15" height="100vh" fill="none" xmlns="http://www.w3.org/2000/svg">

    <defs>

      <pattern id="droplets" width="15" height="21" viewBox="0 0 181 208" fill="url(#pattern)" patternUnits="userSpaceOnUse">
        <path d="M94 160.7C94 186.65 72.97 207.68 47.02 207.68C21.07 207.68 0.0400085 186.65 0.0400085 160.7C0.0400085 134.75 28.04 116.44 47.02 84C61.82 112 94 134.76 94 160.7Z" fill="#00A3FF" />
        <path d="M181 76.7C181 102.65 159.97 123.68 134.02 123.68C108.07 123.68 87.04 102.65 87.04 76.7C87.04 50.75 115.04 32.44 134.02 0C148.82 28 181 50.76 181 76.7Z" fill="#00A3FF" />
      </pattern>
    </defs>

    <rect width="100%" height="100%" fill="url(#droplets)" />

  </svg>

  <img draggable="true" id="gb03" class="gamebtn" alt="Watering Can" src="https://ga.chi.lu/wp-content/uploads/2021/02/watering-can.png" width="80" height="80">
</div>
<img id="grass" class="grasspng" alt="Grass" src="https://ga.chi.lu/wp-content/uploads/2021/02/grass.png">
</img>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  padding: 0;
  margin: 0;
  height: 100%;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body::-webkit-scrollbar,
html::-webkit-scrollbar {
  display: none;
}

.can {
  position: relative;
}

#gb03 {
  position: absolute;
  top: 0;
  left: 0;
}

#droplets {
  visibility: hidden;
}
svg {
  top: 30px;
  left: -10px;
  position: absolute;
  z-index: -1;
}

.gamebtn {
  z-index: 2;
  width: 50px;
  height: 50px;
  margin-bottom: 5px;
}

.gamebtn:hover {
  cursor: pointer;
  filter: brightness(130%) drop-shadow(0 2px 5px black);
}

#grass {
  position: fixed;
  z-index: 1;
  transition: all 2s;
  transition-timing-function: linear;
}

              
            
!

JS

              
                window.addEventListener("load", function () {
  console.clear();
  gsap.set("#grass", {
    bottom: -40
  });
  CanAnim();
});
function CanAnim() {
  var tl = gsap
    .timeline({
      paused: true
    })
    .to(".gamebtn", {
      scale: 1.5,
      rotate: -25,
      duration: 0.25
    });
  Draggable.create(".can", {
    type: "x,y",
    activeCursor: "grabbing",
    onDragStart() {
      tl.timeScale(1).play();
      gsap.to("#droplets", {
        repeat: -1,
        duration: 0.1,
        autoAlpha: 1,
        ease: "none",
        attr: {
          y: () => "+=" + 21
        }
      });
    },
    onDragEnd(event) {
      var bottom = gsap.getProperty("#grass", "bottom");
      if (bottom != "0") {
        gsap.to("#grass", {
          duration: 0.3,
          bottom: "+=10"
        });
      } else {
        gsap.set("#grass", {
          bottom: 0
        });
      }
      tl.timeScale(2).reverse();
      gsap.killTweensOf("#droplets");
      gsap.set("#droplets", {
        autoAlpha: 0
      });
    }
  });
}

              
            
!
999px

Console