A light-weight user's step-by-step guide for your website using Vanilla JS.

Overview

WebTour JS

A light-weight user's step-by-step guide for your website using Vanilla JS.

Features

  • User's walkthrough - can be used to guide user's to your website using modals and popovers.
  • Slideshow - webtour can be used as slideshow within your website.
  • Highlight element - can highlight specific element on the page without modifying the element position and style.
  • Dynamic element - can target dynamically created element.
  • Auto scroll - scroll automatically to popover's position.
  • Keyboard control - allows control using next, back and esc keys.
  • Update position on resize

How does WebTour highlight works?

WebTour highlight works by adding overlay to the page except for the highlighted element. It is basically an overlay with a hole showing the element that is highlighted. WebTour can highlight even on modals.

Installation

Include the files from dist directory.

<link rel="stylesheet" href="/dist/webtour.min.css">
<script src="/dist/webtour.min.js"></script>

Basic usage and Demo

Highlight an element

const wt = new WebTour();
wt.highlight('#target');

Step-by-step guide

const wt = new WebTour();
const steps = [
    {
        element: '#step_1',            //target element (if not defined then the popover will act like a modal at the center of the screen)
        title: 'Popover title',         //this is option if you don't want to add title
        content: 'Popover content',     //can be string or html string
        placement: 'right-start',       //top, top-start, top-end, left, left-start, left-end, right, right-start, right-end, bottom, bottom-start, bottom-end
    },
    ...
];

wt.setSteps(steps);
wt.start();

Actions

WebTour has onNext and onPrevious actions.

const wt = new WebTour();
const steps = [
    {
        element: '#step_1',           
        title: 'Popover title',        
        content: 'Popover content',     
        placement: 'left-start',     
        onNext: function () {  //or ()=> {}
            //perform actions here
        },
        onPrevious: function () {
            //undo actions here
        }
    },    
    {
        element: '#step_2',           
        title: 'Popover title',        
        content: 'Popover content',     
        placement: 'right-start',     
        onNext: function () { 
            //for dynamic elements - pause and resume onNext action
            wt.isPaused = true;                 //pause tour
            wt.showLoader();                    //display a loader

            //perform actions here
            document.querySelector('#button').click();

            //wait for the dynamic element 
            const isPresent = setInterval(function(){
                const nextTarget = document.querySelector('#step_3');
                if (nextTarget){
                    clearInterval(isPresent);   //important to prevent your tour to not iterate until end
                    wt.moveNext();              //go to next step - equivalent to  wt.isPuased = false; wt.next();
                }
            }, 100)
        },

        //dynamically created target element
         {
            element: '#step_3',           
            title: 'Popover title',        
            content: 'Popover content',     
            placement: 'left-start',    
        },
    },
    ...
];

wt.setSteps(steps);
wt.start();

Options

const wt = new WebTour({
    offset: 20,             //distance from popover to target element
    borderRadius: 3,        //popover border radius
    allowClose: true,       //close on click outside
    highlight: true,        //show overlay
    highlightOffset: 5,     //overlay offset from target element
    keyboard: true,         //enable/disable keyboard controll
    width: '300px',         //specify popover's width
    zIndex: 10050,          //specify z-index 
    removeArrow: false,     //show/hide popover arrow
});

Functions

wt.start(startIndex = 0)    //start the tour
wt.setSteps(steps)          //requires array of step object { element, title, content, placement } - provide one option
wt.render(step);            //requires step object { element, title, content, placement } - provide one option
wt.next();                  //trigger next action
wt.previous();              //trigger previous
wt.moveNext();              //resume tour and move next
wt.movePrevious();          //resume tour and move previous

About

This library is created out of frustration of using existing user's walkthrough library that does not support dynamic element targeting.

TODO:

  • Floating popover positioning (top-center, top-start, top-end, middle-center (default), midle-left, middle-right, bottom-left, bottom-center, bottom-end)
  • Add option to hide buttons
  • Add option close button
  • Add hints
You might also like...

An example of an NFT Gated Website for thirdweb's NFT Gated Website Guide

NFT Gated Website "One of the more dynamic use cases for NFTs is using them as a membership pass to the NFT holders. Let’s assume you want to create a

Jan 3, 2023

A lightweight (the actual ship is heavy though), performat & powerful sharder for Discord.JS. Indomitable uses cluster module to evenly spread her weight (load) across your cores

A lightweight (the actual ship is heavy though), performat & powerful sharder for Discord.JS. Indomitable uses cluster module to evenly spread her weight (load) across your cores

Indomitable A lightweight (the actual ship is heavy though), performat & powerful sharder for Discord.JS. Indomitable uses cluster module to evenly sp

Nov 29, 2022

🌗 1 line of code to apply auto dark / light theme and support custom theme for your website. Super fast and lightweight theme library.

themes.js A super lightweight and fast Theme library with auto system color scheme detection in JavaScript. Features Auto detect Dark / Light mode by

Nov 29, 2022

ToastmeJS is a very simple, flexible and light weigth plugin that shows Notifications and modal Dialogs on your website.

⚡ ToastmeJS ToastmeJS is a very simple, flexible and light weigth plugin that shows Notifications and modal Dialogs on your website. Customize positio

Jun 20, 2022

BMI Calculator can give us the bmi result of our bmi on the basis of our corresponding height and weight.

BMI means body mass index. Body Mass Index (BMI) is a person's weight in kilograms divided by the square of height in meters.

Jan 20, 2022

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Jul 19, 2022

How to implement Step-up Authentication using Amazon Cognito

How to implement Step-up Authentication using Amazon Cognito

How to implement Step-up Authentication using Amazon Cognito This repository contains accompanying source code for the AWS Blog post, How to implement

Dec 15, 2022

A website that acts as a guide about the universities to potential students whole throughout the globe.

A website that acts as a guide about the universities to potential students whole throughout the globe.

Apr 15, 2022
Comments
  • `dynamically created target element` in docs is incorrect

    `dynamically created target element` in docs is incorrect

    Love this package, this is great! I hope it gets more traction than the other solutions there.

    One thing I'm stuck on is in the documentation there's:

            //dynamically created target element
             {
                element: '#step_3',           
                title: 'Popover title',        
                content: 'Popover content',     
                placement: 'left-start',    
            },
    

    We can't nest an unnamed JavaScript object in one of the steps, it looks like it's missing a key name. Any idea what that would be?

    opened by KalobTaulien 2
  • Priviledge for name or any other unique attribute

    Priviledge for name or any other unique attribute

    Is there any other alternative exists like name attribute instead of id attribute. In documentation, tour element is defined as follows:

    {
          element: '#step-1',
          title: 'Example title',
          content: 'Example content.',    
          placement: 'bottom-start'
    }
    

    In element key, whether we can add name attribute instead of id ??

    opened by ishpreetkaurwebner 1
Owner
JM de Leon
JM de Leon
A light-weight, simple, and straightforward learning tool for your Kubernetes cluster

Introducing Neptune Light-weight, simple, and straightforward learning tool for your Kubernetes cluster Neptune is an approachable learning tool, ligh

OSLabs Beta 109 Jan 4, 2023
Light-weight Linked Open Data native cataloguing and crowdsourcing platform

id name brief-description type release-date release-number work-package keywords licence release link demo running-instance credits clef CLEF, Crowdso

Polifonia H2020 10 Apr 26, 2022
A robust and light-weight inventory management application designed to help businesses maintain perfect control over every unit of stock.

Inventory Buddy Access inventory anytime on web, tablet or mobile. Inventory Buddy is a robust and light-weight inventory management application desig

Brynn Smith 7 Nov 5, 2022
🛠️⚡ Step-by-step tutorial to build a modern JavaScript stack.

JavaScript Stack from Scratch Welcome to my modern JavaScript stack tutorial: JavaScript Stack from Scratch. ?? This is the V2 of the tutorial, major

Jonathan Verrecchia 19.5k Jan 4, 2023
Full source-code for the step-by-step tutorial on how to use Phaser + Colyseus together.

Phaser: Real-time Multiplayer with Colyseus Full source-code for the step-by-step tutorial on how to use Phaser + Colyseus together. Live Demo See ste

Colyseus 19 Dec 24, 2022
A simple step by step tooltip helper for any site

Tooltip Sequence A minimalistic set of tooltips on your app. What it does So suppose you create a Web Application and you want to take your users or a

Sooraj Sivadasan Nair 299 Dec 21, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023