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

toggleFullscreen #827

Closed
haldo98 opened this issue Jan 8, 2023 · 5 comments
Closed

toggleFullscreen #827

haldo98 opened this issue Jan 8, 2023 · 5 comments
Labels
Milestone

Comments

@haldo98
Copy link

haldo98 commented Jan 8, 2023

Describe your problem

Hi Damien, Thank You for your great work.

I was playing with the new custom keyboard options...
and I defined a key (among the others) for toggling on/off the fullscreen mode

'f': (viewer) => viewer.toggleFullscreen(),

But it seems to work only one time. After toggling fullscreen mode on and then off ... all the other keys I defined (fullscreen included) stop working.

Am I doing something wrong or maybe there's an issue....

because if I manually hit the fullscreen button on the navbar (fullscreen ON) the other keys work again.

check the demo.

Online demo URL

https://www.tadini.it/photosphere/andolla/PS_andolla.html

Photo Sphere Viewer version

5.0.2

Plugins loaded

autorotate compass

Additional context

No response

@mistic100
Copy link
Owner

The keyboard control is designed only for fullscreen use. You force enable it with viewer.startKeyboardControl() but once fullscreen is disabled, so is the keyboard.

/**
* Handles fullscreen events
*/
private __onFullscreenChange() {
const fullscreen = this.viewer.isFullscreenEnabled();
if (this.config.keyboard) {
if (fullscreen) {
this.viewer.startKeyboardControl();
} else {
this.viewer.stopKeyboardControl();
}
}
this.viewer.dispatchEvent(new FullscreenEvent(fullscreen));
}

And it is was the doc says https://photo-sphere-viewer.js.org/guide/config.html#advanced-options


If you want a global keyboard listener, do it yourself

window.addEventListener('keydown', (event) => {
  console.log(event.key);
}, { passive: false });

@mistic100
Copy link
Owner

I will add an option to choose if the keyboard is only enabled in fullscreen or always.

@haldo98
Copy link
Author

haldo98 commented Jan 8, 2023

I will add an option to choose if the keyboard is only enabled in fullscreen or always.

well that will solve it.
Thank You.

mistic100 added a commit that referenced this issue Jan 8, 2023
@mistic100 mistic100 added this to the 5.1.0 milestone Jan 8, 2023
@mistic100
Copy link
Owner

keyboard: 'always',
keyboardActions: {
...PhotoSphereViewer.DEFAULTS.keyboardActions,
f: (viewer) => viewer.toggleFullscreen(),
h: (viewer) => {
if (viewer.panel.isVisible('help')) {
viewer.panel.hide();
} else {
viewer.panel.show({
id: 'help',
content: 'Help content',
});
}
},
},

will have to wait for the next minor version because it can break some configs (though general retrocompatibility should work)

@github-actions
Copy link

This feature/bug fix has been released in version 5.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants