This file contains hidden or 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
function valBetween($val, $min, $max) { | |
return (Math.min($max, Math.max($min, $val))); | |
} |
This file contains hidden or 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
//count elements, return jQuery object if more than specified, else return empty object to 'stop' chaining | |
// usage: $('myElement').atLeast(2).fadeOut(); fadeOut will only execute on elements when 2 or more have been found | |
(function ($) { | |
"use strict"; | |
$.fn.atLeast = function (count) { | |
if (this.length >= count) { | |
//return the objects | |
return this; | |
} else { | |
//return empty jquery object to 'break' the chain |
This file contains hidden or 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 inertial Scroller v1.5 | |
* (c)2013 hnldesign.nl | |
* This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/. | |
* | |
* More information: http://www.hnldesign.nl/work/code/momentum-scrolling-using-jquery/ | |
*/ | |
/*jslint browser: true*/ | |
/*global $, jQuery*/ |
This file contains hidden or 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 Collision Detection - v1.0 - 1/7/2014 | |
* http://www.hnldesign.nl/work/code/collision-prevention-using-jquery/ | |
* | |
* Copyright (c) 2014 HN Leussink | |
* Dual licensed under the MIT and GPL licenses. | |
* | |
* Example: http://code.hnldesign.nl/demo/hnl.collision.detection.html | |
*/ |
This file contains hidden or 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
//26-5-2020 update: possibly shorter, and better, since 'click' now fires on a tap, and is not prevented by the previous script. | |
//Also: more concatenation. | |
$(document).on('touchstart, click', 'a.taphover', function (e) { | |
if (!$(this).hasClass('hover')) { e.preventDefault(); } | |
$('.taphover').not($(this).toggleClass('hover')).removeClass('hover'); | |
}); | |
//the previous version: | |
//taphover - a solution to the lack of hover on touch devices. |
This file contains hidden or 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
$.fn.isVisible = function() { | |
// Am I visible? | |
// Height and Width are not explicitly necessary in visibility detection, the bottom, right, top and left are the | |
// essential checks. If an image is 0x0, it is technically not visible, so it should not be marked as such. | |
// That is why either width or height have to be > 0. | |
var rect = this[0].getBoundingClientRect(); | |
return ( | |
(rect.height > 0 || rect.width > 0) && | |
rect.bottom > 0 && | |
rect.right > 0 && |
This file contains hidden or 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
/*! | |
* | |
* NEW VERSION AT https://github.com/c-kick/mobileConsole | |
* | |
* hnl.mobileConsole - javascript mobile console - v1.3.8 - 04/01/2021 | |
* Adds html console to webpage. Especially useful for debugging JS on mobile devices. | |
* Supports 'log', 'trace', 'info', 'warn', 'error', 'group', 'groupEnd', 'table', 'assert', 'clear' | |
* Inspired by code by Jakub Fiala (https://gist.github.com/jakubfiala/8fe3461ab6508f46003d) | |
* Licensed under the MIT license | |
* |
This file contains hidden or 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
/*! | |
* PRIME - Progressive-Responsive Image Enabler - v2.2.10 - 8/10/2020 | |
* http://code.hnldesign.nl/demo/hnl.prime.html | |
* | |
* Copyright (c) 2014-2020 HN Leussink | |
* Dual licensed under the MIT and GPL licenses. | |
* | |
* Example: http://code.hnldesign.nl/demo/hnl.prime.html | |
* | |
* Feature notes: |
This file contains hidden or 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
/** | |
* | |
* | |
* DEPRECATED, SEE NEW VERSION AT https://gist.github.com/c-kick/d359fce36257cf4c9fb5ea5f2c0033b6 | |
* | |
* | |
* JavaScript function prototype debouncer 3.0 - hnldesign.nl | |
* Based on code by Paul Irish and the original debouncing function from John Hann | |
* http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ | |
* Register deBouncer as a function prototype. |
This file contains hidden or 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
$.fn.checkStuck = function (className) { | |
$(this).each(function() { | |
var t = $(this); //preselect | |
t.toggleClass(className, (parseInt(t.css('top'), 10) === t[0].getBoundingClientRect().top)); | |
}); | |
} |
OlderNewer