Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow slide away of header and footer even if there is no scroll possible in iframe #1141

Closed
Jaifroid opened this issue Oct 30, 2023 · 2 comments · Fixed by #1142
Closed
Assignees
Labels
bug-non-critical For bugs that it would be nice to fix rather than critical to fix user interface
Milestone

Comments

@Jaifroid
Copy link
Member

Once I have merged #1140 (#1139), it will finally be possible to address the issues in #337 and #435, as we'll have tested functions for hiding and showing the UI elements.

We'll need to handle mousedown and touchstart events on the window (possible also on the iframe), and test if there has been a "swipe down" or "swipe up" without a scroll. Boilerplate code would look something like this (untested):

let start = null;

function startHandler(e) {
  if (e.type === 'touchstart') {
    start = e.changedTouches[0];
  } else if (e.type === 'mousedown') {
    start = e;
  }
}

function endHandler(e) {
  let end;
  if (e.type === 'touchend') {
    end = e.changedTouches[0];
  } else if (e.type === 'mouseup') {
    end = e;
  }

  if (end.screenY - start.screenY > 0) {
    console.log('scrolling up');
    document.getElementById('status').innerHTML = 'scrolling up';
  } else if (end.screenY - start.screenY < 0) {
    console.log('scrolling down');
    document.getElementById('status').innerHTML = 'scrolling down';
  }
}

window.addEventListener('touchstart', startHandler);
window.addEventListener('mousedown', startHandler);
window.addEventListener('touchend', endHandler);
window.addEventListener('mouseup', endHandler);

This code listens for both touchstart/mousedown and touchend/mouseup events on the window. When a touch or mouse button press starts, it records the starting position. When the touch ends or mouse button is released, it checks if the end position is greater than or less than the start position to determine if the swipe was up or down.

@Jaifroid Jaifroid added user interface bug-non-critical For bugs that it would be nice to fix rather than critical to fix labels Oct 30, 2023
@Jaifroid Jaifroid added this to the v4.0 milestone Oct 30, 2023
@Jaifroid Jaifroid self-assigned this Oct 30, 2023
@Jaifroid
Copy link
Member Author

Touch events work, but not mouse events.

@Jaifroid
Copy link
Member Author

The wheel event works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-non-critical For bugs that it would be nice to fix rather than critical to fix user interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant