How to use the swup/lib/Link function in swup

To help you get started, we’ve selected a few swup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swup / swupjs / src / modules / renderPage.js View on Github external
module.exports = function (page, popstate) {
    document.documentElement.classList.remove('is-leaving')

    // replace state in case the url was redirected
    let link = new Link()
    link.setPath(page.responseURL)

    if (window.location.pathname !== link.getPath()) {
        window.history.replaceState({
                url: link.getPath(),
                random: Math.random(),
                source: "swup",
            },
            document.title,
            link.getPath(),
        );
    }

    if (!popstate || this.options.animateHistoryBrowsing) {
        document.documentElement.classList.add('is-rendering')
    }

swup

Versatile and extensible page transition library for server-rendered websites

MIT
Latest version published 3 months ago

Package Health Score

82 / 100
Full package analysis

Popular swup functions