@@ -46,35 +46,35 @@ function get_center_of_element( el ){
4646return $el . width ( ) / 2 + $el . position ( ) . left ;
4747}
4848
49- function init_markers ( ) {
50- $ ( ".links > a" ) . click ( function ( e ) {
51- e . preventDefault ( ) ;
52- var $this = $ ( this ) , // `this` is a link
53- id = $this . attr ( "href" ) ,
54- $parent = $this . parent ( ) . parent ( ) ;
55-
56-
57- $ ( ".links > a" , $parent ) . removeClass ( "active" ) ;
58- $this . addClass ( "active" )
59-
60- $ ( ".links .marker" , $parent ) . animate ( {
61- "left" :get_center_of_element ( $this )
62- } , 1500 ) ;
63-
64- $ ( ".external-links.active" , $parent ) . fadeOut ( function ( ) {
65- $ ( this ) . removeClass ( "active" ) ; // `this` is a link navigation elements
66- $ ( id ) . fadeIn ( ) . addClass ( "active" ) ;
67- } ) ;
68-
69- } ) ;
70-
71- // calculate marker positions at the start
72- $first_link = $ ( ".links > a:first-child" ) ;
49+ function calculate_position_of_marker ( ) {
7350$ ( ".links .marker" ) . each ( function ( ) {
7451var $this = $ ( this ) ;
75- $this . css ( "left" , get_center_of_element ( $this . parent ( ) . find ( "a:first-child" ) ) ) ;
52+ $this . css ( "left" , get_center_of_element ( $this . parent ( ) . find ( "a.active" ) ) ) ;
53+ } ) ;
54+ }
55+
56+ function init_markers ( ) {
57+ $ ( ".links > a" ) . click ( function ( e ) {
58+ e . preventDefault ( ) ;
59+ var $this = $ ( this ) , // `this` is a link
60+ id = $this . attr ( "href" ) ,
61+ $parent = $this . parent ( ) . parent ( ) ;
62+
63+ $ ( ".links > a" , $parent ) . removeClass ( "active" ) ;
64+ $this . addClass ( "active" )
65+
66+ $ ( ".links .marker" , $parent ) . animate ( {
67+ "left" :get_center_of_element ( $this )
68+ } , 500 ) ;
69+
70+ $ ( ".external-links.active" , $parent ) . fadeOut ( function ( ) {
71+ $ ( this ) . removeClass ( "active" ) ; // `this` is a link navigation elements
72+ $ ( id ) . fadeIn ( ) . addClass ( "active" ) ;
73+ } ) ;
7674} ) ;
7775
76+ $ ( window ) . resize ( calculate_position_of_marker ) ;
77+ calculate_position_of_marker ( ) ;
7878}
7979
8080function init_affix ( ) {