mirror of
https://gitlab.gnome.org/june/top-bar-organizer.git
synced 2026-01-12 01:03:51 +01:00
Refactor: Add ScrollManager instance to globalThis
Do this so that we don't have to pass the `ScrollManager` instance to each `PrefsBoxOrderItemRow` instance. This is useful for future refactors.
This commit is contained in:
parent
34ba8a58cd
commit
c54e24c151
2 changed files with 8 additions and 8 deletions
|
|
@ -31,21 +31,21 @@ var PrefsPage = GObject.registerClass({
|
|||
// Pass `this.get_first_child()` to the ScrollManager, since this
|
||||
// `PrefsPage` extends an `Adw.PreferencesPage` and the first child of
|
||||
// an `Adw.PreferencesPage` is the built-in `Gtk.ScrolledWindow`.
|
||||
this._scrollManager = new ScrollManager.ScrollManager(this.get_first_child());
|
||||
globalThis.scrollManager = new ScrollManager.ScrollManager(this.get_first_child());
|
||||
let controller = new Gtk.DropControllerMotion();
|
||||
controller.connect("motion", (_, x, y) => {
|
||||
// If the pointer is currently in the upper ten percent of this
|
||||
// widget, then scroll up.
|
||||
if (y <= this.get_allocated_height() * 0.1) this._scrollManager.startScrollUp();
|
||||
if (y <= this.get_allocated_height() * 0.1) scrollManager.startScrollUp();
|
||||
// If the pointer is currently in the lower ten percent of this
|
||||
// widget, then scroll down.
|
||||
else if (y >= this.get_allocated_height() * 0.9) this._scrollManager.startScrollDown();
|
||||
else if (y >= this.get_allocated_height() * 0.9) scrollManager.startScrollDown();
|
||||
// Otherwise stop scrolling.
|
||||
else this._scrollManager.stopScrollAll();
|
||||
else scrollManager.stopScrollAll();
|
||||
});
|
||||
controller.connect("leave", () => {
|
||||
// Stop scrolling on leave.
|
||||
this._scrollManager.stopScrollAll();
|
||||
scrollManager.stopScrollAll();
|
||||
});
|
||||
this.add_controller(controller);
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ var PrefsPage = GObject.registerClass({
|
|||
// Add the items of the given configured box order as
|
||||
// GtkListBoxRows.
|
||||
for (const item of boxOrder) {
|
||||
const listBoxRow = new PrefsBoxOrderItemRow.PrefsBoxOrderItemRow({}, this._scrollManager, item);
|
||||
const listBoxRow = new PrefsBoxOrderItemRow.PrefsBoxOrderItemRow({}, item);
|
||||
gtkListBox.append(listBoxRow);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue