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. 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

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

              
                <!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="base.css">
        <title>Scroll To Accept</title>
</head>
<body>
<h1>Drew Learns how to make <br> A scroll to accept page</h1>
  <div class="wrapper">
    <div class="terms-and-conditions">
      <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Iste, labore!</p>
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum assumenda, ullam, sed quo ipsam officia
        asperiores minima excepturi eveniet reiciendis velit debitis temporibus explicabo. Incidunt sit itaque,
        reprehenderit fuga voluptatem officiis corrupti ipsa eveniet architecto dolorem magni facere doloribus aut
        veritatis sequi quia repellendus aperiam assumenda exercitationem optio praesentium debitis. Excepturi unde
        minus dignissimos at totam tempora beatae cumque, voluptates adipisci repudiandae asperiores repellat delectus
        tempore voluptatem veritatis atque quaerat optio! Quasi, possimus molestiae hic modi quia minus eius veniam
        aperiam assumenda fugiat fugit optio odio quas esse quam architecto officiis sunt quis cupiditate vel
        voluptate
        consequuntur nam porro harum. Fuga distinctio voluptate provident molestias perspiciatis fugit esse corrupti
        adipisci quas eos dolor non cum ipsam repudiandae dolorem, quasi necessitatibus iusto unde similique
        repellendus praesentium tenetur? Obcaecati aliquam nostrum vero expedita fuga, quae et quaerat modi error
        adipisci eligendi fugit alias quia nihil laudantium quam tenetur ipsam explicabo nisi natus, rerum omnis,
        debitis provident! Dolorum sequi recusandae, necessitatibus eos nesciunt cupiditate accusantium illum unde
        minima. Labore sit quos voluptatem illum qui. Veritatis quis a mollitia asperiores repudiandae consequatur
        assumenda, at tempora, modi voluptate sit blanditiis hic dignissimos harum consequuntur quia ipsam, architecto
        nesciunt. Praesentium, mollitia? Delectus quod laudantium doloremque nihil?</p>
      <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quos ab, ea inventore commodi eligendi error
        repellat impedit eum quod enim sequi, distinctio, qui eaque ipsam fugit asperiores eos laboriosam ex.</p>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ipsa id debitis ex eligendi rem unde consequuntur
        natus omnis vel nulla sit commodi, quos distinctio doloremque doloribus veniam quis et dolore?</p>
      <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Commodi laboriosam nulla est architecto eum,
        dolorem
        quam, unde quo fugit tempore ipsa qui provident, iste ratione quis dignissimos temporibus nostrum voluptatum
        molestias? Blanditiis repellendus sapiente inventore aliquam qui error aliquid doloremque fugit consequuntur
        laudantium. Sapiente doloribus ullam vel dicta doloremque iure, deleniti ipsum non. Rem repudiandae deleniti
        ad
        at laborum eaque, modi voluptas aut! Quam nihil deleniti velit excepturi, quidem, veniam aut doloremque iure
        reprehenderit natus vel quia iusto? Magni veritatis provident libero hic quisquam, perferendis officia quasi
        molestiae sit sunt fugiat, perspiciatis architecto velit unde molestias ratione totam, atque doloremque!</p>
      <hr>
    </div>
    <button class="accept" disabled>Accept</button>
  </div>
<script type="text/javascript" src="scroll.js"></script>
</body>
</html>
              
            
!

CSS

              
                
    body {
      min-height: 100vh;
      display: grid;
      justify-content: center;
      align-content: center;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
      line-height: 2;
      background-color: #0072B9;
      background-image: url("data:image/svg+xml,%3Csvg width='20' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 21.184c.13.357.264.72.402 1.088l.661 1.768C4.653 33.64 6 39.647 6 50c0 10.271-1.222 15.362-4.928 24.629-.383.955-.74 1.869-1.072 2.75v6.225c.73-2.51 1.691-5.139 2.928-8.233C6.722 65.888 8 60.562 8 50c0-10.626-1.397-16.855-5.063-26.66l-.662-1.767C1.352 19.098.601 16.913 0 14.85v6.335zm20 0C17.108 13.258 16 8.077 16 0h2c0 5.744.574 9.951 2 14.85v6.334zm0 56.195c-2.966 7.86-4 13.123-4 22.621h2c0-6.842.542-11.386 2-16.396v-6.225zM6 0c0 8.44 1.21 13.718 4.402 22.272l.661 1.768C14.653 33.64 16 39.647 16 50c0 10.271-1.222 15.362-4.928 24.629C7.278 84.112 6 89.438 6 100h2c0-10.271 1.222-15.362 4.928-24.629C16.722 65.888 18 60.562 18 50c0-10.626-1.397-16.855-5.063-26.66l-.662-1.767C9.16 13.223 8 8.163 8 0H6z' fill='%23fff' fill-rule='nonzero' fill-opacity='.1' opacity='.349'/%3E%3C/svg%3E%0A");
    }
    .wrapper {
      width: 400px;
      max-height: 60vh;
      padding: 20px;
      border: 1px solid black;
      background: white;
      display: grid;
      grid-template-rows: 1fr auto;
      border-radius: 5px;
    }
button {
        background: #61e846;
        color: white;
        font-size: 1rem;
        padding: 20px;
        transition: all 0.2s;
        border-radius: 5px;
}
button[disabled] {
        background-color: grey;
        opacity: 0.4;
        /* transform: translateX(-250%) scale(0.5); */
}
.terms-and-conditions {
        overflow: scroll;
}
h1 {
        text-align: center;
        text-transform: capitalize;
}
              
            
!

JS

              
                const terms = document.querySelector('.terms-and-conditions');
const button = document.querySelector('.accept');
function obCallback(payload){
        if (payload[0].intersectionRatio > .9) {
                button.disabled = false;
                ob.unobserve(terms) //clean up
        }else { button.disabled = true;
        }
}
const ob = new IntersectionObserver(obCallback, {
        root: terms, // this is the object it's observing
        threshold: [.9]} // 90% on the page
); //doesn't do anything yet, it's just a watcher you haven't called
ob.observe(terms.lastElementChild); //observing for the HR tag



//*****************************************
//OLD WAY TO DO THIS:
// terms.addEventListener('scroll', function(event){
//         // console.log(event.currentTarget);
//         console.log(event.currentTarget.scrollTop);
//         console.log(event.currentTarget.scrollHeight);
// })

//*****************************************
//IF YOU ARE GOING TO ADD THIS TO AN ENTIRE PROJECT NEST THE ABOVE IN HERE:

// function scrollToAccept (){
//         if(!terms){
//                 console.log('no terms and agreements on this page')
//                 return; //quit this doesn't exist on the page
//         }
// }
              
            
!
999px

Console