check-pls
v0.1.0
Published
For find out if the target is 'Landscape' 'Portrait' or 'Square'.
Downloads
15
Readme
CheckPLS
For find out if the target is 'Portrait' 'Landscape' or 'Square'.
Install
npm
$ npm install check-plsCDN
<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 => falseLicense
Released under the MIT license.
