Pen Settings



CSS Base

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

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


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.


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.


const { onMounted, onUnmounted } = Vue;
export default {
      let tl = null;
      // 抓 document 的 高
      const getDocumentHeight = () => {
        const body = document.body;
        const html = document.documentElement;
        return Math.max(
      // 抓卷軸的位置
      const documentTop = () => (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
      const gsapInit = () => {
        tl = gsap.timeline({defaults: { duration: 1 }});".pic1", {"margin-left": 0, "opacity":1});".pic2", {"margin-left": 0, "opacity":1});".pic3", {"margin-top": 0, "opacity":1});".pic4", {"transform": "scale(1)", "opacity":1, ease: Bounce.easeOut});".pic5", {"width": "240px", "opacity":1});".pic6", {"transform":"scaleX(1)", "opacity":1});".pic7", {"margin-left": 0, "opacity":1});".pic8", {"margin-left": 0, "opacity":1});".pic9", {"transform":"scaleY(1)","opacity":1});".pic10", {"margin-top": 0, "opacity":1});".pic11", {"width": "240px", "opacity":1});
      const handleWinScroll = () =>{
          const scrollTop = documentTop();
          const docHeight = getDocumentHeight();
          const winHeight = window.innerHeight;
          const scrollPercent = (scrollTop) / (docHeight - winHeight);
      onMounted(()=> {
          window.addEventListener("scroll", handleWinScroll);
      // 等同於 Vue2 的 destroyed
      onUnmounted(()=> {
          window.removeEventListener("scroll" ,handleWinScroll);
      return {}

  <div id="box">
      <div class="pic pic1"><img src="" alt=""></div>
      <div class="pic pic2"><img src="" alt=""></div>
      <div class="pic pic3"><img src="" alt=""></div>
      <div class="pic pic4"><img src="" alt=""></div>
      <div class="pic pic5"><img src="" alt=""></div>
      <div class="pic pic6"><img src="" alt=""></div>
      <div class="pic pic7"><img src="" alt=""></div>
      <div class="pic pic8"><img src="" alt=""></div>
      <div class="pic pic9"><img src="" alt=""></div>
      <div class="pic pic10"><img src="" alt=""></div>
      <div class="pic pic11"><img src="" alt=""></div>

    padding: 0;
    margin: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    background-color: cadetblue;
    width: 240px;
    height: auto;
    margin: 0 auto;
    padding-top: 250px;
    width: 240px;
    height: auto;
    overflow: hidden;
    background-color: #fff;
    margin-bottom: 20px;
    opacity: 0;
.pic > img{
    display: block;
    width: 240px;
    height: auto;
    margin-left: -100px;
    margin-left: 100px;
    margin-top: 100px;
    transform: scale(0);
    width: 0;
    margin-left: -100px;
    margin-left: 100px;
    margin-top: 100px;
    width: 0;