|
178 | 178 | return this.root.classList.contains('active'); |
179 | 179 | }, |
180 | 180 | toggle: function(v){ |
181 | | - var c, h, n, hb, cb, ref$, x, y, nscroll, nstack, s, stackb, scrollb; |
| 181 | + var c, h, n, hb, cb, ref$, x, y, nscroll, nstack, countScroll, s, stackb, scrollb, scroll; |
182 | 182 | if (arguments.length === 0) { |
183 | 183 | v = !this.root.classList.contains('active'); |
184 | 184 | } |
|
200 | 200 | cb = c.getBoundingClientRect(); |
201 | 201 | ref$ = [0, 0], x = ref$[0], y = ref$[1]; |
202 | 202 | ref$ = [null, null], nscroll = ref$[0], nstack = ref$[1]; |
| 203 | + countScroll = true; |
203 | 204 | while (n && n.getAttribute) { |
204 | 205 | s = getComputedStyle(n); |
205 | 206 | if (n.nodeName === 'BODY' || ['overflow', 'overflow-y', 'overflow-x'].filter(fn$).length) { |
|
210 | 211 | if (n.nodeName === 'BODY' || s.position !== 'static') { |
211 | 212 | if (!nstack) { |
212 | 213 | nstack = n; |
| 214 | + if (!nscroll) { |
| 215 | + countScroll = false; |
| 216 | + } |
213 | 217 | } |
214 | 218 | } |
215 | 219 | if (nscroll && nstack) { |
|
219 | 223 | } |
220 | 224 | stackb = nstack.getBoundingClientRect(); |
221 | 225 | scrollb = nscroll.getBoundingClientRect(); |
| 226 | + scroll = countScroll |
| 227 | + ? { |
| 228 | + left: nscroll.scrollLeft, |
| 229 | + top: nscroll.scrollTop |
| 230 | + } |
| 231 | + : { |
| 232 | + left: 0, |
| 233 | + top: 0 |
| 234 | + }; |
222 | 235 | if (hb.y + hb.height + cb.height > scrollb.y + scrollb.height) { |
223 | | - y = hb.y - stackb.y - cb.height + nscroll.scrollTop - 2; |
| 236 | + y = hb.y - stackb.y - cb.height + scroll.top - 2; |
224 | 237 | } else { |
225 | | - y = hb.y - stackb.y + hb.height + nscroll.scrollTop + 2; |
| 238 | + y = hb.y - stackb.y + hb.height + scroll.top + 2; |
226 | 239 | } |
227 | 240 | if (hb.x + cb.width > scrollb.x + scrollb.width) { |
228 | | - x = hb.x - stackb.x + hb.width - cb.width + nscroll.scrollLeft; |
| 241 | + x = hb.x - stackb.x + hb.width - cb.width + scroll.left; |
229 | 242 | } else { |
230 | | - x = hb.x - stackb.x + nscroll.scrollLeft; |
| 243 | + x = hb.x - stackb.x + scroll.left; |
231 | 244 | } |
232 | 245 | c.style.transform = "translate(" + x + "px, " + y + "px)"; |
233 | 246 | return ref$ = c.style, ref$.top = 0, ref$.left = 0, ref$; |
|
0 commit comments