1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

reduce direct dom access

This commit is contained in:
Luke Pulverenti 2016-08-20 17:58:28 -04:00
parent f53cb1ca8a
commit b7eaf270a1
13 changed files with 165 additions and 37 deletions

View file

@ -171,8 +171,6 @@ define(['dom'], function (dom) {
function getWindowData(win, documentElement) {
return {
pageYOffset: win.pageYOffset,
pageXOffset: win.pageXOffset,
clientTop: documentElement.clientTop,
clientLeft: documentElement.clientLeft
};
@ -180,16 +178,25 @@ define(['dom'], function (dom) {
function getOffset(elem, windowData) {
var box = { top: 0, left: 0 };
var box;
// Support: BlackBerry 5, iOS 3 (original iPhone)
// If we don't have gBCR, just use 0,0 rather than error
if (elem.getBoundingClientRect) {
box = elem.getBoundingClientRect();
} else {
box = {
top: 0,
left: 0,
width: 0,
height: 0
};
}
return {
top: box.top + windowData.pageYOffset - windowData.clientTop,
left: box.left + windowData.pageXOffset - windowData.clientLeft
top: box.top - windowData.clientTop,
left: box.left - windowData.clientLeft,
width: box.width,
height: box.height
};
}
@ -197,11 +204,13 @@ define(['dom'], function (dom) {
var offset = getOffset(elem, windowData);
var posY = offset.top - windowData.pageYOffset;
var posX = offset.left - windowData.pageXOffset;
var posY = offset.top;
var posX = offset.left;
var width = elem.offsetWidth;
var height = elem.offsetHeight;
var width = offset.width;
var height = offset.height;
//var width = elem.offsetWidth;
//var height = elem.offsetHeight;
return {
left: posX,