Pen Settings



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


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


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.


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.


                <div class="fixed"><h1>iOS Safari Bug - event.clientY/X incorrect every other scroll</h1>
<div class="log"></div>




                * {
  box-sizing: border-box;
.log {
  font-family: monospace;
  color: white;
h1 {
  color: white;

section {
  height: 100vh;
  background-size: cover;

.fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 15px;
  background-color: rgba(0,0,0,0.3);

body {
  margin: 0;
  padding: 0;


                // seems like it was reported in January 2018 and still isn't fixed in March 2022.

On iOS Safari, touch and drag up quickly (to scroll). Often you'll see a momentary jump/flash.
That's because it reports the touchmove event.clientY INCORRECTLY. Move your finger only up, for
example, and you'll notice that the .clientY decreases very quickly and then jumps back up, almost
like momentum is applied to the values. You can even get negative values, indicating your finger 
is literally way off the screen above the viewport. This only seems to happen when the window gets
scrolled (which shouldn't affect .clientY)

It will sense when the .clientY changes direction and then log the recent values to the screen 
so that you can verify. 

let positions = [],
    startY, scroll;

document.addEventListener("touchstart", e => {
  startY = e.changedTouches[0].clientY;
  scroll = window.pageYOffset;
}, { passive: false });

document.addEventListener("touchmove", e => {
  let y = e.changedTouches[0].clientY,
      l = positions.length;
  window.scrollTo(0, scroll + (startY - y));
  if (((y - positions[l-1]) > 0) !== ((positions[l-1] - positions[l-2]) > 0) && l > 1) {
    log("changed direction! Recent clientY: " + positions.slice(Math.max(0, l-4)).join(", "));
}, { passive: false });

document.addEventListener("touchend", e => positions.length = 0);

function log(message) {
  document.querySelector(".log").innerHTML += message + "<br>";

document.querySelectorAll("section").forEach((el, i) => = `url(${i})`);

// attempted workaround (skip every other "touchmove"):