如果你想使用原生方式添加顶层模态,那么编辑你的具体化文件如下:
materialize.css:将此样式添加到您的 css 文件中
.modal.top-sheet {
top: -100%;
bottom: auto;
margin: 0;
width: 100%;
max-height: 45%;
border-radius: 0;
will-change: top, opacity;
}
materialize.js:
找到并编辑“底页动画”如下
在 animateIn() 函数中编辑
// Bottom sheet animation
if (this.$el[0].classList.contains('bottom-sheet')) {
Vel(this.$el[0], { bottom: '-100%', opacity: 0 }, exitVelocityOptions);
}else if (this.$el[0].classList.contains('top-sheet')) {
Vel(this.$el[0], { top: '-100%', opacity: 0 }, exitVelocityOptions);
}
在 animateOut() 函数中编辑
// Bottom sheet animation
if (this.$el[0].classList.contains('bottom-sheet')) {
Vel(this.$el[0], { bottom: 0, opacity: 1 }, enterVelocityOptions);
}else if (this.$el[0].classList.contains('top-sheet')) {
Vel(this.$el[0], { top: 0, opacity: 1 }, enterVelocityOptions);
}