asplunds / floating-pages

Simple example/template for floating pages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Floating Pages

Hold your pages in place while scrolling, when the next page is up, transition to it. This simple example will always hold one page in the center of the viewport, like a powerpoint presentation.

Credit me if you fork/use it.

Demo

Right here

Api

valid directions (as attribute):

  • p-down
  • p-up
  • p-left
  • p-right
<div class="pages" p-down>
    <div class="page"></div>
    <div class="page"></div>
</div>
const pages = new Pages({
    container: document.querySelector(".pages"),
    scroll: window,
    onPageChange: instance => console.log(instance.index)
});

pages.index // the current page

Tools used

  • Vite.js
  • Vanilla js
  • SASS

About

Simple example/template for floating pages

License:MIT License


Languages

Language:JavaScript 43.4%Language:SCSS 37.1%Language:HTML 16.9%Language:CSS 2.6%