Skip to main content

Fullpage Scroll

Combine the moveType: "strict", bound, and align options to build a fullpage scroll UI.

import Flicking from "@egjs/flicking";
import "@egjs/flicking/dist/flicking.css";
import "./styles.css";

const PAGES = [
  { title: "Page 1", subtitle: "Welcome", color: "#e74c3c" },
  { title: "Page 2", subtitle: "Features", color: "#3498db" },
  { title: "Page 3", subtitle: "Pricing", color: "#2ecc71" },
  { title: "Page 4", subtitle: "Contact", color: "#f39c12" },
  { title: "Page 5", subtitle: "About", color: "#9b59b6" }
];

const camera = document.querySelector(".flicking-camera");
PAGES.forEach(page => {
  const panel = document.createElement("div");
  panel.className = "page-panel";
  panel.style.background = page.color;
  panel.innerHTML = `<span>${page.title}</span><span class="page-subtitle">${page.subtitle}</span>`;
  camera.appendChild(panel);
});

const viewport = document.getElementById("flick");
const btnVertical = document.getElementById("btn-vertical");
const btnHorizontal = document.getElementById("btn-horizontal");

let flicking = new Flicking("#flick", {
  horizontal: false,
  moveType: "strict",
  bound: true,
  align: "prev"
});

btnVertical.addEventListener("click", () => {
  flicking.destroy();
  viewport.classList.add("vertical");
  btnVertical.classList.add("active");
  btnHorizontal.classList.remove("active");
  flicking = new Flicking("#flick", {
    horizontal: false,
    moveType: "strict",
    bound: true,
    align: "prev"
  });
});

btnHorizontal.addEventListener("click", () => {
  flicking.destroy();
  viewport.classList.remove("vertical");
  btnHorizontal.classList.add("active");
  btnVertical.classList.remove("active");
  flicking = new Flicking("#flick", {
    horizontal: true,
    moveType: "strict",
    bound: true,
    align: "prev"
  });
});

Summary

Key Options

OptionTypeValueRole
moveTypestring"strict"Move only one page at a time
boundbooleantruePrevent empty space at both ends
alignstring"prev"Align pages to the viewport start
horizontalbooleanfalseVertical scrolling

Direction Comparison

DirectionhorizontalResultRequired Setting
Vertical (Fullpage)falseSwipe up/downHeight must be set on viewport
Horizontal (Slider)trueSwipe left/rightDefault behavior

Details

Role of moveType: "strict"

moveType: "strict" ensures that no matter how hard you swipe, only exactly one panel (one page) moves at a time. This is the key to fullpage scroll — "snap" (the default) can skip multiple panels depending on swipe strength, making it unsuitable for fullpage.

Vertical Direction Setup

Setting horizontal: false enables vertical scrolling. In this case, you must specify a height (height) on the viewport element. Use 100vh for fullscreen, or a fixed height for a specific area.

  • moveType is the key: Only "strict" guarantees exactly 1-page movement
  • Combination with bound: Prevents empty space from showing on the last page
  • Combination with align: "prev": Aligns each page flush with the viewport start

Use Cases

When should you use this?
  • Landing pages: Fullpage transitions between sections
  • Presentation views: Slide navigation
  • Mobile app onboarding: Step-by-step introduction screens

Notes

Caution
  • For vertical direction (horizontal: false), height must be set on the viewport. Without it, the height becomes 0 and nothing will be visible.
  • Vertical scrolling may conflict with the browser's default scroll. Using preventDefaultOnDrag: true together resolves this.