fl_helper v1.6.5
fl_helper
Vanilla ES6 helper collection
npm install fl_helper
Usage
import * as flHelper from 'fl_helper'
Add import 'babel-polyfill'
if IE11 support is needed.
Functions
Checks
isEmpty
Detects if a value is truly empty ('', undefined or null). If emptyOutput contains a value, it will be returned if the original value is empty.
flHelper.isEmpty(value, emptyOutput = false)
detectIE
Detects Internet Explorer (any version).
flHelper.detectIE()
detectMobile
Detects mobile devices (screen width under 767px).
flHelper.detectMobile()
Listeners
onScroll
High performance and nonblocking scroll listener.
flHelper.onScroll(scrollTop => {}, container = window)
Extensions
objectAssignDeep
Performs a deep merge (merge with multiple dimensions) of objects and returns a new object. Useful for extending function options.
flHelper.objectAssignDeep(...objects)
scrollIntoViewCenter
Cross-browser function to center an element in the viewport. Also runs the smoothscroll polyfill. The default centerPosition is half the screen height.
flHelper.scrollIntoViewCenter(element, smooth = true, centerPosition = window.innerHeight >> 1)
outerHeight
Returns the element height including margins.
flHelper.outerHeight(element)
File handlers
uploadText
Creates a file upload dialog and returns text in promise.
flHelper.uploadText(type = 'application/json').then(text => {})
downloadText
Downloads text string as a file.
flHelper.downloadText(text, name, type = 'application/json')
Polyfills
smoothscroll
Polyfills window.scroll functions.
flHelper.polyfillSmoothScroll()