Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Justineo committed Aug 29, 2016
2 parents 2d83697 + cd1b73a commit 2b7a43d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 0.2.10
- 修正二级导航左右边界的计算

* 0.2.9
- 升级 `rule` 模块下的 `phone`/`mobile` 规则,支持 `17` 开头的手机号

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bat-ria",
"version": "0.2.9",
"version": "0.2.10",
"description": "RIA extension for Brand Ads Team",
"main": "main.js",
"repository": {
Expand All @@ -22,7 +22,7 @@
"moment": "2.x",
"etpl": ">=3.0.0",
"urijs": ">=1.12.0",
"eoo": "~0.0.9",
"eoo": "^0.0.9",
"mini-event": "~1.0.2"
}
},
Expand Down
10 changes: 7 additions & 3 deletions src/ui/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,17 @@ define(function (require) {
if (isNew) {
// 二级导航位置的计算,二级导航的长度默认为去除最右子元素的边距后的剩余长度
// 然后将二级导航的垂直平分线与一级导航子元素对齐
var navOffset = lib.getOffset(main);
var navItemOffset = lib.getOffset(navItems[index]);
var subNavOffset = lib.getOffset(ul);
var middleOfNavItem = navItemOffset.left + navItemOffset.width / 2;
var marginLeft = (middleOfNavItem - subNavOffset.width / 2);
if (marginLeft < -navOffset.left + 10) {
marginLeft = -navOffset.left + 10;
var bodyWidth = lib.getOffset(document.body).width;
// 看下是不是超出最左边和最右边
if (marginLeft < 0) {
marginLeft = 10;
}
else if (marginLeft + navItemOffset.right > bodyWidth) {
marginLeft = bodyWidth - subNavOffset.width - 10;
}
ul.style.cssText = 'margin-left: ' + marginLeft + 'px';
}
Expand Down

0 comments on commit 2b7a43d

Please sign in to comment.