1/** 2 * Plugin Name: jquery.SmoothScroll 3 * Plugin URI: http://2inc.org 4 * Description: ã¹ã ã¼ã¹ã¹ã¯ãã¼ã«ã§ãã¼ã¸å ç§»åããããã®ãã©ã°ã¤ã³ãæå®è¦ç´ ã®hashããã¨ã«ç§»åããã 5 * Version: 0.5.0 6 * Author: Takashi Kitajima 7 * Author URI: http://2inc.org 8 * Created: July 5, 2012 9 * Modified: February 8, 2016 10 * License: GPLv2+ 11 * 12 * easing: http://gsgd.co.uk/sandbox/jquery/easing/ 13 * @param { duration, easing, offset, hash ) 14 */ 15;( function( $ ) { 16 var methods = { 17 init : function( params ) { 18 var methods = { 19 scrollStop: function() { 20 targetBody.stop( true ); 21 }, 22 getTargetBody: function() { 23 if ( $( 'html' ).scrollTop() > 0 ) { 24 targetBody = $( 'html' ); 25 } else if ( $( 'body' ).scrollTop() > 0 ) { 26 targetBody = $( 'body' ); 27 } 28 return targetBody; 29 } 30 } 31 32 var defaults = { 33 duration: 1000, 34 easing : 'easeOutQuint', 35 offset : 0, 36 hash : true 37 }; 38 params = $.extend( defaults, params ); 39 40 var targetBody; 41 42 return this.each( function( i, e ) { 43 $( e ).on( 'click.SmoothScroll', function() { 44 var targetHash = this.hash; 45 var offset = $( targetHash ).eq( 0 ).offset(); 46 if ( !targetHash || offset === null || typeof offset === 'undefined' ) 47 return; 48 49 var wst = $( window ).scrollTop(); 50 if ( wst === 0 ) 51 $( window ).scrollTop( wst + 1 ); 52 53 targetBody = methods.getTargetBody(); 54 if ( typeof targetBody === 'undefined' ) 55 return; 56 targetBody.animate( 57 { 58 scrollTop: offset.top - params.offset 59 }, 60 params.duration, 61 params.easing, 62 function() { 63 if ( params.hash === true ) { 64 history.pushState( '', '', targetHash ); 65 } 66 } 67 ); 68 69 if ( window.addEventListener ) 70 window.addEventListener( 'DOMMouseScroll', methods.scrollStop, false ); 71 window.onmousewheel = document.onmousewheel = methods.scrollStop; 72 return false; 73 } ); 74 } ); 75 }, 76 off: function() { 77 $( this ).unbind( 'click.SmoothScroll' ); 78 } 79 } 80 81 $.fn.SmoothScroll = function( method ) { 82 if ( methods[method] ) { 83 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); 84 } else if ( typeof method === 'object' || ! method ) { 85 return methods.init.apply( this, arguments ); 86 } else { 87 $.error( 'Method ' + method + ' does not exist' ); 88 } 89 }; 90} )( 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.