lizmat / App-Raku-Log

Cro application for presenting Raku IRC logs
Artistic License 2.0
3 stars 3 forks source link

[Feature Request] Infiniscroll #9

Closed patrickbkr closed 3 years ago

patrickbkr commented 3 years ago

I propose to add an automatic loading of older messages when scrolling to the top in the live view.

If that's difficult to do, alternatively it would help to have a way to easily transition from the live view to the logs-of-a-day-view without having to find / scroll to the position, where the live view ended. I think for me this would be a help when backlogging. (I tend to backlog in reverse time.)

lizmat commented 3 years ago

It should do that already? Try pulling it down a bit more maybe?

patrickbkr commented 3 years ago

Hm. I have now tried it on my laptop on Linux in Firefox and Chrome, disabled the adblocker and on Firefox and Chrome on an Android Smartphone. raku, raku-dev and moarvm all don't seem to do anything when scrolling to the top of the page in the live view. The Firefox Developer Console does not list any errors that seem to point in the direction of a JavaScript error.

It does automatically load new messages when someone wrote something on IRC, but that's a different feature.

I get the feeling we are talking about something different. In the following screenshot I have scrolled to the top of the raku channel live view. No older messages appear. image

Can you confirm you think we are talking about the same thing?

lizmat commented 3 years ago

Yes, we're talking about the same thing. This is the logic that is being used:

          var $minY  = 0;
          window.addEventListener('scroll', function(e) {
              let currentY = window.scrollY;
              if (currentY == 0) {
                  if (-3 > $minY) {
                      scrollup("<.channel>", 5 + Math.floor(-$minY / 3));
                      $minY = 0;
                  }
              }
              else if (0 > currentY) {
                  $minY = Math.min($minY, currentY);
              }
          });

However, started up a Chrome client, and indeed, it doesn't work on that. Investigating.

lizmat commented 3 years ago

Looks like a case of:

[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
patrickbkr commented 3 years ago

I do indeed see a similar message in the Firefox JS logs. But I think it's unrelated. It's only a warning. I put a breakpoint on that bit of code and it is triggering. On my machine when scrolling to the top $minY and currentY are both zero. This prevents the inner if from succeeding. I think I don't understand how the $minY thing is supposed to work.

patrickbkr commented 3 years ago

Is there some kind of rubber band effect on MacOS that allows scrolling above the top? I think that's not a thing outside of the Mac world. (There was a famous lawsuit about that effect.)

lizmat commented 3 years ago

Ah, I see, maybe it is a MacOS thing. Or at least a Safari thing.

lizmat commented 3 years ago

I believe https://github.com/lizmat/App-Raku-Log/commit/a7e458d9431e2ebfe2bcbe7e9f90cc97199e2a7c solves this for non-Safari users. Could you confirm and close the issue if so? Thanks!

patrickbkr commented 3 years ago

It does work now, but after loading a bit more of the backlog, requires scrolling down to be able to scroll back up again. Could you - after adding more backlog - make sure the page isn't scrolled up entirely so one can then scroll that tiny amount up repeatedly?

lizmat commented 3 years ago

If you can tell me the JS logic I would have to do for that, sure!

patrickbkr commented 3 years ago

I'll have a look.

lizmat commented 3 years ago

@patrickbkr I think this is now covered. Please close if you agree.

patrickbkr commented 3 years ago

I do agree. :-)