Created
November 4, 2015 14:52
-
-
Save zheeeng/112c22c5de1eeecf9a22 to your computer and use it in GitHub Desktop.
JS collection from stackoverflow.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery Bounce Effect on click no jQuery UI -- <http://stackoverflow.com/a/10363828/4494083> | |
// Require jQuery | |
function doBounce(element, times, distance, speed) { | |
for(var i = 0; i < times; i++) { | |
element.animate({marginTop: '-='+distance}, speed) | |
.animate({marginTop: '+='+distance}, speed); | |
} | |
} | |
// Is object empty? -- <http://stackoverflow.com/a/4994244/4494083> | |
// Speed up calls to hasOwnProperty | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
function isEmpty(obj) { | |
// null and undefined are "empty" | |
if (obj == null) return true; | |
// Assume if it has a length property with a non-zero value | |
// that that property is correct. | |
if (obj.length > 0) return false; | |
if (obj.length === 0) return true; | |
// Otherwise, does it have any properties of its own? | |
// Note that this doesn't handle | |
// toString and valueOf enumeration bugs in IE < 9 | |
for (var key in obj) { | |
if (hasOwnProperty.call(obj, key)) return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment