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.