1/*-------------------------------- 2 åºåã®ããã¼ã 3 -------------------------------*/ 4;(function ($) { 5 'use strict'; 6 7 $(function () { 8 var $main = $('main'); // ã¡ã¤ã³ã«ã©ã ã®ID 9 var $side = $('#side aside'); // ãµã¤ããã¼ã®ID 10 var $sticky = $('#scrollad'); // åºåãå ãè¦ç´ ã®ID 11 12 if ($main.length === 0 || $side.length === 0 || $sticky.length === 0) { 13 return; 14 } 15 16 var $window = $(window); 17 18 var measureTrigger = function () { 19 var $measure; 20 var top; 21 var measurement; 22 23 $measure = $('<div />').css({ 24 visibility : 'hidden' 25 }); 26 27 $sticky.before($measure); 28 29 top = $measure.offset().top; 30 31 measurement = { 32 top : top, 33 bottom: top + $sticky.outerHeight() 34 }; 35 36 $measure.remove(); 37 38 return measurement; 39 }; 40 41 var isStickable = function () { 42 // 960px以ä¸ã¯åºå® 43 if (window.matchMedia && window.matchMedia('screen and (min-width: 960px)').matches) { 44 return true; 45 } 46 47 return false; 48 }; 49 50 var stick = function (top) { 51 var sideWidth = $side.outerWidth(); 52 var sideLeft = $side.offset().left; 53 54 top = top || 0; 55 56 $sticky.css({ 57 position: 'fixed', 58 width: sideWidth, 59 top: top, 60 left: sideLeft, 61 margi: 0 62 }); 63 64 $side.addClass('is-fixed'); 65 }; 66 67 var unstick = function () { 68 $sticky.css({ 69 position: 'static', 70 width: '', 71 top: '', 72 left: '', 73 margin: '' 74 }); 75 76 $side.removeClass('is-fixed'); 77 }; 78 79 var adjust = function () { 80 var currentTop = $window.scrollTop(); 81 var trigger = measureTrigger(); 82 var mainBottom= $main.offset().top + $main.outerHeight(); 83 var isStuck = (currentTop > trigger.top) && (trigger.bottom < mainBottom); 84 var bottomTrigger; 85 var stickyTop; 86 87 if (isStickable() && isStuck) { 88 bottomTrigger = mainBottom - $sticky.outerHeight(); 89 stickyTop = (currentTop < bottomTrigger) ? 0 : (bottomTrigger - currentTop); 90 91 stick(stickyTop); 92 } else { 93 unstick(); 94 } 95 }; 96 97 $window.on('load', function() {
98 adjust(); 99 100 setTimeout(function() { 101 adjust(); 102 }, 1000); // èªã¿è¾¼ã¿å®äºå¾ã®èª¿æ´ 103 }); 104 105 $window.on('scroll', function () { 106 adjust(); 107 }); 108 109 $window.on('resize', function() { 110 adjust(); 111 }); 112 }); 113})(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.