-
Notifications
You must be signed in to change notification settings - Fork 142
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
Introduce hooks #365
Merged
Merged
Introduce hooks #365
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looks good! Also i think what were need to update examples, i can do it later. |
@rimlin, sounds good. |
This was referenced Nov 7, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes it possible to hook into the loading process as discussed in #304
This makes it easy to create your own lazyloader. Lets look at some examples:
This will use a scroll listener as before so no breaking changes.
It is however now possible to add hooks so you can create your own, custom, loaders. For example, let's say you want to fetch an image with some custom headers. If so, you can create a custom hook to fetch the image:
And then pass it to
LazyLoadImageModule
:The hooks that are possible to overwrite is:
I made it also possible to create a
preset
to set all the functions above. I have created two preset. One for scroll events and one for IntersectionObserver. So it is now possible to useIntersectionObserver
by just importing the intersectionObserverPreset:I have also publised
[email protected]
so you can try it out and I created a demo page here: https://stackblitz.com/edit/angular-lazyload-intersection-observer?file=src%2Fapp%2Fapp.module.tsSo what do you think? @rimlin @sapierens
Closes: #356 #304 #362
Easy fixes: #322 #323 #334
Easy fixes if intersection observer is possible: #355 #360