top of page

How to create an infinite menu scroll

PROJECTS USED

Start Now
Start Now
Start Now
Start Now

TAGS

SUITABLE FOR

Editor X

ABOUT

Never want the scrolling to stop? Learn how to add an infinite scroll effect to your menus.

Layout

01. Add a title and adjust the style
02. Add a hamburger menu
03. Design the menu container
04. Add a repeater
05. Design the repeater’s items

Layout

Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

Database

01. Add a collection to the site
02. Add "title" and "URL" fields
03. Add content in the fields

Database

Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

Velo

01. Turn on Dev Mode
02. Open the "masterPage.js" file
03. Paste all the code
04. Change “START_LOADING_NEXT” to the number of items in the menu
05. Change the element's IDs

Velo
import wixData from 'wix-data';
import wixLocation from 'wix-location';
const START_LOADING_NEXT = 4;
let menuPages = [];

$w.onReady(function () {
    $w('#menuRepeater').rendered && initSideMenu();
});

async function initSideMenu() {
    $w('#menuRepeater').data = [];
    $w('#menuRepeater').onItemReady(($item, itemData, index) => {
        $item('#menuItemText').text = itemData.title;
        $item('#menuItem').onViewportEnter(() => {
            if (index > 1 && index % START_LOADING_NEXT === 0) {
                concatItems();
            }
        });
    });
    $w('#menuItem').onClick((event) => {
        const itemId = event.context.itemId;
        let item = $w('#menuRepeater').data.find(item => item._id === itemId);
        wixLocation.to(item.link);
    });
    setMenuPages();
}

async function setMenuPages() {
    const query = await wixData.query('MenuPages').find();
    const pages = query.items;
    const menuItems = pages.map(item => {
        item._id = `${item._id}`;
        return item;
    });
    $w('#menuRepeater').data = menuItems;
    for (let i = 0; i < menuItems.length; i++) {
        menuPages[i] = { title: menuItems[i].title, link: menuItems[i].link }
    }
    concatItems();
}

function concatItems() {
    let menuRepeater = $w('#menuRepeater');
    let newItems = menuPages.map(item => {
        return { ...item, _id: Math.random().toString().replace('.', '') }
    });
    menuRepeater.data = menuRepeater.data.concat(newItems);
}

HAVING TROUBLE?

Contact our VIP support channel at vip@support.wix.com and our team will contact you within 24 hours.

MORE HOW TO'S

How to move elements to random positions

How to use the Blog API

How to create dynamic lightboxes

How to create hover interactions

How to create a floating image effect

How to create image hover interactions in a list

bottom of page