Skip to content

Conversation

@kyosifov
Copy link

Add a prop which enables the use of HTMLBody Element as a wrapper.

In one of my projects in order to disable default scroll from Safari, I had to use overflow: scroll for the body and when I want to use it as an infinite loader a check is made when using "body" and it fallbacks to Window.

This pull request adds a prop which enables the usage of "body".

@codecov
Copy link

codecov bot commented Nov 14, 2019

Codecov Report

Merging #268 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #268 +/- ## ===================================== Coverage 100% 100% ===================================== Files 5 5 Lines 174 176 +2 Branches 32 33 +1 ===================================== + Hits 174 176 +2
Impacted Files Coverage Δ
src/components/InfiniteLoading.vue 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3792d95...9607128. Read the comment docs.

@PeachScript
Copy link
Owner

Could it not be implemented that set forceUseInfiniteWrapper as body?

@kyosifov
Copy link
Author

Could you please elaborate? Maybe I have not been clear.

in this line of code -- https://github.com/PeachScript/vue-infinite-loading/blob/master/src/components/InfiniteLoading.vue#L323

You check if the element is of tag "body" and if that is the case you default to the window. That is a great feature if you use the default scroll, but if you set the overflow: auto to both HTML, body the infinite wrapper breaks as the window's scrollTop no longer updates.

And so I implemented a new prop to force it, so we do not use the body if we pass the element.

@PeachScript
Copy link
Owner

PeachScript commented Dec 13, 2019

You could check out this line: https://github.com/PeachScript/vue-infinite-loading/blob/master/src/components/InfiniteLoading.vue#L319

InfiniteLoading will querySelector and use the target element as scroll parent if we pass forceUseInfiniteWrapper property.

@JesusRugama
Copy link

InfiniteLoading will querySelector and use the target element as scroll parent if we pass forceUseInfiniteWrapper property.

InfiniteLoading will querySelector inside the components element, then its parent, then the parent of its parent, until it reaches body. It will never do document.querySelector('body') and $body.querySelector('body') wont find the body either, so getScrollParent will never return the body.

@PeachScript
Copy link
Owner

@JesusRugama got it, I wrote querySelector from component element rather than window, I will fix it in the next version, thank you very much ❤️

@PeachScript
Copy link
Owner

v2.4.5 fixed querySelector bug, this PR will be closed.

@PeachScript PeachScript closed this Mar 5, 2020
@JesusRugama
Copy link

@PeachScript thanks for your work! its a great tool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants