1/** 2 * Creates an observer to add the in-view class to blocks. 3 * 4 * @author Orbit Media Studios 5 */ 6if( !! window.IntersectionObserver ) { 7 8 const options = { 9 //threshold : 0.25 // Percentage of the element is in view. 10 rootMargin: '0px 0px -200px 0px' // distance from bottom window 11 } 12 13 let observer = new IntersectionObserver( 14 ( entries, observer ) => { 15 entries.forEach( entry => { 16 17 // Checks if the element is actually intersecting. 18 if ( entry.isIntersecting ) { 19 20 // Adds 'active' class to the parent element. 21 entry.target.classList.add( 'active' ); 22 } 23 24 } ); 25 }, options ); 26 27 document.querySelectorAll( '.pageblock' ).forEach( block => { 28 observer.observe( block ); 29 } ); 30 31} else { 32 33 // Fallback (IE11). Just sets active on all columns on load. 34 var pageblocks = document.querySelectorAll( '.pageblock' ); 35 [].forEach.call(pageblocks, function(pageblock) { 36 pageblock.classList.add('active') 37 }); 38 39} 40 41/** 42 * Check for transition blocks on the page and adjust them accordingly. 43 * 44 * @author Orbit Media Studios 45 */ 46(function($) { 47 48 $(window).on('load resize scroll', function() { 49 oms_check_transition_blocks(); 50 }); 51 52 /** 53 * Moves a block between the prev/next elements by calculating and updating the margins/paddings for prev/next elements 54 */ 55 function oms_check_transition_blocks() { 56 57 $('.pageblock.transition_block').each(function () { 58 59 // Set these to whatever you want the padding on the prev/next sections to be 60 var prev_section_padding = 100; 61 var next_section_padding = 100; 62 63 // Current block 64 var $transition_block = $(this); 65 66 // Checking the previous element. 67 // If a transition block starts the page blocks off, add padding to previous element, likely a banner/header. 68 var $prev_element= ''; 69 70 if ( $transition_block.prev('.banner_container').length >= 1 ) { 71 $prev_element = $transition_block.prev('.banner_container'); 72 } 73 else if ( $transition_block.prev('.carousel').length >=1) { 74 $prev_element = $transition_block.prev('.carousel'); 75 } 76 else if ( $transition_block.prev('.pageblock').length >=1) { 77 $prev_element = $transition_block.prev('.pageblock'); 78 79 if( $prev_element.hasClass('transition_block') ) { 80 $transition_block.removeClass('transition_block'); 81 return true; 82 } 83 } 84 85 86 // Checks for the next element. 87 var $next_element = ''; 88 89 // If the next block is a transition block, remove the class from current transition block. 90 // Maybe the next transition block will be ok 91 // can't have two transition blocks next to each other. 92 if ( $transition_block.next('.pageblock').length >= 1 ) { 93 $next_element = $transition_block.next('.pageblock'); 94 } 95 else { 96 $next_element = $('.site-footer'); 97 // next_section_padding = 0; 98 } 99 100 if ( $transition_block.prev('.pageblock--oms-hero').length >=1) { 101 $transition_block.removeClass('transition_block').addClass('faux-transition'); 102 $next_bg = $next_element.hasClass('bg-color-gray') ? 'gray' : 'white'; 103 $transition_block.attr('data-next-bg', 'gray'); 104 return true; 105 } 106 107 // Reset initial values before adding the padding to offset the transition container 108 if ($prev_element) { 109 $prev_element.css('padding-bottom', prev_section_padding); 110 } 111 $transition_block.css('margin-top', '0'); 112 if ($next_element) { 113 $next_element.css('padding-top', next_section_padding); 114 $next_element.css('margin-top', '0'); 115 } 116 117 // New margins and padding
118 var padding_to_add = Math.ceil($transition_block.height() / 2); 119 var new_margin = padding_to_add; 120 var new_padding_prev = prev_section_padding + padding_to_add; 121 var new_padding_next = next_section_padding + padding_to_add; 122 123 // Element before transition block 124 if ($prev_element) { 125 $prev_element.css('padding-bottom', new_padding_prev); 126 } 127 128 // Transition block 129 $transition_block.css('margin-top', -1 * (new_margin) ); 130 131 // Element after transition block 132 if ($prev_element) { 133 $next_element.css('padding-top', new_padding_next); 134 $next_element.css('margin-top', -1 * new_margin); 135 } 136 }); 137 } 138 139})(jQuery);
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.