Skip to content

Commit

Permalink
Require swipe gesture to start at the margin
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Jul 16, 2022
1 parent a2c9af6 commit 19a724d
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/insipid_sphinx_theme/insipid/static/insipid-sidebar.js_t
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,28 @@
document.addEventListener('touchstart', event => {
if (event.touches.length > 1) { return; }
const touch = event.touches[0];
{%- if theme_rightsidebar|tobool %}
if (touch.clientX >= window.innerWidth - sidebar.offsetWidth) {
{%- else %}
if (touch.clientX <= sidebar.offsetWidth) {
{%- endif %}
touchstart = {
x: touch.clientX,
y: touch.clientY,
t: Date.now(),
};
if (sidebar_checkbox.checked) {
{%- if theme_rightsidebar|tobool %}
if (touch.clientX < window.innerWidth - sidebar.offsetWidth) {
{%- else %}
if (touch.clientX > sidebar.offsetWidth) {
{%- endif %}
return;
}
} else {
{%- if theme_rightsidebar|tobool %}
if (touch.clientX < window.innerWidth - 20) {
{%- else %}
if (touch.clientX > 20) {
{%- endif %}
return;
}
}
touchstart = {
x: touch.clientX,
y: touch.clientY,
t: Date.now(),
};
});

document.addEventListener('touchend', event => {
Expand Down

0 comments on commit 19a724d

Please sign in to comment.