Skip to content

Commit

Permalink
[changed] uses CSS to position Popover caret
Browse files Browse the repository at this point in the history
  • Loading branch information
Minwe committed May 12, 2015
1 parent 391b6b7 commit 906dde4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@

- `IMPROVED` #556 调整 `select` 在 Firefox 下的样式(Thx to @photino)。

**JS:**

- `CHANGED` 使用 CSS 定位 Popover 箭头。

### 2015.05 W1

**Web 组件:**
Expand Down
6 changes: 3 additions & 3 deletions js/ui.popover.js
Expand Up @@ -93,7 +93,7 @@ Popover.prototype.sizePopover = function sizePopover() {
$popover.css({left: '', top: ''}).removeClass('am-popover-left ' +
'am-popover-right am-popover-top am-popover-bottom');

$popCaret.css({left: '', top: ''});
// $popCaret.css({left: '', top: ''});

if (popTotalHeight - spacing < triggerRect.top + spacing) {
// Popover on the top of trigger
Expand Down Expand Up @@ -134,7 +134,7 @@ Popover.prototype.sizePopover = function sizePopover() {
}

diff = diff - popLeft;
$popCaret.css({left: (popWidth / 2 - popCaretSize + diff) + 'px'});
// $popCaret.css({left: (popWidth / 2 - popCaretSize + diff) + 'px'});

} else if (popPosition === 'middle') {
popLeft = triggerOffset.left - popWidth - popCaretSize;
Expand All @@ -148,7 +148,7 @@ Popover.prototype.sizePopover = function sizePopover() {
popLeft = winWidth - popWidth - 5;
$popover.removeClass('am-popover-left').addClass('am-popover-right');
}
$popCaret.css({top: (popHeight / 2 - popCaretSize / 2) + 'px'});
// $popCaret.css({top: (popHeight / 2 - popCaretSize / 2) + 'px'});
}

// Apply position style
Expand Down
15 changes: 13 additions & 2 deletions less/ui.popover.less
Expand Up @@ -62,13 +62,12 @@
background: @popover-bg;
padding: 8px;
z-index: 110;
.scrollable();
// .scrollable();
.hook-popover-inner;
}

.@{ns}popover-caret {
position: absolute;
left: 5px;
top: 0;
z-index: 100;
.caret-up(8px, @popover-bg);
Expand All @@ -85,6 +84,12 @@
top: -8px;
}

.@{ns}popover-top &,
.@{ns}popover-bottom & {
left: 50%;
margin-left: -8px;
}

.@{ns}popover-left & {
top: auto;
left: auto;
Expand All @@ -97,6 +102,12 @@
left: -12px;
transform: rotate(-90deg);
}

.@{ns}popover-left &,
.@{ns}popover-right & {
top: 50%;
margin-top: -4px;
}
}


Expand Down

0 comments on commit 906dde4

Please sign in to comment.