mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
client/css: make tab navigations scrollable on smaller screens
This commit is contained in:
@ -44,11 +44,18 @@ class HelpView {
|
||||
subsectionTemplates[section][subsection](ctx));
|
||||
}
|
||||
|
||||
views.replaceContent(this._hostNode, sourceNode);
|
||||
|
||||
for (let itemNode of
|
||||
sourceNode.querySelectorAll('.primary [data-name]')) {
|
||||
itemNode.classList.toggle(
|
||||
'active',
|
||||
itemNode.getAttribute('data-name') === section);
|
||||
if (itemNode.getAttribute('data-name') === section) {
|
||||
itemNode.parentNode.scrollLeft =
|
||||
itemNode.getBoundingClientRect().left -
|
||||
itemNode.parentNode.getBoundingClientRect().left
|
||||
}
|
||||
}
|
||||
|
||||
for (let itemNode of
|
||||
@ -56,9 +63,13 @@ class HelpView {
|
||||
itemNode.classList.toggle(
|
||||
'active',
|
||||
itemNode.getAttribute('data-name') === subsection);
|
||||
if (itemNode.getAttribute('data-name') === subsection) {
|
||||
itemNode.parentNode.scrollLeft =
|
||||
itemNode.getBoundingClientRect().left -
|
||||
itemNode.parentNode.getBoundingClientRect().left
|
||||
}
|
||||
}
|
||||
|
||||
views.replaceContent(this._hostNode, sourceNode);
|
||||
views.syncScrollPosition();
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,11 @@ class PostDetailView extends events.EventTarget {
|
||||
for (let item of this._hostNode.querySelectorAll('[data-name]')) {
|
||||
item.classList.toggle(
|
||||
'active', item.getAttribute('data-name') === ctx.section);
|
||||
if (item.getAttribute('data-name') === ctx.section) {
|
||||
item.parentNode.scrollLeft =
|
||||
item.getBoundingClientRect().left -
|
||||
item.parentNode.getBoundingClientRect().left
|
||||
}
|
||||
}
|
||||
|
||||
ctx.hostNode = this._hostNode.querySelector('.post-content-holder');
|
||||
|
@ -29,6 +29,11 @@ class TagView extends events.EventTarget {
|
||||
for (let item of this._hostNode.querySelectorAll('[data-name]')) {
|
||||
item.classList.toggle(
|
||||
'active', item.getAttribute('data-name') === ctx.section);
|
||||
if (item.getAttribute('data-name') === ctx.section) {
|
||||
item.parentNode.scrollLeft =
|
||||
item.getBoundingClientRect().left -
|
||||
item.parentNode.getBoundingClientRect().left
|
||||
}
|
||||
}
|
||||
|
||||
ctx.hostNode = this._hostNode.querySelector('.tag-content-holder');
|
||||
|
@ -24,11 +24,14 @@ class UserView extends events.EventTarget {
|
||||
_install() {
|
||||
const ctx = this._ctx;
|
||||
views.replaceContent(this._hostNode, template(ctx));
|
||||
|
||||
for (let item of this._hostNode.querySelectorAll('[data-name]')) {
|
||||
item.classList.toggle(
|
||||
'active', item.getAttribute('data-name') === ctx.section);
|
||||
if (item.getAttribute('data-name') === ctx.section) {
|
||||
item.className = 'active';
|
||||
} else {
|
||||
item.className = '';
|
||||
item.parentNode.scrollLeft =
|
||||
item.getBoundingClientRect().left -
|
||||
item.parentNode.getBoundingClientRect().left
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user