Use like this:
// Call the function with the following parameters:
onViewport(selector, classNameToBeAdded, offset, callback);
// Example:
onViewport(".about-section", "active", 300, function() {
console.log("This is not a drill.")
});Use like this:
// Call the function with the following parameters:
onViewport(selector, classNameToBeAdded, offset, callback);
// Example:
onViewport(".about-section", "active", 300, function() {
console.log("This is not a drill.")
});| ("0" + h).slice (-2); // devolverá "01" si h=1; "12" si h=12 | |
| ("00" + h).slice (-3); // "001" si h=1; "012" si h=12;"123" si h = 123 |
| // Returns a random integer between min (included) and max (included) | |
| function getRandomInt(min, max) { | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } | |
| getRandomInt(5, 10); // -> 5, 8, 6, 10 |
| var data = {'foo': 'bar'}; | |
| if(data.hasOwnProperty("foo")){ | |
| console.log(data.foo); | |
| } | |
| if(typeof data == 'object'){ | |
| //console.log(e) | |
| } |
| var flattenObject = function(ob) { | |
| return Object.keys(ob).reduce(function(toReturn, k) { | |
| if (Object.prototype.toString.call(ob[k]) === '[object Date]') { | |
| toReturn[k] = ob[k].toString(); | |
| } | |
| else if ((typeof ob[k]) === 'object' && ob[k]) { | |
| var flatObject = flattenObject(ob[k]); | |
| Object.keys(flatObject).forEach(function(k2) { |
| .mixin (@width,@height,@x,@y) { | |
| width: @width*1px; | |
| height: @height*1px; | |
| margin: @x*(-1px) @y*(-1px); | |
| } | |
| .element{ | |
| .mixin(100,100,25,25); | |
| } |
| /** | |
| * Markdown Quote to Clipboard | |
| */ | |
| var mo = { | |
| version: 1, | |
| btnId: 'clipboard-btn-dceaeae8-1557-4454-883c-05ae99312192', | |
| id:'clipboard-dceaeae8-1557-4454-883c-05ae99312192', | |
| textareaId: 'clipboard-textarea-dceaeae8-1557-4454-883c-05ae99312192', | |
| uniqueId: 'clipboard-script-dceaeae8-1557-4454-883c-05ae99312192', |
| // http://jsbin.com/vurimiguci/edit?html,js,console,output | |
| var links = document.querySelectorAll( 'a' ); | |
| for (var i = 0, l = links.length; i < l; i++) { | |
| if (links[i].hostname != window.location.hostname) { | |
| links[i].target = '_blank'; | |
| } | |
| } |
Note the trailing white-space. Some editors will unfortunately automatically strip this.
input(type='button')| // http://jsbin.com/tuniligupi/edit?js,console | |
| var jsonObj = [ | |
| { | |
| "title": "pineapple", | |
| "uid": "ab982d34c98f" | |
| }, | |
| { | |
| "title": "carrots", | |
| "uid": "6f12e6ba45ec" |