JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hopscotch/0.3.1/css/hopscotch.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/hopscotch/0.3.1/js/hopscotch.js"></script>
<div id="header">
My First Hopscotch Tour</div>
<div id="content">
<p>Content goes here...</p>
</div>
CSS
#header {
width: 100px;
height: 100px;
border: 1px dashed;
font-size: 2em;
}
#content {
width: 100px;
height: 100px;
border: 1px dashed green;
margin-top: 100px;
}
JavaScript
setTimeout(function() {
// Start the tour!
hopscotch.startTour(tour1);
}, 500)
// Define the tour!
var tour1 = {
id: "hello-hopscotch",
steps: [{
title: "Tour 1 s1",
content: "content",
target: "header",
placement: "right",
},
{
title: "Tour 1 s2",
content: "content",
target: document.querySelector("#content p"),
placement: "bottom"
}
],
onEnd: onTour1End_working
};
var tour2 = {
id: "hello-hopscotch",
steps: [{
title: "Tour 2 s1",
content: "content",
target: "header",
placement: "right",
},
{
title: "Tour 2 s2",
content: "content",
target: document.querySelector("#content p"),
placement: "bottom"
}
]
};
function onTour1End_working() {
setTimeout(hopscotch.startTour.bind(hopscotch, tour2), 0);
}
function onTour1End_not_working() {
hopscotch.startTour(tour2);
}