1/** 2 2sic sync-height jQuery plugin 3 https://github.com/raphael-m/syncHeightResponsive/ 4 Syncs the height of elements that are displayed beneath each other (by comparing their offset top) 5 Include also the waitForImages plugin to ensure correct behaviour when elements contain images 6**/ 7 8(function ($) { 9 10 $.fn.syncHeightResponsive = function (config) { 11 12 // Self will contain the elements to sync 13 var self = $(this); 14 15 // The main function - run height sync 16 var triggerHeightSync = function () { 17 18 // Group elements by getting the offset top value 19 var previousTop = 0, 20 elementGroups = {}; 21 22 $(self).each(function (i, e) { 23 24 var top = Math.round($(e).offset().top); 25 26 if (!elementGroups[top]) 27 elementGroups[top] = []; 28 elementGroups[top].push(e); 29 30 }); 31 32 // All groups are created, sync height for each group separately 33 $.each(elementGroups, function (k, elements) { 34 35 // Get maximal height value 36 var maxHeight = 0; 37 $(elements).css('height', ''); 38 39 $.each(elements, function (i, element) { 40 maxHeight = Math.max(maxHeight, $(element).height()); 41 }); 42 43 $(elements).height(maxHeight); 44 45 }); 46 47 } 48 49 // Call sync wrapped in a timeout to make sure other scripts that could modify the height have already run 50 window.setTimeout(function () { 51 triggerHeightSync(); 52 }, 0); 53 54 $(window).load(function () { 55 triggerHeightSync(); 56 }); 57 58 if ($.fn.waitForImages) { 59 $(self).waitForImages(triggerHeightSync); 60 } 61 62 var ticking = false; 63 var update = function() { 64 ticking = false; 65 triggerHeightSync(); 66 }; 67 68 $(window).resize(function () { 69 if (!ticking) 70 window.requestAnimationFrame(update); 71 ticking = true; 72 }); 73 74 }; 75})(jQuery); 76 77/* Polyfill for requestAnimationFrame 78 Source: http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ 79*/ 80(function() { 81 if(window.requestAnimationFrame) 82 return; 83 84 var lastTime = 0; 85 var vendors = ['webkit', 'moz']; 86 for(var x = 0; x < vendors.length; ++x) { 87 window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; 88 window.cancelAnimationFrame = 89 window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; 90 } 91 92 window.requestAnimationFrame = function(callback, element) { 93 var currTime = new Date().getTime(); 94 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 95 var id = window.setTimeout(function() { callback(currTime + timeToCall); }, 96 timeToCall); 97 lastTime = currTime + timeToCall; 98 return id; 99 }; 100 101}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.