Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plax + Turbolinks [It worcks] #74

Open
Golgarud opened this issue Jan 19, 2018 · 0 comments
Open

Plax + Turbolinks [It worcks] #74

Golgarud opened this issue Jan 19, 2018 · 0 comments

Comments

@Golgarud
Copy link

Hello,
First of all, thanks so much for this awesome plugin.
(Im really sad about the support ending).

This is not realy an issue but I have try to run plax with Turbolinks.
I cant find any explanation of how to do it.
So I found it myself and I want to post the solution here :3

( function() {
	Turbolinks.start();
	var ready = function()
	{
		console.log( "🦄 TurboLinks Ready -> " + window.location.href + " width: " + $(window).width());
		// PLAX
		if( $('.yourPlaxSelector').length )
		{
			$('.yourPlaxSelector').plaxify();
			$.plax.enable();
		}
	}
	var cache = function()
	{
		console.log( "🦄 TurboLinks CacheLoad" );
		// Allow plax function `inViewport` to worck properly.
		// Without it Plax will only worck on the first call of `ready`.
		$.plax.disable( { "clearLayers": true } );
	}
	// Turbolink tracker
	var change = function()
	{
		console.log( "🦄 TurboLinks Change" );
		window['referer'] = window.location.href;
	}
	ready();
	document.addEventListener("turbolinks:before-cache", cache);
	document.addEventListener("turbolinks:load", ready);
	document.addEventListener("page:change", change);
} )( jQuery );
@Golgarud Golgarud changed the title Plax + Turbolinks [ It worcks] Plax + Turbolinks [It worcks] Jan 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant