mirror of https://github.com/zulip/zulip.git
Return the viewport to a corresponding position when unnarrowing.
(imported from commit d1cb35b175a23e18ed79537843ce7940ec370cf3)
This commit is contained in:
parent
0d5469f6ab
commit
166a9c9635
|
@ -400,8 +400,14 @@ exports.activate = function (operators, opts) {
|
||||||
|
|
||||||
current_filter = new Filter(operators);
|
current_filter = new Filter(operators);
|
||||||
|
|
||||||
|
// Save how far from the pointer the top of the message list was.
|
||||||
|
if (current_msg_list.selected_id() !== -1) {
|
||||||
|
current_msg_list.pre_narrow_offset = current_msg_list.selected_row().offset().top - viewport.scrollTop();
|
||||||
|
}
|
||||||
narrowed_msg_list = new MessageList('zfilt', current_filter,
|
narrowed_msg_list = new MessageList('zfilt', current_filter,
|
||||||
{collapse_messages: ! current_filter.is_search()});
|
{collapse_messages: ! current_filter.is_search()});
|
||||||
|
|
||||||
|
|
||||||
current_msg_list = narrowed_msg_list;
|
current_msg_list = narrowed_msg_list;
|
||||||
|
|
||||||
function maybe_select_closest() {
|
function maybe_select_closest() {
|
||||||
|
@ -552,20 +558,19 @@ exports.deactivate = function () {
|
||||||
// We fall back to the closest selected id, if the user has removed a stream from the home
|
// We fall back to the closest selected id, if the user has removed a stream from the home
|
||||||
// view since leaving it the old selected id might no longer be there
|
// view since leaving it the old selected id might no longer be there
|
||||||
home_msg_list.select_id(home_msg_list.selected_id(), {
|
home_msg_list.select_id(home_msg_list.selected_id(), {
|
||||||
then_scroll: true,
|
then_scroll: false,
|
||||||
use_closest: true,
|
use_closest: true,
|
||||||
mark_read: false
|
mark_read: false
|
||||||
});
|
});
|
||||||
|
// We scroll the user back to exactly the offset from the selected
|
||||||
|
// message that he was at the time that he narrowed.
|
||||||
|
// TODO: Make this correctly handle the case of resizing while narrowed.
|
||||||
|
if (current_msg_list.selected_id() !== -1) {
|
||||||
|
viewport.scrollTop(current_msg_list.selected_row().offset().top - current_msg_list.pre_narrow_offset);
|
||||||
|
}
|
||||||
|
|
||||||
hashchange.save_narrow();
|
hashchange.save_narrow();
|
||||||
|
|
||||||
// This really shouldn't be necessary since the act of unnarrowing
|
|
||||||
// fires a "message_selected.zephyr" event that in principle goes
|
|
||||||
// and takes care of this, but on Safari (at least) there
|
|
||||||
// seems to be some sort of order-of-events issue that causes
|
|
||||||
// the scrolling not to happen, so this is my hack for now.
|
|
||||||
scroll_to_selected();
|
|
||||||
|
|
||||||
$(document).trigger($.Event('narrow_deactivated.zephyr', {msg_list: current_msg_list}));
|
$(document).trigger($.Event('narrow_deactivated.zephyr', {msg_list: current_msg_list}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue