JagWaugh
(Andrew Waugh)
2017 年 4 月 24 日午後 4:08
1
A user asked about this today.
If you’ve used search to get a list of posts, scroll down then click on one of them, if you then use the back function in the browser it always returns you to the top of the search results.
If you view a category, scroll down, then open a topic, the back button returns you to your previous scrolling position.
「いいね!」 8
sam
(Sam Saffron)
2017 年 4 月 26 日午後 7:09
2
I believe this was reported before but can not find the topic or discussion fragment, its a bug we should fix.
「いいね!」 2
Sure if this is not too hard or risky maybe @eviltrout could take it.
nbianca
(Bianca)
2017 年 8 月 10 日午後 8:54
5
Hey,
I have been trying to fix this issue. I implemented it like this so far: https://github.com/discourse/discourse/compare/master...nbianca:scroll_tracking?expand=1
The issue is that even though scrollTo
has the right value in didInsertElement
, the scrollTop
method does not seem to work (probably rendering has not finished?).
Can anyone take a look, please?
「いいね!」 4
j.jaffeux
(Joffrey Jaffeux)
2017 年 8 月 11 日午前 8:24
6
Hi Bianca,
I would implement it this way:
import Scrolling from "discourse/mixins/scrolling";
export default Ember.Component.extend(Scrolling, {
didInsertElement() {
this._super();
this.bindScrolling({ name: this.get("name") });
},
didRender() {
this._super();
const scrollToY = this.session.get(this.get("trackerName"));
if (scrollToY && scrollToY >= 0) {
Ember.run.next(() => $(window).scrollTop(scrollToY + 1));
}
},
didReceiveAttrs() {
this._super();
this.set("trackerName", `scroll-tracker-${this.get("name")}`);
},
willDestroyElement() {
this._super();
this.unbindScrolling(this.get("name"));
},
scrolled() {
this._super();
this.session.set(this.get("trackerName"), $(window).scrollTop());
},
});
It should work, feel free to modify the coding style. Thanks for your contribution.
「いいね!」 4
nbianca
(Bianca)
2017 年 8 月 12 日午後 8:07
7
Thank you a lot! That fixed my issue and made my code look a lot better.
I submitted this pull request: https://github.com/discourse/discourse/pull/5040
「いいね!」 5