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="page">

  <div class="container">
    <div class="carousel">
      <ul class="carousel-pagination">

        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>
        <li class="carousel-bullet"></li>

      </ul>

      <div class="carousel-container">
        <p class="carouselPara">

          This book is here to help you get your job done. In general, if this book includes code examples, you may use the code in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of
          the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this
          book and quoting example code does not require permission. Incorporating a significant amount of ex‐ ample code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution
          usually includes the title, author, publisher, and ISBN. For example: “Developing Backbone.js Applications by Adnan Osmani (O’Reilly). Copyright 2013 Addy Osmani, 978-1-449-32825-2.” If you feel your use of code examples falls outside fair use
          or the permission given above, feel free to contact us at [email protected]. Safari® Books Online Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form
          from the world’s leading authors in technology and business. Technology professionals, software developers, web designers, and business and crea‐ tive professionals use Safari Books Online as their primary resource for research, prob‐ lem solving,
          learning, and certification training. Safari Books Online offers a range of product mixes and pricing programs for organi‐ zations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication
          manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Pro‐ fessional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan
          Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online. </p>
      </div>

    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  background: #FFF;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  overflow-y: scroll;
  overflow-x: hidden;
  min-height: 600px;
}
.page {
  margin-top: 50px;
  width: 700px;
  height: 300px;
}

.container {
  width: 700px;
  height: 100%;
  margin: 0 auto;
  box-shadow: 0 16px 18px -10px rgba(0, 0, 0, 0.5);
  -moz-box-shadow: 0 16px 18px -10px rgba(0, 0, 0, 0.5);
  -webkit-box-shadow: 0 16px 18px -10px rgba(0, 0, 0, 0.5);
  -o-box-shadow: 0 16px 18px -10px rgba(0, 0, 0, 0.5);
  border-radius: 0px 0px 10px 10px;
}

.carousel {
  position: relative;
  overflow: hidden;
  width: 700px;
}

.carousel-pagination {
  list-style: none;
  position: absolute;
  left: 0;
  right: 0;
  width: 700px;
  height: 25px;
  padding: 10px 0px 0px 0px;
  margin: 0 auto;
  text-align: center;
  z-index: 10;
  background-color: #F6F6F6;
}

.carousel-bullet {
  display: inline-flex;
  width: 10px;
  height: 10px;
  background-color: #B7B7B7;
  cursor: pointer;
  border-radius: 50%;
  opacity: 0.5;
  
/*   transition-property: transform, opacity, background-color; */
/*   transition-duration: 0.3s; */
}

/* .carousel-bullet:hover {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
} */

/* .carousel-bullet.active-bullet, .carousel-bullet.active-bullet:hover {
  opacity: 1;
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
  background-color: #324892;
  cursor: default;
} */
.carousel-container {
  background-color: #CCC;
  margin-top: 50px;
  width: 700px;
  height: 300px;
/*   transition: transform 0.3s cubic-bezier(.694, .0482, .335, 1); */
  overflow-y: hidden;
  overflow-x: scroll;
}

p {
  padding: 10px;
  width: 200%;
}

              
            
!

JS

              
                
var container = document.querySelector(".carousel-container");
var bulletElements = document.querySelectorAll(".carousel-bullet");

var scrollArea = container.scrollWidth - container.offsetWidth;
var length = bulletElements.length;
var bullets = [];

var requestId = null;

// Prevent Chrome from rasterizing at scale of 1
// https://greensock.com/will-change
TweenLite.set(bulletElements, {
  force3D: true
});

for (var i = 0; i < length; i++) {
  var bullet = createBullet(bulletElements[i], i);
  bullets.push(bullet);
}

container.addEventListener("scroll", requestScrollUpdate);

updateScroll();

// Throttle scroll events to animation frames
function requestScrollUpdate() {
  if (!requestId) {
    requestId = requestAnimationFrame(updateScroll);
  }
}

function updateScroll() {
  
  var ratio = container.scrollLeft / scrollArea;
  var cursor = Math.floor((length - 1) * ratio);
  
  for (var i = 0; i < length; i++) {
    bullets[i].updateProgress(cursor);
  }  
  
  requestId = null;
}

function createBullet(element, index) {
    
  var animation = new TimelineMax({ paused: true })
    .to(element, 1, { scale: 2, backgroundColor: "pink" })
    .to(element, 1, { scale: 3, backgroundColor: "red" })
  
  var bullet = {
    element: element,
    index: index,
    animation: animation,
    updateProgress: updateProgress
  };
    
  function updateProgress(cursor) {
    
    // Use a small progress value here instead of 0
    // to work around will-change issue in Chrome
    var progress = 0.0001;
    
    if (cursor === index) {
      progress = 1;
    } else if (cursor === index - 1 || cursor === index + 1) {
      progress = 0.5;
    }
    
    if (animation.progress() !== progress) {
      TweenLite.to(animation, 0.25, { progress: progress });
    }   
  }
  
  return bullet;
}
              
            
!
999px

Console