Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:mip-nav-slidedown 下拉菜单组件与mip-fixed组件冲突 #1122 #1145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
74 changes: 74 additions & 0 deletions sample/mip-nav-slidedown/testNav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html mip>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<title>测试mip-nav-slidedown下拉菜单body不可滚动</title>
<link rel="stylesheet" type="text/css" href="https://c.mipcdn.com/static/v1/mip.css">
<link rel="canonical" href="对应的原页面地址">
<style mip-custom>
/* 自定义样式 */
</style>
</head>

<body>
<div class="mip-nav-wrapper">
<mip-nav-slidedown data-id="bs-navbar" class="mip-element-sidebar container" data-showbrand="1" data-brandname="MIP官网">
<nav id="bs-navbar" class="navbar-collapse collapse navbar navbar-static-top">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="//www.mipengine.org/">菜单1</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单2</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单3</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单4</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单5</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单6</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单7</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单8</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单9</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单10</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单11</a>
</li>
<li class="navbar-wise-close">
<span id="navbar-wise-close-btn"></span>
</li>
</ul>
</nav>
</mip-nav-slidedown>
</div>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>

<script src="https://c.mipcdn.com/static/v1/mip.js"></script>
<script src="https://c.mipcdn.com/static/v1/mip-nav-slidedown/mip-nav-slidedown.js"></script>

</html>
75 changes: 75 additions & 0 deletions sample/mip-nav-slidedown/testNavFixed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html mip>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<title>测试mip-nav-slidedown和mip-fixed组合使用</title>
<link rel="stylesheet" type="text/css" href="https://c.mipcdn.com/static/v1/mip.css">
<link rel="canonical" href="对应的原页面地址">
<style mip-custom>
/* 自定义样式 */
</style>
</head>
<body>
<mip-fixed type="top">
<div class="mip-nav-wrapper">
<mip-nav-slidedown data-id="bs-navbar" class="mip-element-sidebar container" data-showbrand="1" data-brandname="MIP官网">
<nav id="bs-navbar" class="navbar-collapse collapse navbar navbar-static-top">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="//www.mipengine.org/">菜单1</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单2</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单3</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单4</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单5</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单6</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单7</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单8</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单9</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单10</a>
</li>
<li>
<a href="//www.mipengine.org/">菜单11</a>
</li>
<li class="navbar-wise-close">
<span id="navbar-wise-close-btn"></span>
</li>
</ul>
</nav>
</mip-nav-slidedown>
</div>
</mip-fixed>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>
<mip-img layout="responsive" width="350" height="263" src="https://www.mipengine.org/static/img/sample_01.jpg">
</mip-img>

<script src="https://c.mipcdn.com/static/v1/mip.js"></script>
<script src="https://c.mipcdn.com/static/v1/mip-nav-slidedown/mip-nav-slidedown.js"></script>
<script src="https://c.mipcdn.com/static/v1/mip-fixed/mip-fixed.js"></script>
</body>
</html>
10 changes: 8 additions & 2 deletions src/mip-nav-slidedown/mip-nav-slidedown.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ define(function (require) {
if (window.innerWidth > 767) {
return;
}

var $wiseNav = $('#bs-navbar');

var $navWrapper = $('.mip-nav-wrapper');
if ($wiseNav.hasClass('in')) {
// 关闭菜单
$wiseNav.height('0px');
Expand All @@ -85,6 +84,9 @@ define(function (require) {
setTimeout(function () {
$wiseNav.removeClass('in');
}, 500);
setTimeout(function () {
$navWrapper.removeAttr('style');
}, 100);
}
else {
// 打开菜单
Expand Down Expand Up @@ -118,6 +120,10 @@ define(function (require) {
var offsetTop = $('mip-nav-slidedown')[0] ? $('mip-nav-slidedown')[0].getBoundingClientRect().top : 0;
var navHeight = window.innerHeight - $('.navbar-header').height() - offsetTop;
$wiseNav.height(navHeight);

var $navWrapper = $('.mip-nav-wrapper');
var navWrapperHeight = window.innerHeight - offsetTop;
$navWrapper.height(navWrapperHeight);
// 关闭按钮距离底部固定为90px
closeBtnTop = navHeight - ($('.navbar-right li').height()) * listNum - 90;
if (closeBtnTop > 20) {
Expand Down
5 changes: 5 additions & 0 deletions src/mip-nav-slidedown/mip-nav-slidedown.less
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
.mip-nav-wrapper {
height: 72px;
transition: height 0.3s;
&.show {
opacity: 1!important;
}
.hr-xs {
display: none;
}
}
.noscroll {
overflow-y: hidden !important;
}
mip-nav-slidedown{
#bs-navbar {
margin-bottom: 0;
Expand Down Expand Up @@ -73,6 +77,7 @@ mip-nav-slidedown{
@media screen and (max-width: 767px) {
.mip-nav-wrapper {
height: 44px;
transition: height 0.3s;
#bs-navbar {
height: 0;
transition: height 0.3s;
Expand Down