This repository was archived by the owner on Jan 11, 2023. It is now read-only.
File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -292,16 +292,17 @@ function prepare_page(target: Target): Promise<{
292
292
} ) ;
293
293
}
294
294
295
- async function navigate ( target : Target , id : number ) : Promise < any > {
295
+ async function navigate ( target : Target , id : number , noscroll = false ) : Promise < any > {
296
296
if ( id ) {
297
297
// popstate or initial navigation
298
298
cid = id ;
299
299
} else {
300
300
// clicked on a link. preserve scroll state
301
- scroll_history [ cid ] = scroll_state ( ) ;
301
+ const scrollState = scroll_state ( )
302
+ scroll_history [ cid ] = scrollState ;
302
303
303
304
id = cid = ++ uid ;
304
- scroll_history [ cid ] = { x : 0 , y : 0 } ;
305
+ scroll_history [ cid ] = noscroll ? scrollState : { x : 0 , y : 0 } ;
305
306
}
306
307
307
308
cid = id ;
@@ -362,8 +363,9 @@ function handle_click(event: MouseEvent) {
362
363
if ( url . pathname === window . location . pathname && url . search === window . location . search ) return ;
363
364
364
365
const target = select_route ( url ) ;
366
+ const hasNoscroll = a . hasAttribute ( 'sapper-noscroll' )
365
367
if ( target ) {
366
- navigate ( target , null ) ;
368
+ navigate ( target , null , hasNoscroll ) ;
367
369
event . preventDefault ( ) ;
368
370
history . pushState ( { id : cid } , '' , url . href ) ;
369
371
}
You can’t perform that action at this time.
0 commit comments