File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -52,9 +52,26 @@ jQuery(document).on('ready', function() {
5252 /* -------------------------------------
5353 ADD ANIMATIONS TO SECTION SCROLL
5454 -------------------------------------- */
55- $ ( 'a[href*=\\#]' ) . on ( 'click' , function ( event ) {
56- event . preventDefault ( ) ;
57- $ ( 'html,body' ) . animate ( { scrollTop :$ ( this . hash ) . offset ( ) . top } , 700 ) ;
55+ function ea_scroll ( hash ) {
56+ var target = $ ( hash ) ;
57+ target = target . length ? target : $ ( '[name=' + this . hash . slice ( 1 ) + ']' ) ;
58+ if ( target . length ) {
59+ var top_offset = 0 ;
60+ $ ( 'html,body' ) . animate ( {
61+ scrollTop : target . offset ( ) . top - top_offset
62+ } , 1000 ) ;
63+ return false ;
64+ }
65+ }
66+ // -- Smooth scroll on pageload
67+ if ( window . location . hash ) {
68+ ea_scroll ( window . location . hash ) ;
69+ }
70+ // -- Smooth scroll on click
71+ $ ( 'a[href*="#"]:not([href="#"]):not(.no-scroll)' ) . click ( function ( ) {
72+ if ( location . pathname . replace ( / ^ \/ / , '' ) == this . pathname . replace ( / ^ \/ / , '' ) || location . hostname == this . hostname ) {
73+ ea_scroll ( this . hash ) ;
74+ }
5875 } ) ;
5976
6077 /* -------------------------------------
You can’t perform that action at this time.
0 commit comments