Skip to content
Snippets Groups Projects

Mobile Post button fix

Merged Eugenij requested to merge eugenijm/pleroma-fe:fix/floating-button into develop

Closes #506 (closed)

Merge request reports

Pipeline #11259 passed

Pipeline passed for b18fea85 on eugenijm:fix/floating-button

Approval is optional

Merged by HJHJ 5 years ago (May 7, 2019 6:40pm UTC)

Merge details

Pipeline #11494 passed

Pipeline passed for 157d4e60 on develop

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
84 93
85 94 this.oldScrollPos = window.scrollY
86 95 this.scrollingDown = scrollingDown
96 }, 100),
97 handleScrollDown: debounce(function () {
  • Maintainer

    why isn't the entire thing debounced?

  • Author Contributor

    In my understanding, the purpose of the throttled function was to keep track of the direction so that it could hide the button when scrolling down (positive scrollAmount) and show it when scrolling up (negative scrollAmount). I'm not sure if the latter is the desired behavior, but if so, I think scrollY needs to be constantly updated, hence throttle. Otherwise, debounce, which is called at the beginning / end of the scroll, doesn't have enough info to know the direction and whether it is the beginning or end of the movement. (this may illustrate this point a bit better: https://cl.ly/846f6e51d4a7).

    Are you suggesting to distinguish between the leading and trailing debounce calls and then hide it on leading (the beginning of the movement) and show on trailing? I haven't considered that but I guess it should be possible. Will look into how this and how can this be simplified in general tomorrow morning

    Edited by Eugenij
  • Author Contributor

    Update: the debounce-only approach works overall:

        handleScrollStart: debounce(function () {
          if (window.scrollY > this.oldScrollPos) {
            this.hidden = true
          } else {
            this.hidden = false
          }
          this.oldScrollPos = window.scrollY
        }, 100, {leading: true, trailing: false}),
    
        handleScrollEnd: debounce(function () {
          this.hidden = false
          this.oldScrollPos = window.scrollY
        }, 100, {leading: false, trailing: true})

    However, there is a limitation compared to the previous approach with throttle:

    if the user scrolls up a little and then immediately continues to scroll down, it will still consider this as a "scroll-up" event and won't hide the button.

    So, with the debounce-only approach, we can either accept this as a limitation or make it hide the button even on scroll-up.

    Edited by Eugenij
  • Maintainer

    i'd leave it entirely debounced.

  • changed this line in version 13 of the diff

  • Author Contributor

    Done

  • Please register or sign in to reply
  • HJ
  • HJ
  • Maintainer

    Right now with autohide enabled it hides button only during scroll-down, when scroll stops button pops back up.

    Not very important and could be done in a separate MR.

    Other things need to be fixed tho.

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading