check-pls

0.1.0 • Public • Published

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://npmcdn.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.

Package Sidebar

Install

npm i check-pls

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • blivesta