| @@ 2298-2346 (lines=49) @@ | ||
| 2295 | var isFixed = function (ctrl) { |
|
| 2296 | return ctrl.state.get('fixed'); |
|
| 2297 | }; |
|
| 2298 | function calculateRelativePosition(ctrl, targetElm, rel) { |
|
| 2299 | var ctrlElm, pos, x, y, selfW, selfH, targetW, targetH, viewport, size; |
|
| 2300 | viewport = getWindowViewPort(); |
|
| 2301 | pos = funcs.getPos(targetElm, UiContainer.getUiContainer(ctrl)); |
|
| 2302 | x = pos.x; |
|
| 2303 | y = pos.y; |
|
| 2304 | if (isFixed(ctrl) && isStatic(document.body)) { |
|
| 2305 | x -= viewport.x; |
|
| 2306 | y -= viewport.y; |
|
| 2307 | } |
|
| 2308 | ctrlElm = ctrl.getEl(); |
|
| 2309 | size = funcs.getSize(ctrlElm); |
|
| 2310 | selfW = size.width; |
|
| 2311 | selfH = size.height; |
|
| 2312 | size = funcs.getSize(targetElm); |
|
| 2313 | targetW = size.width; |
|
| 2314 | targetH = size.height; |
|
| 2315 | rel = (rel || '').split(''); |
|
| 2316 | if (rel[0] === 'b') { |
|
| 2317 | y += targetH; |
|
| 2318 | } |
|
| 2319 | if (rel[1] === 'r') { |
|
| 2320 | x += targetW; |
|
| 2321 | } |
|
| 2322 | if (rel[0] === 'c') { |
|
| 2323 | y += Math.round(targetH / 2); |
|
| 2324 | } |
|
| 2325 | if (rel[1] === 'c') { |
|
| 2326 | x += Math.round(targetW / 2); |
|
| 2327 | } |
|
| 2328 | if (rel[3] === 'b') { |
|
| 2329 | y -= selfH; |
|
| 2330 | } |
|
| 2331 | if (rel[4] === 'r') { |
|
| 2332 | x -= selfW; |
|
| 2333 | } |
|
| 2334 | if (rel[3] === 'c') { |
|
| 2335 | y -= Math.round(selfH / 2); |
|
| 2336 | } |
|
| 2337 | if (rel[4] === 'c') { |
|
| 2338 | x -= Math.round(selfW / 2); |
|
| 2339 | } |
|
| 2340 | return { |
|
| 2341 | x: x, |
|
| 2342 | y: y, |
|
| 2343 | w: selfW, |
|
| 2344 | h: selfH |
|
| 2345 | }; |
|
| 2346 | } |
|
| 2347 | var getUiContainerViewPort = function (customUiContainer) { |
|
| 2348 | return { |
|
| 2349 | x: 0, |
|
| @@ 1282-1330 (lines=49) @@ | ||
| 1279 | var isFixed = function (ctrl) { |
|
| 1280 | return ctrl.state.get('fixed'); |
|
| 1281 | }; |
|
| 1282 | function calculateRelativePosition(ctrl, targetElm, rel) { |
|
| 1283 | var ctrlElm, pos, x, y, selfW, selfH, targetW, targetH, viewport, size; |
|
| 1284 | viewport = getWindowViewPort(); |
|
| 1285 | pos = funcs.getPos(targetElm, UiContainer.getUiContainer(ctrl)); |
|
| 1286 | x = pos.x; |
|
| 1287 | y = pos.y; |
|
| 1288 | if (isFixed(ctrl) && isStatic(document.body)) { |
|
| 1289 | x -= viewport.x; |
|
| 1290 | y -= viewport.y; |
|
| 1291 | } |
|
| 1292 | ctrlElm = ctrl.getEl(); |
|
| 1293 | size = funcs.getSize(ctrlElm); |
|
| 1294 | selfW = size.width; |
|
| 1295 | selfH = size.height; |
|
| 1296 | size = funcs.getSize(targetElm); |
|
| 1297 | targetW = size.width; |
|
| 1298 | targetH = size.height; |
|
| 1299 | rel = (rel || '').split(''); |
|
| 1300 | if (rel[0] === 'b') { |
|
| 1301 | y += targetH; |
|
| 1302 | } |
|
| 1303 | if (rel[1] === 'r') { |
|
| 1304 | x += targetW; |
|
| 1305 | } |
|
| 1306 | if (rel[0] === 'c') { |
|
| 1307 | y += Math.round(targetH / 2); |
|
| 1308 | } |
|
| 1309 | if (rel[1] === 'c') { |
|
| 1310 | x += Math.round(targetW / 2); |
|
| 1311 | } |
|
| 1312 | if (rel[3] === 'b') { |
|
| 1313 | y -= selfH; |
|
| 1314 | } |
|
| 1315 | if (rel[4] === 'r') { |
|
| 1316 | x -= selfW; |
|
| 1317 | } |
|
| 1318 | if (rel[3] === 'c') { |
|
| 1319 | y -= Math.round(selfH / 2); |
|
| 1320 | } |
|
| 1321 | if (rel[4] === 'c') { |
|
| 1322 | x -= Math.round(selfW / 2); |
|
| 1323 | } |
|
| 1324 | return { |
|
| 1325 | x: x, |
|
| 1326 | y: y, |
|
| 1327 | w: selfW, |
|
| 1328 | h: selfH |
|
| 1329 | }; |
|
| 1330 | } |
|
| 1331 | var getUiContainerViewPort = function (customUiContainer) { |
|
| 1332 | return { |
|
| 1333 | x: 0, |
|