Skip to content

Commit 7a773bc

Browse files
committed
upgrade version to 0.0.11
1 parent 996bd2f commit 7a773bc

File tree

2 files changed

+48
-34
lines changed

2 files changed

+48
-34
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-wtpbox",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"main": "src/pbox.js",
55
"dependencies": {
66
"angular": "~1.2.25",

src/pbox.js

+47-33
Original file line numberDiff line numberDiff line change
@@ -71,59 +71,70 @@
7171
case "bottom":
7272
top = elementTop + elementOuterHeight + options.offset;
7373
calLeftRight();
74-
if (options.autoAdapt && top + boxHeight > docClientHeight) {
75-
top = undefined;
76-
bottom = docClientHeight - elementTop + options.offset;
77-
if (bottom + boxHeight > docClientHeight) {
78-
top = options.offset;
79-
bottom = undefined;
74+
if (top + boxHeight > docClientHeight) {
75+
if (options.autoAdapt) {
76+
top = undefined;
77+
bottom = docClientHeight - elementTop + options.offset;
78+
if (bottom + boxHeight > docClientHeight) {
79+
top = options.offset;
80+
bottom = undefined;
81+
}
82+
} else {
83+
top = docClientHeight - boxHeight - options.offset;
84+
top = top > 0 ? top : options.offset;
8085
}
8186
}
8287
break;
8388
case "top":
8489
bottom = docClientHeight - elementTop + options.offset;
85-
if (options.autoAdapt && bottom + boxHeight > docClientHeight) {
86-
bottom = undefined;
87-
top = elementTop + elementOuterHeight + options.offset;
88-
if (top + boxHeight > docClientWidth) {
89-
top = undefined;
90-
bottom = docClientHeight - boxHeight + options.offset;
90+
if (bottom + boxHeight > docClientHeight) {
91+
if (options.autoAdapt) {
92+
bottom = undefined;
93+
top = elementTop + elementOuterHeight + options.offset;
94+
if (top + boxHeight > docClientWidth) {
95+
top = undefined;
96+
bottom = docClientHeight - boxHeight + options.offset;
97+
}
98+
} else {
99+
bottom = docClientHeight - boxHeight - options.offset;
100+
bottom = bottom > 0 ? bottom : options.offset;
91101
}
102+
92103
}
93104
calLeftRight();
94105
break;
95106
case "left":
96107
right = ~~(docClientWidth - elementLeft + options.offset);
97-
if (options.autoAdapt && right + boxWidth + options.offset > docClientWidth) {
98-
right = undefined;
99-
left = ~~(elementLeft + elementOuterWidth + options.offset);
108+
if (right + boxWidth + options.offset > docClientWidth) {
109+
if (options.autoAdapt) {
110+
right = undefined;
111+
left = ~~(elementLeft + elementOuterWidth + options.offset);
112+
} else {
113+
right = docClientWidth - boxWidth - options.offset;
114+
}
100115
}
101116
calTopBottom();
102117
break;
103118
case "right":
104119
left = elementLeft + elementOuterWidth + options.offset;
105-
if (options.autoAdapt && left + boxWidth + options.offset > docClientWidth) {
106-
left = undefined;
107-
right = docClientWidth - elementLeft + options.offset;
120+
if (left + boxWidth + options.offset > docClientWidth) {
121+
if (options.autoAdapt) {
122+
left = undefined;
123+
right = docClientWidth - elementLeft + options.offset;
124+
} else {
125+
left = docClientWidth - boxWidth - options.offset;
126+
}
108127
}
109128
calTopBottom();
110129
break;
111130
default:
112131
break;
113132
}
114133

115-
if (top !== undefined) {
116-
$boxElement.css("top", top);
117-
}
118-
if (bottom) {
119-
$boxElement.css("bottom", bottom);
120-
}
121-
if (left !== undefined) {
122-
$boxElement.css("left", left);
123-
}
124-
if (right !== undefined) {
125-
$boxElement.css("right", right);
126-
}
134+
$boxElement.css("top", top || "");
135+
$boxElement.css("bottom", bottom || "");
136+
$boxElement.css("left", left || "");
137+
$boxElement.css("right", right || "");
127138

128139
if (options.animation === true) {
129140
$boxElement.slideToggle("normal");
@@ -281,16 +292,19 @@
281292
$compile(this._pboxElement)(scope);
282293
$body.append(this._pboxElement);
283294
$timeout(function () {
284-
$wtPosition.calculatePos(_self._options, $target, _self._pboxElement);
285295
_self._bindEvents();
286296
if (_self._options.watch) {
287297
scope.$watch(function () {
288298
return _self._pboxElement.width() + "," + _self._pboxElement.height()
289299
}, function () {
290-
$wtPosition.calculatePos(_self._options, $target, _self._pboxElement);
300+
$timeout(function () {
301+
$wtPosition.calculatePos(_self._options, $target, _self._pboxElement);
302+
});
291303
})
304+
} else {
305+
$wtPosition.calculatePos(_self._options, $target, _self._pboxElement);
292306
}
293-
},this._options.delay);
307+
}, this._options.delay);
294308
};
295309

296310
BoxModal.prototype.close = function (result) {

0 commit comments

Comments
 (0)