Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import resolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import pkg from './package.json';
import pkg from './package.json' assert {type: "json"};

const plugins = [
// The 'node-resolve' plugin allows Rollup to resolve bare module imports like
Expand Down
56 changes: 39 additions & 17 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ export class Router extends Resolver {
baseUrl: baseHref && Resolver.__createUrl(baseHref, document.URL).href.replace(/[^/]*$/, '')
}, options));

this.enableNativeViewTransitions = options && options.enableNativeViewTransitions;

this.resolveRoute = context => this.__resolveRoute(context);

const triggers = Router.NavigationTrigger;
Expand Down Expand Up @@ -472,23 +474,43 @@ export class Router extends Resolver {
return this.location;
}

this.__addAppearingContent(context, previousContext);
const animationDone = this.__animateIfNeeded(context);

this.__runOnAfterEnterCallbacks(context);
this.__runOnAfterLeaveCallbacks(context, previousContext);

return animationDone.then(() => {
if (this.__isLatestRender(context)) {
// If there is another render pass started after this one,
// the 'disappearing content' would be removed when the other
// render pass calls `this.__addAppearingContent()`
this.__removeDisappearingContent();

this.__previousContext = context;
return this.location;
}
});
if(this.enableNativeViewTransitions && document.startViewTransition) {
document.startViewTransition(
() => {
this.__addAppearingContent(context, previousContext);
this.__runOnAfterEnterCallbacks(context);
this.__runOnAfterLeaveCallbacks(context, previousContext);
if (this.__isLatestRender(context)) {
// If there is another render pass started after this one,
// the 'disappearing content' would be removed when the other
// render pass calls `this.__addAppearingContent()`
this.__removeDisappearingContent();

this.__previousContext = context;
return this.location;
}
}
)
}
else {
this.__addAppearingContent(context, previousContext);
const animationDone = this.__animateIfNeeded(context);

this.__runOnAfterEnterCallbacks(context);
this.__runOnAfterLeaveCallbacks(context, previousContext);

return animationDone.then(() => {
if (this.__isLatestRender(context)) {
// If there is another render pass started after this one,
// the 'disappearing content' would be removed when the other
// render pass calls `this.__addAppearingContent()`
this.__removeDisappearingContent();

this.__previousContext = context;
return this.location;
}
});
}
}
})
.catch(error => {
Expand Down