Skip to content

Commit

Permalink
Fix region resizing and make swipe > 2/3 screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Nov 1, 2023
1 parent 8ee8cb8 commit ef29fdc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion i18n/en.jsonp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion i18n/es.jsonp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion i18n/fr.jsonp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ <h3 id="removeNavbars" data-i18n="about-remove-navbars">Removing navigation bars
<p data-i18n="about-remove-navbars-para1">
The default setting is for the top and bottom navigation bars to slide away when you scroll down and slide back when you scroll up. However,
in some ZIM archives, e.g. PhET, it is not possible to scroll, and the navigation bars can obscure some content. In this case, in most browsers
you can swipe up or down on the window (with touch or with the mouse wheel/touchpad) to toggle the display of the navigation bars. In all browsers,
you can also use the <code>Ctrl/Cmd</code> + <code>UpArrow</code>/<code>DownArrow</code> keys.
you can swipe decisively up or down on the window (with touch or with the mouse wheel/touchpad) to toggle the display of the navigation bars.
In all browsers, you can also use the <code>Ctrl/Cmd</code> + <code>UpArrow</code>/<code>DownArrow</code> keys.
</p>
<p style="text-align: right"><a href="#contents" data-i18n="about-back-contents">↑ Back to Contents</a></p>

Expand Down
15 changes: 9 additions & 6 deletions www/js/lib/uiUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import settingsStore from './settingsStore.js';
import translateUI from './translateUI.js';

// Placeholders for the article container and the article window
const region = document.getElementById('search-article');
const header = document.getElementById('top');
const footer = document.getElementById('footer');

Expand All @@ -48,7 +47,6 @@ function hideSlidingUIElements () {
const iframeHeight = parseFloat(articleContainer.style.height.replace('px', ''));
articleContainer.style.height = iframeHeight + headerHeight + 'px';
footer.style.transform = 'translateY(' + footerHeight + 'px)';
region.style.height = window.innerHeight + headerHeight + 10 + 'px';
}

/**
Expand All @@ -64,7 +62,6 @@ function showSlidingUIElements () {
const headerStyles = getComputedStyle(document.getElementById('top'));
const headerHeight = parseFloat(headerStyles.height) + parseFloat(headerStyles.marginBottom);
articleContainer.style.height = window.innerHeight - headerHeight + 'px';
region.style.height = window.innerHeight + 10 + 'px';
}, 200);
}

Expand All @@ -79,14 +76,19 @@ function scroller (e) {
// windowIsScrollable gets set and reset in slideAway()
if (windowIsScrollable && e.type === 'wheel') return;
const newScrollY = articleContainer.contentWindow.pageYOffset;
// If it's a wheel event and we're actually scrolling, get out of the way and let the scroll event handle it
// If it's a non-scroll event and we're actually scrolling, get out of the way and let the scroll event handle it
if ((/^touch|^wheel|^keydown/.test(e.type)) && newScrollY !== oldScrollY) {
oldScrollY = newScrollY;
return;
}
if (e.type === 'touchstart') {
oldTouchY = e.touches[0].screenY;
return;
}
scrollThrottle = true;
// Call the main function
slideAway(e);
// Set timeouts for the throttle
let timeout = 250;
if (/^touch|^keydown/.test(e.type)) {
scrollThrottle = false;
Expand All @@ -106,6 +108,7 @@ if ('MSBlobBuilder' in window) {
}

let oldScrollY = 0;
let oldTouchY = 0;
let timeoutResetScrollable;
let windowIsScrollable = false;

Expand Down Expand Up @@ -141,8 +144,8 @@ function slideAway (e) {
hideOrShow = showSlidingUIElements;
}
if (e.type === 'touchend') {
delta = Math.abs(e.changedTouches[0].screenY);
if (delta > 50) {
delta = Math.abs(oldTouchY - e.changedTouches[0].screenY);
if (delta > articleContainer.contentWindow.innerHeight / 1.5) {
hideOrShow();
}
} else if (e.type === 'wheel') {
Expand Down

0 comments on commit ef29fdc

Please sign in to comment.