UI utilities & helpers
Clone or download
desandro 🐞 v2.0.7 add back methodTimeout in debounceMethod
Fixes bug with multiple instances using the same timeout
Latest commit 72feb9f Jan 25, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
test 🛠 makeArray( null ) returns []; #6 May 17, 2017
.gitignore Initial commit; port over Flickity utils Jan 22, 2015
README.md Merge branch 'master' into v2 Jan 8, 2016
package.json 🐞 v2.0.7 add back methodTimeout in debounceMethod Jan 25, 2018
utils.js 🐞 v2.0.7 add back methodTimeout in debounceMethod Jan 25, 2018


Fizzy UI utils

UI utility & helper functions

Used in Flickity, Isotope, Masonry, Draggabilly


Bower: bower install fizzy-ui-utils --save

npm: npm install fizzy-ui-utils --save


// fizzyUIUtils is the browser global
var utils = fizzyUIUtils;

// ---- ---- //

utils.extend( a, b )
// extend object

utils.modulo( num, div )
// num [modulo] div

utils.makeArray( obj )
// make array from object

utils.removeFrom( ary, obj )
// remove object from array

utils.getParent( elem, selector )
// get parent element of an element, given a selector string

utils.getQueryElement( elem )
// if elem is a string, use it as a selector and return element

Class.prototype.handleEvent = utils.handleEvent;
// enable Class.onclick when element.addEventListener( 'click', this, false )

utils.filterFindElements( elems, selector )
// iterate through elems, filter and find all elements that match selector

utils.debounceMethod( Class, methodName, threhold )
// debounce a class method

utils.docReady( callback )
// trigger callback on document ready

utils.toDashed( str )
// 'camelCaseString' -> 'camel-case-string'

utils.htmlInit( Class, namespace )
// on document ready, initialize Class on every element
// that matches js-namespace
// pass in JSON options from element's data-options-namespace attribute

MIT license. Have at it.

By Metafizzy