/* revealator jquery plugin revealator is a jquery-based plugin for adding effects to elements that enter the window. it's simple, and easy to use. version 1.0, jan 11th, 2016 by ingi p. jacobsen the mit license (mit) copyright (c) 2016 faroe media permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "software"), to deal in the software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions: the above copyright notice and this permission notice shall be included in all copies or substantial portions of the software. the software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. */ window.revealator = { timer: null, busy: false }; $(function () { var refreshrevealator = function () { var $window = $(window); var i = 0; var window_top = 0; var window_bottom = $window.height(); $('*[class^="revealator"]').each(function () { i++; var element = this; var $element = $(element); var element_bounding = element.getboundingclientrect(); var position_class = undefined; if (element_bounding.top > window_bottom && element_bounding.bottom > window_bottom) { position_class = 'revealator-below'; } else if (element_bounding.top < window_bottom && element_bounding.bottom > window_bottom) { position_class = 'revealator-partially-below' } else if (element_bounding.top < window_top && element_bounding.bottom > window_top) { position_class = 'revealator-partially-above' } else if (element_bounding.top < window_top && element_bounding.bottom < window_top) { position_class = 'revealator-above'; } else { position_class = 'revealator-within'; } if (!$element.hasclass(position_class)) { $element.removeclass('revealator-below revealator-partially-below revealator-partially-above revealator-above revealator-within'); $element.addclass(position_class); } }); }; $(window).bind('scroll resize load ready', function () { if (!window.revealator.busy) { window.revealator.busy = true; settimeout(function () { window.revealator.busy = false; refreshrevealator(); }, 150); } }); });