Skip to content

Commit

Permalink
add is_mobile property to scrollbar to always display when mobile vie…
Browse files Browse the repository at this point in the history
…wport
  • Loading branch information
lenadax committed Aug 8, 2024
1 parent 544dc69 commit 7c369ae
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions js/src/mainmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class MainMenu extends ts.Events {
this.handle = this.handle.bind(this);
global_events.on('on_sidebar_resize', this.handle);
$(window).on('resize', this.handle);
this.handle();
}

hide_dropdowns() {
Expand Down
15 changes: 14 additions & 1 deletion js/src/scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export class Scrollbar extends ts.Motion {

ts.ajax.attach(this, this.elem);
ts.clock.schedule_frame(() => this.render());

const is_mobile = $(window).width() <= 768; // bs5 small/medium breakpoint
new ts.Property(this, 'is_mobile', is_mobile);
}

get position() {
Expand All @@ -51,10 +54,19 @@ export class Scrollbar extends ts.Motion {
this.elem.css('pointer-events', value ? 'all' : 'none');
}

on_is_mobile(val) {
if (val && this.contentsize > this.scrollsize) {
this.scrollbar.stop(true, true).show();
this.elem.off('mouseenter mouseleave', this.on_hover);
} else {
this.scrollbar.stop(true, true).hide();
this.elem.on('mouseenter mouseleave', this.on_hover);
}
}

bind() {
this.pointer_events = true;
this.elem.on('mousewheel wheel', this.on_scroll);
this.elem.on('mouseenter mouseleave', this.on_hover);
this.scrollbar.on('click', this.on_click);
this.set_scope(this.thumb, $(document), this.elem);
$(window).on('resize', this.on_resize);
Expand Down Expand Up @@ -111,6 +123,7 @@ export class Scrollbar extends ts.Motion {
}

on_resize() {
this.is_mobile = $(window).width() <= 768; // bs5 small/medium breakpoint
this.render();
}

Expand Down
15 changes: 14 additions & 1 deletion src/cone/app/browser/static/cone/cone.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ var cone = (function (exports, $, ts) {
new ts.Property(this, 'disabled', false);
ts.ajax.attach(this, this.elem);
ts.clock.schedule_frame(() => this.render());
const is_mobile = $(window).width() <= 768;
new ts.Property(this, 'is_mobile', is_mobile);
}
get position() {
return this._position || 0;
Expand All @@ -714,10 +716,19 @@ var cone = (function (exports, $, ts) {
set pointer_events(value) {
this.elem.css('pointer-events', value ? 'all' : 'none');
}
on_is_mobile(val) {
console.log(val);
if (val && this.contentsize > this.scrollsize) {
this.scrollbar.stop(true, true).show();
this.elem.off('mouseenter mouseleave', this.on_hover);
} else {
this.scrollbar.stop(true, true).hide();
this.elem.on('mouseenter mouseleave', this.on_hover);
}
}
bind() {
this.pointer_events = true;
this.elem.on('mousewheel wheel', this.on_scroll);
this.elem.on('mouseenter mouseleave', this.on_hover);
this.scrollbar.on('click', this.on_click);
this.set_scope(this.thumb, $(document), this.elem);
$(window).on('resize', this.on_resize);
Expand Down Expand Up @@ -767,6 +778,7 @@ var cone = (function (exports, $, ts) {
}
}
on_resize() {
this.is_mobile = $(window).width() <= 768;
this.render();
}
on_hover(evt) {
Expand Down Expand Up @@ -1086,6 +1098,7 @@ var cone = (function (exports, $, ts) {
this.handle = this.handle.bind(this);
global_events.on('on_sidebar_resize', this.handle);
$(window).on('resize', this.handle);
this.handle();
}
hide_dropdowns() {
this.elems.each((i, el) => {
Expand Down
Loading

0 comments on commit 7c369ae

Please sign in to comment.