Swup isn't working
amineyarman opened this issue · 2 comments
amineyarman commented
Hello hello,
This sounds like a wonderful tool. But for some reason can't figure why this is not working for me. I tried some basic setup as follows :
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div>
<main id="swup">
<h1>This is homepage</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
</p>
<a href="./about.html">Go to other page</a>
</main>
</div>
<div class="loading">We are loading...</div>
<script src="./js/libs/swupjs.js"></script>
<script src="./js/main.js"></script>
</body>
</html>
about.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div>
<main id="swup">
<h1>This is about page</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
</p>
<a href="./index.html">Go to other page</a>
</main>
</div>
<div class="loading">We are loading...</div>
<script src="./js/libs/swupjs.js"></script>
<script src="./js/main.js"></script>
</body>
</html>
main.js
(function() {
var options = {
debugMode: true,
animations: {
'*': {
out: function (next) {
console.log("Out Function")
setTimeout(function () {
console.log("Timeout Out")
next()
},1000)
},
in: function (next) {
console.log("Timeout In")
next()
}
}
}
}
var swupjs = new Swupjs(options)
})();
But nothing happens. Clicking on the links redirects right away. Nothing show up in the console. But the debug mode shows that Swup is enabled. What am I doing wrong?
Aminerman commented
I got it to work. I simply had to replace the
<a href="./whatever"></a>
by
<a href="/whatever"></a>
and run this on a server.
gmrchk commented
You could also set the link selector option to fit your needs.