@@ -74,29 +74,25 @@ export default Base.extend({
7474 } ,
7575
7676 markIfVisible ( ) {
77- if ( this . $el . hasClass ( "pat-scroll-animated" ) ) {
78- // this section is triggered when the scrolling is a result of the animate function
79- // ie. automatic scrolling as opposed to the user manually scrolling
80- this . $el . removeClass ( "pat-scroll-animated" ) ;
81- } else if ( this . el . href ) {
82- const fragment = this . el . href . split ( "#" ) ?. [ 1 ] ;
83- if ( fragment ) {
84- const $target = $ ( `#${ fragment } ` ) ;
85- if ( $target . length ) {
86- if (
87- utils . isElementInViewport ( $target [ 0 ] , true , this . options . offset )
88- ) {
89- // check that the anchor's target is visible
90- // if so, mark both the anchor and the target element
91- $target . addClass ( "current" ) ;
92- this . $el . addClass ( "current" ) ;
93- this . $el . trigger ( "pat-update" , {
94- pattern : "scroll" ,
95- action : "attribute-changed" ,
96- dom : $target [ 0 ] ,
97- } ) ;
98- }
99- }
77+ if ( ! this . el . href ) {
78+ return ;
79+ }
80+ const fragment = this . el . href . split ( "#" ) ?. [ 1 ] ;
81+ if ( ! fragment ) {
82+ return ;
83+ }
84+ const $target = $ ( `#${ fragment } ` ) ;
85+ if ( $target . length ) {
86+ if ( utils . isElementInViewport ( $target [ 0 ] , true , this . options . offset ) ) {
87+ // check that the anchor's target is visible
88+ // if so, mark both the anchor and the target element
89+ $target . addClass ( "current" ) ;
90+ this . $el . addClass ( "current" ) ;
91+ this . $el . trigger ( "pat-update" , {
92+ pattern : "scroll" ,
93+ action : "attribute-changed" ,
94+ dom : $target [ 0 ] ,
95+ } ) ;
10096 }
10197 }
10298 } ,
@@ -223,5 +219,6 @@ export default Base.extend({
223219 } ,
224220 } )
225221 . promise ( ) ;
222+ $ ( ".pat-scroll" ) . removeClass ( "pat-scroll-animated" ) ;
226223 } ,
227224} ) ;
0 commit comments