diff --git a/app/assets/javascripts/admin/addon/templates/users-list-show.hbs b/app/assets/javascripts/admin/addon/templates/users-list-show.hbs index 1ee1985adbc..1ff64f70020 100644 --- a/app/assets/javascripts/admin/addon/templates/users-list-show.hbs +++ b/app/assets/javascripts/admin/addon/templates/users-list-show.hbs @@ -67,7 +67,7 @@ {{#if this.users}} { + this.table = element.querySelector(".directory-table"); + this.topHorizontalScrollBar = element.querySelector( + ".directory-table-top-scroll" + ); + this.fakeScrollContent = element.querySelector( + ".directory-table-top-scroll-fake-content" + ); + + this.checkScroll(); + }); + + @bind + checkScroll() { + if (this.table.getBoundingClientRect().bottom < window.innerHeight) { + // Bottom of the table is visible. Hide the scrollbar + this.fakeScrollContent.style.height = 0; + } else { + this.fakeScrollContent.style.width = `${this.table.scrollWidth}px`; + this.fakeScrollContent.style.height = "1px"; + } + } + + @bind + replicateScroll(from, to) { + this.lastScrollPosition = from?.scrollLeft; + + if (!this.ticking) { + window.requestAnimationFrame(() => { + to.scrollLeft = this.lastScrollPosition; + this.ticking = false; + }); + + this.ticking = true; + } + } + + +} diff --git a/app/assets/javascripts/discourse/app/components/responsive-table.hbs b/app/assets/javascripts/discourse/app/components/responsive-table.hbs deleted file mode 100644 index 8cfc2185e42..00000000000 --- a/app/assets/javascripts/discourse/app/components/responsive-table.hbs +++ /dev/null @@ -1,22 +0,0 @@ -
-
-
-
-
-
- {{yield to="header"}} -
-
- {{yield to="body"}} -
-
-
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/responsive-table.js b/app/assets/javascripts/discourse/app/components/responsive-table.js deleted file mode 100644 index ac1523313d5..00000000000 --- a/app/assets/javascripts/discourse/app/components/responsive-table.js +++ /dev/null @@ -1,51 +0,0 @@ -import { tracked } from "@glimmer/tracking"; -import Component from "@ember/component"; -import { bind } from "discourse-common/utils/decorators"; - -export default class ResponsiveTable extends Component { - @tracked lastScrollPosition = 0; - @tracked ticking = false; - @tracked _table = document.querySelector(".directory-table"); - @tracked _topHorizontalScrollBar = document.querySelector( - ".directory-table-top-scroll" - ); - - @bind - checkScroll() { - const _fakeScrollContent = document.querySelector( - ".directory-table-top-scroll-fake-content" - ); - - if (this._table.getBoundingClientRect().bottom < window.innerHeight) { - // Bottom of the table is visible. Hide the scrollbar - _fakeScrollContent.style.height = 0; - } else { - _fakeScrollContent.style.width = `${this._table.scrollWidth}px`; - _fakeScrollContent.style.height = "1px"; - } - } - - @bind - onTopScroll() { - this.onHorizontalScroll(this._topHorizontalScrollBar, this._table); - } - - @bind - onBottomScroll() { - this.onHorizontalScroll(this._table, this._topHorizontalScrollBar); - } - - @bind - onHorizontalScroll(primary, replica) { - this.set("lastScrollPosition", primary?.scrollLeft); - - if (!this.ticking) { - window.requestAnimationFrame(() => { - replica.scrollLeft = this.lastScrollPosition; - this.set("ticking", false); - }); - - this.set("ticking", true); - } - } -}