ViewTransition:skipTransition() 方法
skipTransition()
方法是 ViewTransition
接口的方法,它跳过视图转换的动画部分,但不跳过运行关联的视图更新。
语法
js
skipTransition()
参数
无。
返回值
undefined
.
示例
跳过 SPA 视图转换
js
// start new view transition
const transition = document.startViewTransition(() => displayNewImage());
// skip the animation and just update the DOM
transition.skipTransition();
跳过 MPA 视图转换
js
// Fired on the current (outgoing) page
document.addEventListener("pageswap", (event) => {
event.viewTransition?.skipTransition();
});
// Fired on the destination (inbound) page
document.addEventListener("pagereveal", (event) => {
event.viewTransition?.skipTransition();
});
规范
规范 |
---|
CSS 视图转换模块级别 1 # dom-viewtransition-skiptransition |
浏览器兼容性
BCD 表格仅在浏览器中加载