Skip to content

A platform for community discussion. Free, open, simple.

DEV: remove scrolling mixin (#32399)

Kelv9f280872f87c
diff --git a/app/assets/javascripts/discourse/app/mixins/scrolling.js b/app/assets/javascripts/discourse/app/mixins/scrolling.js
deleted file mode 100644
index 91801214323..00000000000
--- a/app/assets/javascripts/discourse/app/mixins/scrolling.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import Mixin from "@ember/object/mixin";
-import { scheduleOnce, throttle } from "@ember/runloop";
-import { service } from "@ember/service";
-
-/**
- This object provides the DOM methods we need for our Mixin to bind to scrolling
- methods in the browser. By removing them from the Mixin we can test them
- easier.
-**/
-const ScrollingDOMMethods = {
- bindOnScroll(onScrollMethod) {
- document.addEventListener("touchmove", onScrollMethod, { passive: true });
- window.addEventListener("scroll", onScrollMethod, { passive: true });
- },
-
- unbindOnScroll(onScrollMethod) {
- document.removeEventListener("touchmove", onScrollMethod);
- window.removeEventListener("scroll", onScrollMethod);
- },
-};
-
-const Scrolling = Mixin.create({
- router: service(),
-
- // Begin watching for scroll events. By default they will be called at max every 100ms.
- // call with {throttle: N} to change the throttle spacing
- bindScrolling(opts = {}) {
- if (!opts.throttle) {
- opts.throttle = 100;
- }
-
- // So we can not call the scrolled event while transitioning. There is no public API for this :'(
- // eslint-disable-next-line ember/no-private-routing-service
- const microLib = this.router._router._routerMicrolib;
-
- let scheduleScrolled = () => {
- if (microLib.activeTransition) {
- return;
- }
-
- return scheduleOnce("afterRender", this, "scrolled");
- };
-
- let onScrollMethod;
- if (opts.throttle) {
- onScrollMethod = () =>
- throttle(this, scheduleScrolled, opts.throttle, false);
- } else {
- onScrollMethod = scheduleScrolled;
- }
-
- this._scrollingMixinOnScrollMethod = onScrollMethod;
- ScrollingDOMMethods.bindOnScroll(onScrollMethod);
- },
-
- unbindScrolling() {
- ScrollingDOMMethods.unbindOnScroll(this._scrollingMixinOnScrollMethod);
- },
-});
-
-export { ScrollingDOMMethods };
-export default Scrolling;
diff --git a/app/assets/javascripts/discourse/tests/setup-tests.js b/app/assets/javascripts/discourse/tests/setup-tests.js
index ba74767e41a..9e03e822560 100644
--- a/app/assets/javascripts/discourse/tests/setup-tests.js
+++ b/app/assets/javascripts/discourse/tests/setup-tests.js
@@ -16,7 +16,6 @@ import QUnit from "qunit";
import sinon from "sinon";
import PreloadStore from "discourse/lib/preload-store";
import { resetSettings as resetThemeSettings } from "discourse/lib/theme-settings-store";
-import { ScrollingDOMMethods } from "discourse/mixins/scrolling";
import Session from "discourse/models/session";
import User from "discourse/models/user";
import { resetCategoryCache } from "discourse/models/category";
@@ -304,9 +303,6 @@ export default function setupTests(config) {
resetCategoryCache();
- sinon.stub(ScrollingDOMMethods, "bindOnScroll");
- sinon.stub(ScrollingDOMMethods, "unbindOnScroll");
-
// Access the container that's set up in createApplication
const scrollManager = app.__container__.lookup("service:scroll-manager");
sinon.stub(scrollManager, "bindScrolling");