|
71 | 71 | case "bottom": |
72 | 72 | top = elementTop + elementOuterHeight + options.offset; |
73 | 73 | 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; |
80 | 85 | } |
81 | 86 | } |
82 | 87 | break; |
83 | 88 | case "top": |
84 | 89 | 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; |
91 | 101 | } |
| 102 | + |
92 | 103 | } |
93 | 104 | calLeftRight(); |
94 | 105 | break; |
95 | 106 | case "left": |
96 | 107 | 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 | + } |
100 | 115 | } |
101 | 116 | calTopBottom(); |
102 | 117 | break; |
103 | 118 | case "right": |
104 | 119 | 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 | + } |
108 | 127 | } |
109 | 128 | calTopBottom(); |
110 | 129 | break; |
111 | 130 | default: |
112 | 131 | break; |
113 | 132 | } |
114 | 133 |
|
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 || ""); |
127 | 138 |
|
128 | 139 | if (options.animation === true) { |
129 | 140 | $boxElement.slideToggle("normal"); |
|
281 | 292 | $compile(this._pboxElement)(scope); |
282 | 293 | $body.append(this._pboxElement); |
283 | 294 | $timeout(function () { |
284 | | - $wtPosition.calculatePos(_self._options, $target, _self._pboxElement); |
285 | 295 | _self._bindEvents(); |
286 | 296 | if (_self._options.watch) { |
287 | 297 | scope.$watch(function () { |
288 | 298 | return _self._pboxElement.width() + "," + _self._pboxElement.height() |
289 | 299 | }, function () { |
290 | | - $wtPosition.calculatePos(_self._options, $target, _self._pboxElement); |
| 300 | + $timeout(function () { |
| 301 | + $wtPosition.calculatePos(_self._options, $target, _self._pboxElement); |
| 302 | + }); |
291 | 303 | }) |
| 304 | + } else { |
| 305 | + $wtPosition.calculatePos(_self._options, $target, _self._pboxElement); |
292 | 306 | } |
293 | | - },this._options.delay); |
| 307 | + }, this._options.delay); |
294 | 308 | }; |
295 | 309 |
|
296 | 310 | BoxModal.prototype.close = function (result) { |
|
0 commit comments