Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import React, { Component } from "react";
  2.  
  3. const splitScreenPages = ['PAGE_CONFIRM', 'PAGE_QUIZ'];
  4.  
  5. class App extends Component {
  6.  
  7. componentDidUpdate(prevProps) {
  8. if (prevProps.page !== this.props.page) {
  9. if (splitScreenPages.includes(this.props.page)) this.setSplitScreen();
  10. if (!splitScreenPages.includes(this.props.page)) this.setLandscape();
  11. }
  12. }
  13.  
  14. setSplitScreen() {
  15. if (window.screen.orientation && window.screen.orientation.type !== 'portrait-primary') {
  16. window.screen.orientation.lock('portrait-primary');
  17. }
  18. }
  19.  
  20. setLandscape() {
  21. if (window.screen.orientation && window.screen.orientation.type !== 'landscape-primary') {
  22. window.screen.orientation.lock('landscape-primary');
  23. }
  24. }
  25.  
  26. // ...
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement