1/** 2 * jQuery Target Scroller Plugin 3 * ã»aã¿ã°ã®hrefã§ããã·ã¥æå®ã§ã¹ã¯ãã¼ã«å¯è½ã§ã 4 * ã»aã¿ã°ä»¥å¤ã§ãã»ã¬ã¯ã¿ã¼æå®ã§ã¹ã¯ãã¼ã«å¯è½ã§ã 5 * ã»URLããã·ã¥ã§ã¹ã¯ãã¼ã«å¯è½ã§ã 6 * ã»ç§»åé度æå®(æéæå®)å¯è½ã§ã 7 * ã»ã¹ã¯ãã¼ã«ã¨ãã§ã¯ã(easing)æå®å¯è½ã§ã 8 * ã»ã¹ã¯ãã¼ã«å¾ã«ã³ã¼ã«ããã¯é¢æ°å®è¡å¯è½ã§ã 9 * 10 * 注æç¹ 11 * ã»æå®ããã¿ã¼ã²ãããåå¨ããªããã°ã¹ã¯ãã¼ã«ãã¾ãã(äºåã«ãã§ãã¯ãã¦å®è¡ãã¾ãã) 12 * ã»ã¹ã¯ãã¼ã«ä¸ã«ãã¦ã¹ãã¤ã¼ã«ã§ã¹ã¯ãã¼ã«ã忢ãã¾ã(æ£å¸¸ã«åæ¢ãã¾ã) 13 * 14 * ä½¿ç¨æ¹æ³ 15 * 弿°æå®ã¯ãªãã·ã§ã³ 16 * $(selector).targetScroller({ 17 * target: ã¹ã¯ãã¼ã«å ã®selector(aã¿ã°ã®hrefããåªå ããã¾ã), 18 * duration: ã¹ã¯ãã¼ã«ã«ãããæé[ms], 19 * easing: ã¹ã¯ãã¼ã«ã®ã¨ãã§ã¯ã(jQuery Easing Pluginãèªã¿è¾¼ããã¨ã§ä½¿ç¨ã§ãã¾ã), 20 * callback: ã¹ã¯ãã¼ã«å®äºæã«å¼ã³åºããã颿°(function() {ã»ã»ã»} ã§æå®ãã¾ã) 21 * }); 22 * 23 * 弿°ãªããªãããã©ã«ãåä½ 24 * $(selector).targetScroller(); 25 * 26 * ããã©ã«ãåä½ 27 * target: aã¿ã°ã®hrefã§æå®ããã¿ã¼ã²ãã(aã¿ã°ä»¥å¤ or hrefãªããªãã¹ã¯ãã¼ã«ãã¾ãã) 28 * duration: 1500[ms] 29 * easing: 'swing' 30 * callback: ãªã 31 * 32 * ããã·ã¥ããã®aã¿ã°ãã¹ã¦ã«é©ç¨ããæã¯ 33 * $('a[href^="#"]').targetScroller(); 34 * ã¨æå®ããã°å¯è½ã§ãã 35 */ 36;jQuery(document).ready(function($) { 37 var mousewheelevent = 'onwheel' in document ? 'wheel' : 'onmousewheel' in document ? 'mousewheel' : 'DOMMouseScroll'; 38 39 var targetScroller = function(elem, options) { 40 this.options = {}; 41 if (elem === null) { 42 // è¦ç´ ãnullãªãURLããã·ã¥ã«ããã¹ã¯ãã¼ã« 43 this.load(options); 44 } else { 45 if (this.init(elem, options)) { 46 // ã¿ã¼ã²ããã®ä½ç½®ãåå¾ã§ããã°ã¤ãã³ãç»é² 47 this.event(elem); 48 } 49 } 50 } 51 $.extend(targetScroller.prototype, { 52 defaults: { 53 duration: 1500, 54 easing: 'swing', 55 callback: function() {} 56 }, 57 // åæå 58 init: function(elem, options) { 59 var href = {}; 60 // aã¿ã°ã§ããã·ã¥ãããã°ã¿ã¼ã²ããã¨ãã¦ä½¿ç¨ãã 61 if (elem.hash !== '' && typeof elem.hash !== 'undefined') { 62 href['target'] = elem.hash; 63 } 64 // åªå é ä½ï¼ãªãã·ã§ã³æå® > ããã·ã¥ > ããã©ã«ã 65 this.options = $.extend({}, this.defaults, href, options); 66 if (typeof this.options.target !== 'undefined' && $(this.options.target).length) { 67 // ã¿ã¼ã²ãããæå®ããã¦ãã¦ä¸ã¤åå¨ãã¦ããã°ä½ç½®ãåå¾ 68 this.options = $.extend(this.options, $(this.options.target).eq(0).offset()); 69 return true; 70 } else { 71 return false; 72 } 73 }, 74 // ã¹ã¯ãã¼ã« 75 scroll: function(me) { 76 // ã¹ã¯ãã¼ã«åã«å度ã¿ã¼ã²ããã®åå¨ç¢ºèªããã³ä½ç½®åå¾ 77 if ($(this.options.target).length) { 78 // ã¿ã¼ã²ãããåå¨ãã¦ããã°ä½ç½®ãåå¾ 79 this.options = $.extend(this.options, $(this.options.target).eq(0).offset()); 80 // ãããã¼è¦ç´ ãæå®ããã¦ãã¦ãããã position: fixed ã ã£ãå ´åãã¹ã¯ãã¼ã«ä½ç½®ã«é«ããèæ ®ãã 81 if (typeof this.options.header !== 'undefined'){ 82 $header = $(this.options.header); 83 if ($header.length 84 && 'fixed' === $header.first().css('position') 85 ) { 86 me.options.top = me.options.top - $header.height(); 87 if (me.options.top < 0) { 88 me.options.top = 0; 89 } 90 } 91 } 92 me.body().animate( 93 { 94 scrollTop: me.options.top 95 }, 96 me.options.duration, 97 me.options.easing, 98 function() { 99 $(document).off(mousewheelevent); 100 (me.options.callback)(); 101 } 102 ); 103 104 $(document).on(mousewheelevent, function(e) { 105 me.stop(); 106 }); 107 } else { 108 } 109 }, 110 // ã¹ã¯ãã¼ã«åæ¢ 111 stop: function() { 112 this.body().stop(true); 113 $(document).off(mousewheelevent); 114 }, 115 // ãã¼ãæã®ã¹ã¯ãã¼ã« 116 load: function(options) { 117 if (location.hash) { 118 if (this.init({hash:location.hash}, options)) { 119 // ãã¼ã¸ãããããã¹ã¯ãã¼ã« 120 this.body().scrollTop(0); 121 this.scroll(this); 122 } 123 } 124 }, 125 // ã¹ã¯ãã¼ã«ãããè¦ç´ å¤å® 126 body: function() { 127// 以ä¸ã®å¤å®æ¹æ³ã§ã¯htmlãã¹ã¯ãã¼ã«ãããã©ã¦ã¶ã§ã¯ä¸é©å 128// $('html').scrollTop(5); 129// if ($('html').scrollTop() > 0) { 130// return $('html'); 131// } else { 132// return $('body'); 133// }
134 // htmlã¨bodyã®ä¸¡æ¹ãã¹ã¯ãã¼ã«ããã 135 return $('html, body'); 136 }, 137 // ã¤ãã³ãç»é² 138 event: function(elem) { 139 var me = this; 140 $(elem).on('click', function(e) { 141 me.scroll(me); 142 return false; 143 }); 144 } 145 }); 146 147 $.fn.targetScroller = function(options) { 148 return this.each(function() { 149 new targetScroller(this, options); 150 }); 151 }; 152 153 // URLããã·ã¥ã«ããã¹ã¯ãã¼ã« 154 $.targetScroller = function(options) { 155 new targetScroller(null, options); 156 } 157});
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.