Skip to content

blivesta/check-pls

Repository files navigation

CheckPLS

npm version Build Status

For find out if the target is 'Portrait' 'Landscape' or 'Square'.

Install

npm

$ npm install check-pls

CDN

<script src="https://unpkg.com/check-pls/check-pls.min.js"></script>

Usage

checkPls(element) // => string ['portrait'||'landscape'||'square']
checkPls(element, 'portrait') // => boolean
checkPls(element, 'landscape') // => boolean
checkPls(element, 'square') // => boolean

Example

html

<img src="image-portrait.jpg" />
<img src="image-landscape.jpg" />
<img src="image-square.jpg" />

use imagesLoaded $ npm install imagesloaded

import imagesLoaded from 'imagesloaded'
import checkPls from 'check-pls'

const elements = document.querySelectorAll('img')
const el = Array.apply(null, elements)
imagesLoaded(el, () => {
  el.map((node) => {
    const str = checkPls(node)
    const bool = checkPls(node, 'landscape')
    console.log(str)
    console.log(bool)
  })
})

Result:

// image-portrait.jpg
str => portrait
bool => false

// image-landscape.jpg
str => landscape
bool => true

// image-square.jpg
str => square
bool => false

License

Released under the MIT license.

About

For find out if the target is 'Portrait' 'Landscape' or 'Square'.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published