首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >物化模态自上而下打开

问物化模态自上而下打开
EN

Stack Overflow用户
提问于 2017-03-21 12:50:51
回答 4查看 5.5K关注 0票数 1

我正在尝试打开物化模式,从上到下下垂,完全像在这把小提琴中,但从上到下反向。不幸的是,很难在物化模式上修改某些东西,因为有些css属性是从物化js中添加的。自下而上的特殊效果是由“底部工作表”类添加的,但是不存在“顶层”类。

代码语言:javascript
复制
.modal.bottom-sheet {
  top: auto;
  bottom: -100%;
  margin: 0;
  width: 100%;
  max-height: 45%;
  border-radius: 0;
  will-change: bottom, opacity;
}

那么,我如何才能改变打开的效果,以扭转和模态打开,从上到下?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2017-03-21 13:23:33

我知道这个解决方案太麻烦了,但至少有效。

代码语言:javascript
复制
.modal.top-sheet {
  top: 0% !important;
  bottom: auto !important;
  transition: transform cubic-bezier(0.22, 0.61, 0.36, 1) .2s;
  will-change: transform;
  transform: translate(0, -100%) scale(1) !important;
  width: 100%;
  opacity: 1 !important;
}

.modal.top-sheet.open {
   transition: transform cubic-bezier(0.22, 0.61, 0.36, 1) .35s .25s;
}

.modal.top-sheet.open:not([style*="display: none"]):not([style*="opacity: 0;"]) {
  transform: translate(0, 0%) !important;
}

https://jsfiddle.net/xmz0afhf/1/

原则:

  1. 将“底部”属性设置为“自动!重要”
  2. 覆盖转换属性以包含"top“
  3. 应用当显示支柱不是“无”和“不透明”支柱不是"0“时应用的css规则

编辑:更新后,您可以分别使用底部工作表和顶部工作表。

票数 5
EN

Stack Overflow用户

发布于 2017-03-21 13:19:46

物化模态在默认情况下通过缩放模式对话框提供自上而下的效果。如果您想要从上到下滑动功能,那么您可以使用简单的$.slideToggle()。但是,如果您想修改物化JS,那么您可以使用下面的代码尝试小提琴,

代码语言:javascript
复制
$(document).ready(function() {
    $('#modal1').modal({
      startingTop: '0', // Starting top style attribute
      endingTop: '10%', // Ending top style attribute
    });
});
票数 1
EN

Stack Overflow用户

发布于 2017-03-21 13:33:45

就像罗汉·库马尔所说的,物化确实给了你改变模态行为的可能性。您可以在这里查看:物化模态选择

这就是我在Fiddler网站上看到的:https://jsfiddle.net/7f6hmgcf/25/

代码语言:javascript
复制
$(document).ready(function() {
$('.modal').modal({
  dismissible: true, // Modal can be dismissed by clicking outside of the modal
  opacity: .5, // Opacity of modal background
  inDuration: 300, // Transition in duration
  outDuration: 200, // Transition out duration
  startingTop: '-10%', // Starting top style attribute
  endingTop: '10px', // <-- HEIGHT OF THE BUTTON
  ready: function(modal, trigger) { // Callback for Modal open. Modal and trigger parameters available.
    console.log(modal, trigger);
  },
  complete: function() { alert('Closed'); } // Callback for Modal close
    }
  );
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42927688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档