Infinite Scroll

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Infinite Scroll
« Reply #90, on July 4th, 2013, 08:32 PM »
Indeed, looks like it's no longer working...
This might be due to the sidebar stuff, I don't know... jQuery should be allowing me to accumulate multiple touchmove events, but if for any reason it only executes one, then there's your problem... :-/

Code: [Select]
Sorry, just testing something else... Can't bother to find another topic that has a code tag... Please bear with me...

(Hmm, looks like I can't reproduce the scrollbar bug today... Is this a bug fix in Chrome 30, maybe..?)
:edit: Nope, happened as soon as I quick-edited the post... Goes away if I happen to change any of the CSS properties, so it's not even fixable in a convenient way, arggg...

godboko71

  • Fence accomplished!
  • Hello
  • Posts: 361
Re: Infinite Scroll
« Reply #91, on July 5th, 2013, 01:04 AM »
Well atleast I haven't lost my mind sorry holiday today so only partly here.
Thank you,
Boko

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Infinite Scroll
« Reply #92, on August 1st, 2013, 05:26 PM »
Quote from Nao on July 4th, 2013, 08:32 PM
(Hmm, looks like I can't reproduce the scrollbar bug today... Is this a bug fix in Chrome 30, maybe..?)
Nope, it's still there on new pageloads... It fixes itself if quick-editing the post in question, and some other situations, but... It's still quite annoying, really. The only clue I have, is that it's a Chrome-only bug, and it happens with overflow: auto inside a div that's using the flexible layout model. (Talk about an awfully buggy system, eh... And people say it's the future..? Okay, but fix it first, right..?)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Infinite Scroll
« Reply #93, on August 1st, 2013, 05:43 PM »
That scrollbar still can't be scrolled in Chrome 29 either.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

ChalkCat

  • Posts: 6
Re: Infinite Scroll
« Reply #94, on August 22nd, 2013, 09:03 PM »
I love the infinity scroll!  A couple of things I've noticed though:

In my Firefox 23.0.1, after the IS has kicked in and I'm scrolling through the second (or more) page in the topic, the whole display goes very jittery, the kind of effect you'd expect when the graphics card can't keep up with a game.  I disabled the browser's "smooth scrolling" option and the issue is resolved (other than making scrolling everywhere jerky - LOL)

Whilst confirming that disabling smooth scrolling stopped the jitteriness and scrolling through this very thread to see if anybody had already mentioned the jitter, I noticed the strange effect you see in the attached screenshot.  Only with replies #22 and #24 of this thread.  After scrolling through the whole thread I went back again and sure enough, with those two same posts, the same thing happened as the user box approached the top of the screen.  I could not recreate the effect with any other posts in this thread, but I haven't looked for it on any other threads.

(Ooh I like how you see a diddy-preview of attached image as soon as you attach it - cool!)

📎 Capture.PNG - 90.57 kB, 1124x456, viewed 193 times.


Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Infinite Scroll
« Reply #95, on September 28th, 2013, 09:45 PM »
So... Infinite scrolling. We meet again.

I just wanted to say something about it.

Really, infinite scrolling is for *static content*. All websites that show infinite scrolling will only do it on items that they know are built in a way to 'accept' being nested into other pages and not corrupting them.

Earlier today, I noticed that the More button was broken in infinite-scrolling-loaded pages. I then realized it was broken by a small change in rev 2262 that fixed infinite scrolling on IE 11, or something... But broke many things everywhere else. So, back to the old code...
Unfortunately, it still doesn't execute some things correctly-- e.g. the code BBC hack for Chrome... And, I'm not exactly sure why.
It also tends to duplicate DOM objects that are modified by JavaScript. For instance, the board selector. I tend to fix these manually. Up until now, the quick edit button would be duplicated; it's no longer the case, but...

It's freaking annoying, knowing that in years from now, some people will just break their teeth on their plugin because it does some modifications to individual posts, and it doesn't play along with infinite scrolling.

I gave another try to the iframe-based version, but it's even worse, really... I should have kept a copy of the 'working' version I had before. Maybe it was fixable. I'm not so sure, right now... What I do know, though, is that it's unrealistic to use that right now.

So, I'm asking again... Guys, do you think the infinite scrolling feature is fantastic enough to guarantee that plugin authors will happily comply with its complicated rules..? Or should infinite scrolling simply, well... Redirect to the previous/next page through insistent mouse wheel scrolling? (i.e. if you scroll down for a second, instead of loading the next page via Ajax and showing it below the current page, it'll simply redirect you to the next page.)
That's the 'chicken' solution, but honestly... It also carries zero issues with it, and when I say zero, I do mean zero...

Re: Infinite Scroll
« Reply #96, on September 28th, 2013, 10:57 PM »
Infinite scrolling looks real nice, but the difference between the present version and the one just loading the next page on further scrolling is visible for a second or so.
I am plugin author, but if even you the developer has problems making and keeping everything work correctly then to me that is a sign that it's probably best to ditch it.

Aaron Smith

  • The mini menus on Thoughts... Damn Sexy!
  • Posts: 39
Re: Infinite Scroll
« Reply #97, on September 29th, 2013, 12:45 PM »
I really like the idea of infinite scrolling, but it's not IMHO fantastic enough to spend this kind of time on it. I think if a simple redirect to the next page is doable with no issues then I'm content with this middle ground solution.

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Infinite Scroll
« Reply #98, on September 29th, 2013, 05:09 PM »
Quote from Johnny54 on September 28th, 2013, 10:57 PM
Infinite scrolling looks real nice, but the difference between the present version and the one just loading the next page on further scrolling is visible for a second or so.
What difference..? :huh:

Okay, regarding the use of an iframe. I should have remembered that... The problem with iframes is two-fold:
- if I just want to load the next page into an iframe and have it take the correct height etc, it'll still run its JavaScript inside of the frame, and thus, a popup animation will take place inside of it, not inside of the main page.
- if I want to 'import' the HTML from within the iframe towards the main page, the JavaScript will STILL execute within the iframe, or, if the iframe is removed consequently, it won't execute at all.

I tried to find a proper way to 'move' the scripts, but the current solution has been doing that, and it's what I wanted to avoid: any changes to the DOM affect the entire page, not just the new stuff...

And doing a trick such as overriding jQuery.fn.init to always add the new content's div as the 'context' variable doesn't seem to work. It didn't back when I first thought of it last month, and it still doesn't.

The big, big issue with infinite scrolling, is really that it's tailored to one of two situations:
- the new content is really, really simple, and we are 100% sure there's not (much) JavaScript in it; making it possible to just show it without dealing with JS...
- or on the contrary, it's very complicated, but the whole website is a 'web app' in style, that is, the HTML is only a placeholder to run Ajax queries, and show them after applying some magic to the results. For instance, Backbone.js allows for this kind of thing.

Wedge is not the former, and as for the latter, it would require passing all message-related functions to a single pass-through function that would then reapply its modifications on demand. Basically, while it's DOABLE, it's not realistic. It would put far too much pressure on plugin developers and themers, and I don't want that.

I'm considering, though, the possibility of keeping the current code but as a plugin; i.e., it's the responsibility of the webmaster to determine whether they want the cool effect, and whether they're ready to accept they'll have to disable some other plugins that may conflict with it.

Suki

  • Posts: 59
Re: Infinite Scroll
« Reply #99, on September 29th, 2013, 07:23 PM »
I faced the same annoyances :( infinitescroll is nice and dandy but it is really a pain in the posterior.

I used the jquery plugin along with my custom pagination class, later and for performance, I changed my big fat query (I was loading every single message) for the SMF approach of using $start and LIMIT, turns out the jquery script was borked (because how it works vs how SMF works) so I have to code my very own version of it.

I couldn't get a fine and stable code for scrolling events, yes jQuery has .scroll() and I can get if the user has reached the bottom of a page, however, it was very unstable (if the user stays at the bottom the event gets fire constantly) so I decided to use a "load more" button.

Another issue was handling all the HTML, I had 2 options, sent the entire data plus HTML as a json object or just send the pure data and have all the HTML either created on-the-fly or as an empty shell on the template itself, I decided to just sent the already constructed HTML as a json object and then just use .append() on an empty <ul> created on-the-fly by jQuery.

I didn't want to have multiple template structures so I took the message HTML, isolated it on a  single function with all the data (content, poster, time, etc) passed as a param and thats the only template I use for every place where I show a message, it is a little hackish because in the same function I can either return the structured HTML or just print it, depending on where exactly I'm using that template function, my solution was to use a var and at the end simple decide what to do, return it or print it, not nice but it works.

I also faced the duplicate DOM elements, in my case it wasn't that much of an issue since I don't handle that many features and options, my solution was handling all JS events using jQuery(document).on() to differentiate between events I use the ID in the ID attribute so:

Code: [Select]
jQuery(document).on('submit', '.form_comment', function(event){

// The most important thing is... the ID
var StatusID = parseInt(jQuery(this).attr('id').replace('form_comment_', ''));

var comment = {
'commentStatus' : StatusID,
'commentOwner' : jQuery('#commentOwner_' + StatusID).val(),
'commentPoster' : jQuery('#commentPoster_' + StatusID).val(),
'commentStatusPoster' : jQuery('#commentStatusPoster_' + StatusID).val(),
'commentContent' : jQuery('#commentContent_' + StatusID).val(),
};

But I recon, the amount of DOM elements I manage is extremely low and this approach wouldn't work on handling forum messages.

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Infinite Scroll
« Reply #100, on September 29th, 2013, 08:04 PM »
Quote from Suki on September 29th, 2013, 07:23 PM
I faced the same annoyances :( infinitescroll is nice and dandy but it is really a pain in the posterior.
Glad to know I'm not alone... ;)
Quote
I used the jquery plugin
Which one..?
Quote
I couldn't get a fine and stable code for scrolling events, yes jQuery has .scroll() and I can get if the user has reached the bottom of a page, however, it was very unstable (if the user stays at the bottom the event gets fire constantly) so I decided to use a "load more" button.
Yes, it's better for accessibility. Although, as you may have noticed, Wedge does it differently: it only triggers on mouse wheels, and only starts counting mouse wheels after you reach the end of the page. It was a deliberate decision, to ensure that the user actually wants to see the next page.
I must admit, I'm a mouse wheel freak... I tend to roll it everywhere, including at the end of a page, so it was a no-brainer for me. The counterpart, though, is that I can't decide whether to use the system to just load the next page the 'regular' way, because the current solution at least allows me to keep reading the last post in the page, even if I'm wheeling a bit too much.
Quote
Another issue was handling all the HTML, I had 2 options, sent the entire data plus HTML as a json object or just send the pure data and have all the HTML either created on-the-fly or as an empty shell on the template itself, I decided to just sent the already constructed HTML as a json object and then just use .append() on an empty <ul> created on-the-fly by jQuery.
Did your data have any events attached to them..?
Quote
I didn't want to have multiple template structures so I took the message HTML, isolated it on a  single function with all the data (content, poster, time, etc) passed as a param and thats the only template I use for every place where I show a message, it is a little hackish because in the same function I can either return the structured HTML or just print it, depending on where exactly I'm using that template function, my solution was to use a var and at the end simple decide what to do, return it or print it, not nice but it works.
At this point, I'd be glad to have an ugly solution that just ensures developers can freely work around this infinite scrolling thing... :-/

I'm trying to figure out a 'different way', but it's hard. Something like, take all functions that knowingly modify messages (layout, contents...), and have them declare themselves to a special hook that will call them again when new posts are inserted. But I need to figure out a clean way to do that. And I don't even know if it's viable.

Either way, it probably won't be ready for v1.0... In fact, I'm likely to keep things as they are for now, because it 'mostly works', and I'll just fix my existing broken code (i.e. duplicate HTML.) I think that the face value of having this nice infinite scrolling effect is important for Wedge to gain some momentum among the SMF community, and if removed later and replaced with a plugin, it'll have less visibility and I'll be sad about it. (I DID spend a lot of time on this...)
Quote
I also faced the duplicate DOM elements, in my case it wasn't that much of an issue since I don't handle that many features and options, my solution was handling all JS events using jQuery(document).on() to differentiate between events I use the ID in the ID attribute so:
That's a good thing, but it's still something that should be kept to a minimum or to very specific events like the one in your example, because it does mean all events of the same type will bubble up the DOM, be caught by jQuery, which will determine if it was in the 'domain' it was watching, etc... Heck, I'm not exactly sure why the jQuery team replaced .live() with that. Maybe they wanted to make it harder to use the function, and thus encourage dropping it..?
Quote
But I recon, the amount of DOM elements I manage is extremely low and this approach wouldn't work on handling forum messages.
Oh, it might work, after all it's 2013, not 2004. Of course, IE6 won't like this... :P But it's only a matter of months before I definitely drop IE6 support anyway. Whatever, eh...

Suki

  • Posts: 59
Re: Infinite Scroll
« Reply #101, on September 29th, 2013, 10:21 PM »
Quote from Nao on September 29th, 2013, 08:04 PM
Which one..?
The very same one that its named infinite scroll :P I tried others, most of them was built around custom needs so they wouldn't work for me anyway.
Quote from Nao on September 29th, 2013, 08:04 PM
Yes, it's better for accessibility. Although, as you may have noticed, Wedge does it differently: it only triggers on mouse wheels, and only starts counting mouse wheels after you reach the end of the page. It was a deliberate decision, to ensure that the user actually wants to see the next page.
I must admit, I'm a mouse wheel freak... I tend to roll it everywhere, including at the end of a page, so it was a no-brainer for me. The counterpart, though, is that I can't decide whether to use the system to just load the next page the 'regular' way, because the current solution at least allows me to keep reading the last post in the page, even if I'm wheeling a bit too much.
Thats an interesting approach, I'll give it a try :)  I also like the refresh one!
Quote from Nao on September 29th, 2013, 08:04 PM
Did your data have any events attached to them..?
Yes, if the message is a status, users can make a comment on it as well as deleting it, if the message was a comment, theres only the deletion part, thats all I have at the moment, I don't think I'll ever implement editing or even a comment of a comment (child comment) that would be a nightmare!
Quote from Nao on September 29th, 2013, 08:04 PM
At this point, I'd be glad to have an ugly solution that just ensures developers can freely work around this infinite scrolling thing... :-/

I'm trying to figure out a 'different way', but it's hard. Something like, take all functions that knowingly modify messages (layout, contents...), and have them declare themselves to a special hook that will call them again when new posts are inserted. But I need to figure out a clean way to do that. And I don't even know if it's viable.

Either way, it probably won't be ready for v1.0... In fact, I'm likely to keep things as they are for now, because it 'mostly works', and I'll just fix my existing broken code (i.e. duplicate HTML.) I think that the face value of having this nice infinite scrolling effect is important for Wedge to gain some momentum among the SMF community, and if removed later and replaced with a plugin, it'll have less visibility and I'll be sad about it. (I DID spend a lot of time on this...)
Yep, after taking a lot of approaches, suddenly ugly code doesn't seem so ugly anymore :P

Having a single template for messages sure is handy but it comes with its own set of issues, everything gotta be normalized, I'm (ab)using $context to show the poster data (it shows in a fancy lightbox) so before I show the data, I load all possible users IDs and pass them to an instantiated class that sets a $context array, then on the template I use $context['userData'][$userID]['avatar']  but since sometimes I call the template from another instantiated class, the whole global scope gets lose (I haven't really figure it out why exactly :( since I use Dependency Injection, I suspect it has something to do with it but I'm not sure) so I again do some nasty tricks to successfully keep $context in global scope .
Quote from Nao on September 29th, 2013, 08:04 PM
That's a good thing, but it's still something that should be kept to a minimum or to very specific events like the one in your example, because it does mean all events of the same type will bubble up the DOM, be caught by jQuery, which will determine if it was in the 'domain' it was watching, etc... Heck, I'm not exactly sure why the jQuery team replaced .live() with that. Maybe they wanted to make it harder to use the function, and thus encourage dropping it..?
Well, the number of events is an user option, they decide how many messages are showing per page, I'm sure they will chose something like 10 to 15.

I don't know how .live() used to work, from what I read, now its just a duplicate of .on() but I learned not to trust the first (or the most voted) answer I found on stackoverflow :P

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Infinite Scroll
« Reply #102, on October 1st, 2013, 12:45 AM »
Another day working on a potential infinite scrolling rewrite-- another failure. Yesterday, tried to do something with the Shadow DOM. Today, it was with createHTMLDocument(), and executing scripts in a parallel document. Yes, another failure... The new script tags still execute globally the moment the additional document is added to the main DOM. Ah, well. I thought I was onto something, really...!

MultiformeIngegno

  • Posts: 1,337

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Infinite Scroll
« Reply #104, on October 1st, 2013, 11:38 PM »
Got it working a bit better... Well, to be honest, right now on wedge.org, it's working perfectly fine. The updated version is pretty much the same... In fact, they both have the same limitation: if the new page has JS errors in it, it screw up everything. And since I'm doing half of my tests on a page that specifically has JS errors (a buggy video embedding, apparently), I consistently see THAT problem.

I think I've found a solution for the duplicate thingy, though, but mostly, it'll be down to the plugin authors to see to it that their code can execute twice without issues.