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

Listening on body does not work correctly. #63

Open
nextgenthemes opened this issue May 1, 2017 · 0 comments
Open

Listening on body does not work correctly. #63

nextgenthemes opened this issue May 1, 2017 · 0 comments

Comments

@nextgenthemes
Copy link

	$( 'body' ).on( 'inview', '.arve-wrapper[data-arve-inview]', function() {
		$(this).removeAttr('data-arve-inview');
		console.log( $(this) );
		load_video( $(this) );
	});

I have this based on the img example. The console log shows that its triggered for all elements once the very first becomes visible. That should not be.

tried with $( document ) as well but same issue.

I have to do this to actually listen to elements and try to also do it for elements that are added later.

	function arve_inview() {

		$( '[data-arve-inview]' ).one( 'inview', function( event, isInView ) {
			if ( isInView ) {
				load_video( $(this) );
			}
		} );
	}

	arve_inview();

	$( document ).ajaxComplete(function() {
		arve_inview();
	});
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