Skip to content

iambumblehead/screenlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

screenlock

// https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation

const screenlock = module.exports = (o => {

  let orientation = typeof screen === 'object'
        && (screen.orientation ||
            screen.mozOrientation ||
            screen.msOrientation);

  return {
    lock : (type='landscape-primary') => {
      if (orientation && orientation.lock) {
        try {
          orientation.lock(type);
        } catch (e) {}
      }
    },

    unlock : () => {
      if (orientation && orientation.unlock) {
        try {
          orientation.unlock();
        } catch (e) {}
      }
    }
  };

  
})({});

About

try screenlock.lock and screenlock.unlock without errors

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published