Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Dynamic offset ? #80

Closed
xavierleune opened this issue Nov 29, 2017 · 2 comments
Closed

Dynamic offset ? #80

xavierleune opened this issue Nov 29, 2017 · 2 comments

Comments

@xavierleune
Copy link

xavierleune commented Nov 29, 2017

Hi @camwiegert

First thing, I want to thank you for creating, releasing and maintaining this library ! It's super useful !

I do have a question - perhaps it's an improvement if not implemented, I'm not sure - about the offset.

Actually I use inView to check when some specific elements enter in the viewport, without offset. I want to put an event on another element, but it needs to be at least at 300px from the bottom.
I've been trying a very "naive" approach:

inView('#element1').once('enter', function(){console.log('visible without offset');});

inView.offset({bottom:300});
inView('#element2')
	.once('enter', function(el){
		console.log('visible with offset');
});

As far as I can see, this approach is not working (and I'm not very surprised) as inView use a global state. Is there a way to declare an offset on a specific element ?

Thanks for your feedback.
If not implemented yet, I'll try to do that if you'd like,

Xavier.

@camwiegert
Copy link
Owner

@xavierleune At the moment, I'm rewriting in-view to be a thin wrapper around the IntersectionObserver API. So, I don't anticipate merging a lot of changes.

You're right that in-view isn't great for this use case. It was originally designed to be configured globally. If I were you, I'd consider using IntersectionObserver directly and polyfilling for whatever support you need.

Otherwise, if you can wait a bit, I'm hoping to have the new implementation done soon. That will support per-element configuration. Hope that helps!

@xavierleune
Copy link
Author

@camwiegert All right, thanks for your feedback !
For now, I'll try to postpone the need of a per-element configuration and to wait for the new implementation !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants