Skip to content

[stable13] Fix scrolling in chat view#843

Merged
Ivansss merged 3 commits into
stable13from
stable13-838-fix-scrolling-in-chat-view
May 2, 2018
Merged

[stable13] Fix scrolling in chat view#843
Ivansss merged 3 commits into
stable13from
stable13-838-fix-scrolling-in-chat-view

Conversation

@danxuliu

@danxuliu danxuliu commented May 2, 2018

Copy link
Copy Markdown
Member

Backport of #838

danxuliu added 3 commits May 2, 2018 18:15
When an element has a negative top margin jQuery returns its top
position as the position in where the element would be if it had no
margin. In a similar way, when there is a negative margin the returned
height is not the actual height of the element, but its height without
that margin.

The message list is expected to scroll to the newest message if the last
one is partially visible, but due to the jQuery behaviour the message
list did not scroll when the last message was grouped and less than 20px
(the negative top margin) of the content of that message was visible.
Now the negative margin is taken into account and the message list
always scrolls to the newest message if the last one is partially
visible.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The scroll area covers the top and bottom padding of an element, but not
its top and bottom margins, so the margins should not be taken into
account in the scroll calculations.

Currently this does not cause any difference in the behaviour, as the
message lists does not have any margin, but it is fixed just in case it
is added in the future.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When an element is detached and then attached again its scroll position
is reset to the top. Now the chat view provides the "saveScrollPosition"
and "restoreScrollPosition" methods to save the scroll position before
detaching its element and then restoring it when attached again.

Note that the position can not be exactly restored, as the size of the
chat view may have changed due to switching it from the main view to the
sidebar, and thus the visible messages can not be the same in both
cases. Due to this, restoring the scroll position just ensures that the
last message that was partially visible when it was saved will be fully
visible when it is restored.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@danxuliu danxuliu added this to the 3.2 (Nextcloud 13.0.2) milestone May 2, 2018
@danxuliu danxuliu requested review from Ivansss and nickvergessen May 2, 2018 16:16
@Ivansss Ivansss merged commit 325277f into stable13 May 2, 2018
@Ivansss Ivansss deleted the stable13-838-fix-scrolling-in-chat-view branch May 2, 2018 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug feature: chat 💬 Chat and system messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants