css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <article class="content">
  <header>
    <h1>Lorem ipsum</h1>
    <p><a href="#" id="rss">RSS feed</a></p>
  </header>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
  <footer><p><button id="action">A button here</button></p></footer>
</article>

<div class="overlay">
  <div id="banner">
    <h1>Hola</h1>
    <h2>Click anywhere to continue</h2>
  </div>
  <div id="indication">
    <span class="message">Lorem ipsum</span>
   <svg class="arrow" width="50" height="20">
     <rect x="0" y="5" width="30" height="10" />
     <polygon points="30 0, 50 10, 30 20"/>
    </svg>
    </div>
</div>
            
          
!
            
              .content {
  max-width: 600px;
  margin: 0 auto;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
}

#indication {
  position: absolute;
  display: none;
}

#banner {
  position: absolute;
  display: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(255, 255, 255, 0.8);
  padding: 1em;
}

.message { 
  margin: 0 0.5em;
}

.flipped {
  transform: scaleX(-1); 
}

            
          
!
            
              const TOUR = [
  { msg: 'Begin of tour'},
  { msg: 'Subscribe here to our RSS feed', selector: '#rss'}, 
  { msg: 'Dolors sit amet', selector: '#action'},
  { msg: 'Have fun!'}
];

const sign = document.querySelector('#indication');
const textBanner = document.querySelector('#banner');
const overlay = document.querySelector('.overlay');
var content = document.querySelector('.content');

playTour(TOUR);

function playTour(tour) {
  overlay.style.display = 'block';

  let currentStep = 0;
  showNext(TOUR[currentStep]);
  
  let clickHandler = function () {
    currentStep++;

    if (currentStep >= tour.length) { // end
      overlay.removeEventListener('click', clickHandler);
      overlay.style.display = 'none';
      unclip();
    }
    else {
      showNext(TOUR[currentStep]);
    }
  }
  
  let click = overlay.addEventListener('click', clickHandler);
}

function showNext(step) {
  if (step.selector) { // element an arrow must point to
    textBanner.style.display = 'none';
    sign.style.display = 'flex';
    pointMessage(sign, step.msg, document.querySelector(step.selector));
    clipElement(document.querySelector(step.selector));
  }
  else {
    textBanner.querySelector('h1').innerHTML = step.msg;
    textBanner.style.display = 'block';
    sign.style.display = 'none';
    unclip();
  }
}

function clipElement(el) {
  let containerBounds = content.getBoundingClientRect();
  let elBounds = el.getBoundingClientRect();
  
  let clip = {
    top: elBounds.top - containerBounds.top,
    left: elBounds.left - containerBounds.left,
    right: containerBounds.left + containerBounds.width - (elBounds.left + elBounds.width),
    bottom: containerBounds.top + containerBounds.height - (elBounds.top + elBounds.height)
  };
  
  let inset = `inset(${clip.top}px ${clip.right}px ${clip.bottom}px ${clip.left}px)`;
  content.style['-webkit-clip-path'] = inset;
  content.style['clip-path'] = inset;
}

function unclip() {
  content.style['-webkit-clip-path'] = 'none';
  content.style['clip-path'] = 'none';
}

function pointMessage(sign, msg, el) {
  const PADDING = 5;  
  let signBox = sign.getBoundingClientRect();
  
  sign.style.left = `${el.offsetLeft - signBox.width - PADDING}px`;
  sign.style.top = `${el.offsetTop - signBox.height / 2 + el.getBoundingClientRect().height / 2}px`;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console