mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
Merge pull request #2105 from LiFaytheGoblin/responsive-project-page/landscape-player
If in landscape format on mobile, switch to fullscreen mode
This commit is contained in:
commit
d0257ae43d
2 changed files with 23 additions and 2 deletions
|
@ -97,7 +97,6 @@ const PreviewPresentation = ({
|
|||
</a>
|
||||
<div className="title">
|
||||
{editable ?
|
||||
|
||||
<InplaceInput
|
||||
className="project-title"
|
||||
handleUpdate={onUpdate}
|
||||
|
|
|
@ -23,6 +23,8 @@ const sessionActions = require('../../redux/session.js');
|
|||
const navigationActions = require('../../redux/navigation.js');
|
||||
const previewActions = require('../../redux/preview.js');
|
||||
|
||||
const frameless = require('../../lib/frameless');
|
||||
|
||||
const GUI = require('scratch-gui');
|
||||
const IntlGUI = injectIntl(GUI.default);
|
||||
|
||||
|
@ -46,7 +48,8 @@ class Preview extends React.Component {
|
|||
'handleUpdate',
|
||||
'initCounts',
|
||||
'pushHistory',
|
||||
'renderLogin'
|
||||
'renderLogin',
|
||||
'setScreenFromOrientation'
|
||||
]);
|
||||
const pathname = window.location.pathname.toLowerCase();
|
||||
const parts = pathname.split('/').filter(Boolean);
|
||||
|
@ -63,6 +66,8 @@ class Preview extends React.Component {
|
|||
};
|
||||
this.getExtensions(this.state.projectId);
|
||||
this.addEventListeners();
|
||||
/* In the beginning, if user is on mobile and landscape, go to fullscreen */
|
||||
this.setScreenFromOrientation();
|
||||
}
|
||||
componentDidUpdate (prevProps) {
|
||||
if (this.props.sessionStatus !== prevProps.sessionStatus &&
|
||||
|
@ -106,9 +111,26 @@ class Preview extends React.Component {
|
|||
}
|
||||
addEventListeners () {
|
||||
window.addEventListener('popstate', this.handlePopState);
|
||||
window.addEventListener('orientationchange', this.setScreenFromOrientation);
|
||||
}
|
||||
removeEventListeners () {
|
||||
window.removeEventListener('popstate', this.handlePopState);
|
||||
window.removeEventListener('orientationchange', this.setScreenFromOrientation);
|
||||
}
|
||||
setScreenFromOrientation () {
|
||||
/*
|
||||
* If the user is on a mobile device, switching to
|
||||
* landscape format should make the fullscreen mode active
|
||||
*/
|
||||
const isMobileDevice = screen.height <= frameless.mobile || screen.width <= frameless.mobile;
|
||||
if (this.props.playerMode && isMobileDevice) {
|
||||
const isLandscape = screen.height < screen.width;
|
||||
if (isLandscape) {
|
||||
this.props.setFullScreen(true);
|
||||
} else {
|
||||
this.props.setFullScreen(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
getExtensions (projectId) {
|
||||
storage
|
||||
|
|
Loading…
Reference in a new issue