Skip to content

Commit

Permalink
Merge 04a0d1c into 451e27d
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeizizhu committed Sep 26, 2013
2 parents 451e27d + 04a0d1c commit 266ca67
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,27 @@ define(function(require, exports, module) {
return;
}
var ap = this._originArrowPosition,
triggerOffset = this.get('trigger').offset(),

scrollTop = $(window).scrollTop(),
viewportHeight = $(window).outerHeight(),
elemHeight = this.element.height() + this.get('distance'),
triggerTop = this.get('trigger').offset().top,
triggerTop = triggerOffset.top,
triggerHeight = this.get('trigger').height(),

scrollLeft = $(window).scrollLeft(),
viewportWidth = $(window).outerWidth(),
elemWidth = this.element.width() + this.get("distance"),
triggerLeft = triggerOffset.left,
triggerWidth = this.get("trigger").width(),

arrowMap = {
'1': 5,
'5': 1,
'7': 11,
'11': 7
'11': 7,
'2': 10,
'10': 2
};

if ((ap == 11 || ap == 1) &&
Expand All @@ -73,6 +84,12 @@ define(function(require, exports, module) {
(triggerTop < scrollTop + elemHeight)) {
// tip 溢出屏幕上方
this.set('arrowPosition', arrowMap[ap]);
} else if ((ap == 2) && triggerLeft < scrollLeft + elemWidth) {
// tip 溢出屏幕左方
this.set("arrowPosition", arrowMap[ap]);
} else if ((ap == 10) && triggerLeft + triggerWidth > scrollLeft + viewportWidth - elemWidth) {
// tip 溢出屏幕右方
this.set("arrowPosition", arrowMap[ap]);
} else {
// 复原
this.set('arrowPosition', this._originArrowPosition);
Expand Down

0 comments on commit 266ca67

Please sign in to comment.