mirror of
https://github.com/discourse/discourse.git
synced 2025-02-01 07:37:14 +08:00
REFACTOR: Don't use container in Scrolling mixin
This commit is contained in:
parent
37c6fef535
commit
99764d8108
|
@ -1,6 +1,7 @@
|
||||||
import { scheduleOnce } from "@ember/runloop";
|
import { scheduleOnce } from "@ember/runloop";
|
||||||
import discourseDebounce from "discourse/lib/debounce";
|
import discourseDebounce from "discourse/lib/debounce";
|
||||||
import Mixin from "@ember/object/mixin";
|
import Mixin from "@ember/object/mixin";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This object provides the DOM methods we need for our Mixin to bind to scrolling
|
This object provides the DOM methods we need for our Mixin to bind to scrolling
|
||||||
|
@ -26,17 +27,18 @@ const ScrollingDOMMethods = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Scrolling = Mixin.create({
|
const Scrolling = Mixin.create({
|
||||||
|
router: service(),
|
||||||
|
|
||||||
// Begin watching for scroll events. By default they will be called at max every 100ms.
|
// Begin watching for scroll events. By default they will be called at max every 100ms.
|
||||||
// call with {debounce: N} for a diff time
|
// call with {debounce: N} for a diff time
|
||||||
bindScrolling(opts) {
|
bindScrolling(opts) {
|
||||||
opts = opts || { debounce: 100 };
|
opts = opts || { debounce: 100 };
|
||||||
|
|
||||||
// So we can not call the scrolled event while transitioning
|
// So we can not call the scrolled event while transitioning. There is no public API for this :'(
|
||||||
const router = Discourse.__container__.lookup("router:main")
|
const microLib = this.router._router._routerMicrolib;
|
||||||
._routerMicrolib;
|
|
||||||
|
|
||||||
let onScrollMethod = () => {
|
let onScrollMethod = () => {
|
||||||
if (router.activeTransition) {
|
if (microLib.activeTransition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return scheduleOnce("afterRender", this, "scrolled");
|
return scheduleOnce("afterRender", this, "scrolled");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user