Socket
Socket
Sign inDemoInstall

mobile-orientation

Package Overview
Dependencies
16
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mobile-orientation

Detect Mobile Portrait/Landscape on resize. See [demo](https://adi518.github.io/mobile-orientation/). ## Browser compatibility See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia). ## Install ``` npm install --save mobile-ori


Version published
Weekly downloads
219
decreased by-31.13%
Maintainers
1
Install size
4.36 MB
Created
Weekly downloads
 

Changelog

Source

2.1.2

  • Fix IE11 (and possible IE10) exceptions.

Readme

Source

Mobile-Orientation

Detect Mobile Portrait/Landscape on resize. See demo.

Browser compatibility

See MDN.

Install

npm install --save mobile-orientation

Usage

import { MobileOrientation } from 'mobile-orientation'

const orientation = new MobileOrientation()

console.log(orientation.state) // 'portrait'

orientation.on('resize', state => console.log(state)) // portrait or landscape
orientation.on('portrait', state => console.log(state)) // portrait
orientation.on('landscape', state => console.log(state)) // landscape

Alternatively, the state can be utilized within a computed property, a la Vue.js Computed Property.

// Vue Component
export default {
    data() {
        return {
            orientation: new MobileOrientation()
        }
    },
    computed: {
        isPortrait() {
            return this.orientation.isPortrait
        },
        isLandscape() {
            return this.orientation.isLandscape
        }
    }
}

Options

debounceTime
  • Type: Number
  • Default: 50
  • Format: Milliseconds
  • Description: Time to wait before invoking detection.
withTouch
  • Type: Boolean
  • Default: false
  • Description: Include touch-device when testing mobile.
portraitMediaQuery

See MDN for media queries syntax.

  • Type: String
  • Default: screen and (max-device-aspect-ratio: 1/1)
  • Format: CSS Media Query
  • Description: CSS Media Query to test against portrait.
landscapeMediaQuery

See MDN for media queries syntax.

  • Type: String
  • Default: all
  • Format: CSS Media Query
  • Description: CSS Media Query to test against landscape.

FAQs

Last updated on 09 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc