-
Notifications
You must be signed in to change notification settings - Fork 723
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
Infinite scroll on any element. #7
Conversation
Actually I've rewritten infinite-scroll so it will find the correct scroll parent automatically without the user having to specify which element to use. I think this is an easier out of the box solution that just works as opposed to making the user stop and think about how to configure infinite-scroll to work for their situation. |
@chubbard could you please share the code? |
Works like a charm! Thank you, this saved my project! |
@yungpanda Glad it helped somebody else. Both attributes do the same: watch on some element's scroll. With infinite-scroll-contained you must specify which element you want to watch, while infinite-scroll-parent just watches the applied element's parent, which is a common case (was for me, anyway). |
Good one 👍 We're already starting to implementing this ourself. Works good. |
@chubbard can you share your code? In the mean time, thanks tcard - I'll be using this as well. |
I'd be happy to commit the code, but being a github newbie on this. Not sure what is the best way to do that. |
How come this code hasn't been merged yet? Don't want to sound harsh but a directive that watches only the $window is a bit useless in my opinion, as chances that most users will need to make this work on specific elements, and potentially on multiple elements in the same window, as is in my case; That said, @tcard, I'm not sure how to use your infinite-scroll-container attrs; Could you provide an example? Here's how I see hoe this directive should behave though; That would eleminate the need for extra attributes and config mumbojumbo What do you guys think? |
Yeah. Actually, we've merged it in our fork, too: https://github.com/hlsolutions/ngInfiniteScroll/tree/scroll-on-any-lement I think you have only to provide |
Thanks for the update @knalli Sorry for the long upcoming post: I'm playing with this right now and coming up with this that seems to work just fine (I haven't done any real testing just yet though) NoteFor some reason I had to put Each Referring to It looks like this:
So given that context, here's what I could use succesfuly (in the
Don't even need a ref to the parent container either; I still need to check how this behave given different context and elements though... |
Ehm, build an example please. Much more easier. |
@OClement Just pass a jQuery selector, such as |
@tcard: @knalli: You can checkout the code, cd in that directory then sorry if it's complicated :P |
@OClement IDs are more or less the standard way to refer to elements, aren't they? Anyway, you can also put the |
I've tried it. Some resources are still missing and won't resolved by Bower. Missing files in browser.. |
@knalli Sorry, I forgot to update bower dependencies with a few libs; It should work right now |
Not really. Try to reduce the problem. Sometimes, a single/simple problem can be solved by reducing the complexity of big apps. |
@tcard first off, thanks for doing this... I anticipate this being a life saver. Second, and embarrassingly, I cannot get your implementation to work. I have an absolutely positioned scrollable element and then use your syntax from an earlier post: <div data-infinite-scroll="loadMore()" data-infinite-scroll-distance="2" data-infinite-scroll-container="#container-view"... and receive the following error (seems like it is angular barfing): Error: Lexer Error: Unexpected next character at columns 0-0 [#] in expression [#container-view]. |
Theses issues and commits confuse me. Where do I actually get this patch? :) Edit: found it. @nokturnal I'm getting the same error as you. |
This is not working for me. I have two ng-repeats happening. One is on the main page. The other is an overlay. When I open up the overlay, it shuts down overflow on the body, but allows overflow on the overlay itself. Now the overlay covers the entire page, it has position fixed. I tried using infinite-scroll-container=".overlay_backdrop" and it doesn't do anything. However when I close the overlay and scroll on the main page, this triggers the handler that is meant for the overlay. The handlers are not being isolated from each other when they are instantiated. |
CMCDragonkai - why not show us in a jsfiddle? For me, the patch works. |
@chubbard Why don't you copy and paste your solution or diff onto http://pastie.org/? |
I pulled the latest js code from: https://github.com/hlsolutions/ngInfiniteScroll/tree/scroll-on-any-lement But I too am seeing the same error as @nokturnal and @dmackerman: I'm on angular v1.2.7 Does anyone know the solution? |
Do you have a demo? Plunkr? |
In angular 1.2.x I also get the lexer error. Solution: put your value into commas: '#my-selector'. |
@BinaryMuse why don't you merge this? |
While it's unfortunate that BinaryMuse isn't updating the repo anymore, this should not be merged as it is. Two problems: In 1.2, you get a lexer error, and when you change the scroll-container after linking, the scroll event handler is not bound to the new container. |
If
ul.container
li(
infinite-scroll = "myPagingFunc()"
infinite-scroll-parent = "true"
ng-repeat = "post in posts"
)
h1 {{ post.title }}
div {{ post.content }}
It would be so much simpler to do the following: ul.container(
infinite-scroll = "myPagingFunc()"
)
li(ng-repeat="post in posts")
h1 {{ post.title }}
... |
I can not for the life of me get this to work - the only script that works is the original 1.0 - What am I doing wrong? |
Don't know without your code. It works well but without documentation i had to put some console.log() in the directive code to understand how to set up this. In my case : Let's say that you have a div with a scroll, in my case because of theses css properties : .class_with_css_props_leading_to_a_scroll {
height: 100%;
overflow-y: auto;
} And this div contains a child div, and that child div contains one ore more div or li with ng-repeat (3 nested ng-repeat in my case) Your structure is : <div id="main_block_with_scroll" class="class_with_css_props_leading_to_a_scroll">
<div infinite-scroll="youFnToGetMoreResults()"
infinite-scroll-container="'#main_block_with_scroll'"
infinite-scroll-parent>
<div ng-repeat="elem in list">
</div>
</div>
</div> Hope it can help. |
I've always used it like this without infinite-scroll-parent:
I couldn't get it done, but thanks to @MarcLoupias 's example I got it working!! |
Which example exactly? |
the comment above ;) #7 (comment) |
Thanks @MarcLoupias it works like a charm. |
@MarcLoupias thanks! |
hi, <div ui-view="content" id="myContent">
<div infinite-scroll="scrollToLoad()" infinite-scroll-distance="1" infinite-scroll-container="'#myContent'" >
<div ng-repeat="collection in collections" > </div>
</div>
</div> thanks.. |
@cecep17 the branch you're referencing is pretty far behind the current state of code. It's probably not a bad idea to update. Regardless, you likely just need the |
@fishfacemcgee which branch for last code? are at master? |
@cecep17 Master Branch of this repository would have the latest code. You're referencing a side-branch of a fork that hasn't been updated in a long time. |
@fishfacemcgee how i know my is use ngInfiniteScroll ? my real problem is i have side bar with scroll, at this moment if i scroll my sidebar an have max.. my content with ngInfiniteScroll scrolling to..
i hope you understand and thanks for help. |
@cecep17 I'm not sure I follow, unfortunately. Your best bet would be to set up a Plunkr or something that can demonstrate the issue. |
Here is a Plunkr in case any one want to see it working: http://plnkr.co/edit/a2u9I9 |
Thanks @ObaidUrRehman for the Plunkr. Has anyone been able to make it work on mobile? I'm having issues, but can't pinpoint the exact root cause… Edit: I used multiple |
Hi guys, I've been working with this directive and it's just fantastic! However, i have some issues with scrolling. What happens is that scroll event actions are executing even when i'm not really scrolling the infinite scroll container, has any of you experienced this same problem? Your help will be appreciated! Thanks! |
@MarcLoupias thanks! that worked very well, I will only add Im using version 1.2.0 of ngInfinite. |
Thanks for the good work! @PaulMougel I have used this for a site now, and it works fine on iPhone 4/5/6 and iPad mini as far as I have seen. |
Was having an issue getting infinite scroll to work and found the solution. It wasn't a problem with the ngInfiniteScroll code though, but I just thought I'd post it here for anyone who is using the same frameworks. I've been trying to get infinite scroll working on a sidebar container in a project that uses Angular Material Design. I managed to see scroll events firing on the right element using infinite-scroll-parent='true', but it was firing every time I scrolled. So I was debugging the infinite scroll code when I saw that elementBottom and remaining were negative. It appears that having layout="column" (I think its an HTML attribute only used by the material design code) on your element causes something weird to happen. If you scroll, the div appears in the right location visually, but it actually scrolls up in the DOM viewer, so it makes sense that the element offsets are negative. So the fix for me was just removing that attribute. I'm not really a front-end developer so idk if this behaviour is a bug with Material Design or not. Anyways, took me quite awhile to figure out, hope this helps others out that are using both Material Design and ngInfiniteScroll. |
My problem was similar to @JQGuo because every time I scrolling, the page event was fired. It was because the div element with ng-repeat had assigned a style float: left. |
@mgonzalez10 Thanks! |
I'm getting the same problem as @dopgm . The nextPage isn't fetching the next results. I'm only getting the first page when in a modal |
I resolved the issue with adding infinite-scroll-parent on the element, it works fine on ng-infinite-scroll: 1.3.0 |
I use infinite scroll on ng-dialog in a div, it works ,but when i scroll function
|
I have a scroll-able div and my main page is also scrollable. In my case, the desired behavior is that the |
Sets two new attributes: infinite-scroll-container, which replaces $window with an arbitrary scrollable element, and the helper infinite-scroll-parent, which replaces $window with the element's parent.