Methods
visit
Navigate and transition to a URL. Pass an options object to configure the page load.
swup.visit(url);
swup.visit(url);
Send a POST request with form data:
swup.visit(url, { method: 'POST', data: new FormData() });
swup.visit(url, { method: 'POST', data: new FormData() });
Disable animations for this visit:
swup.visit(url, { animate: false });
swup.visit(url, { animate: false });
Set a custom animation name:
swup.visit(url, { animation: 'custom' });
swup.visit(url, { animation: 'custom' });
Replace the current history entry instead of creating a new one:
swup.visit(url, { history: 'replace' });
swup.visit(url, { history: 'replace' });
destroy
Disables swup.
swup.destroy();
swup.destroy();
use/unuse
Enable and disable plugins.
// Enable plugin: accepts an instantiated instance
swup.use(new SwupScrollPlugin());
// Disable plugin: accepts either name or instance
swup.unuse('SwupScrollPlugin');
// Enable plugin: accepts an instantiated instance
swup.use(new SwupScrollPlugin());
// Disable plugin: accepts either name or instance
swup.unuse('SwupScrollPlugin');
findPlugin
Returns the plugin instance by that name, if enabled.
const pluginInstance = swup.findPlugin('SwupScrollPlugin');
const pluginInstance = swup.findPlugin('SwupScrollPlugin');
log
Does nothing by default, but outputs the passed content when the debug plugin is used. Accepts two arguments, the content of message and an optional log object which gets printed in a console group.
swup.log('Something happened', { lorem: 'ipsum' });
swup.log('Something happened', { lorem: 'ipsum' });