1 2 var $bubbles = $('.bubbles'); 3 4function bubbles() { 5 6 // Settings 7 var min_bubble_count = 20, // Minimum number of bubbles 8 max_bubble_count = 60, // Maximum number of bubbles 9 min_bubble_size = 3, // Smallest possible bubble diameter (px) 10 max_bubble_size = 12; // Maximum bubble blur amount (px) 11 12 // Calculate a random number of bubbles based on our min/max 13 var bubbleCount = min_bubble_count + Math.floor(Math.random() * (max_bubble_count + 1)); 14 15 // Create the bubbles 16 for (var i = 0; i < bubbleCount; i++) { 17 $bubbles.append('<div class="bubble-container"><div class="bubble"></div></div>'); 18 } 19 20 // Now randomise the various bubble elements 21 $bubbles.find('.bubble-container').each(function(){ 22 23 // Randomise the bubble positions (0 - 100%) 24 var pos_rand = Math.floor(Math.random() * 101); 25 26 // Randomise their size 27 var size_rand = min_bubble_size + Math.floor(Math.random() * (max_bubble_size + 1)); 28 29 // Randomise the time they start rising (0-15s) 30 var delay_rand = Math.floor(Math.random() * 16); 31 32 // Randomise their speed (3-8s) 33 var speed_rand = 3 + Math.floor(Math.random() * 9); 34 35 // Random blur 36 var blur_rand = Math.floor(Math.random() * 3); 37 38 // Cache the this selector 39 var $this = $(this); 40 41 // Apply the new styles 42 $this.css({ 43 'left' : pos_rand + '%', 44 45 '-webkit-animation-duration' : speed_rand + 's', 46 '-moz-animation-duration' : speed_rand + 's', 47 '-ms-animation-duration' : speed_rand + 's', 48 'animation-duration' : speed_rand + 's', 49 50 '-webkit-animation-delay' : delay_rand + 's', 51 '-moz-animation-delay' : delay_rand + 's', 52 '-ms-animation-delay' : delay_rand + 's', 53 'animation-delay' : delay_rand + 's', 54 55 '-webkit-filter' : 'blur(' + blur_rand + 'px)', 56 '-moz-filter' : 'blur(' + blur_rand + 'px)', 57 '-ms-filter' : 'blur(' + blur_rand + 'px)', 58 'filter' : 'blur(' + blur_rand + 'px)', 59 }); 60 61 $this.children('.bubble').css({ 62 'width' : size_rand + 'px', 63 'height' : size_rand + 'px' 64 }); 65 66 }); 67} 68 69// In case users value their laptop battery life 70// Allow them to turn the bubbles off 71$('.bubble-toggle').click(function(){ 72 if($bubbles.is(':empty')) { 73 bubbles(); 74 $bubbles.show(); 75 $(this).text('Bubbles Off'); 76 } else { 77 $bubbles.fadeOut(function(){ 78 $(this).empty(); 79 }); 80 $(this).text('Bubbles On'); 81 } 82 83 return false; 84}); 85 86bubbles();
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.