refactor(blurFeature): use atachment fixed

pull/3/head
alex 2016-03-01 18:09:11 +03:00
parent 817e19eabf
commit 85274b90b2
2 changed files with 2 additions and 4 deletions

View File

@ -26,7 +26,6 @@
baPanelBlurHelper.bodyBgLoad().then(function() { baPanelBlurHelper.bodyBgLoad().then(function() {
setTimeout(recalculatePanelStyle); setTimeout(recalculatePanelStyle);
}); });
$document.on('scroll', recalculatePanelStyle);
$window.addEventListener('resize', recalculatePanelStyle); $window.addEventListener('resize', recalculatePanelStyle);
$scope.$on('$destroy', function() { $scope.$on('$destroy', function() {
@ -37,10 +36,9 @@
if (!bodyBgSize) { if (!bodyBgSize) {
return; return;
} }
var position = elem[0].getBoundingClientRect();
elem.css({ elem.css({
backgroundSize: Math.round(bodyBgSize.width) + 'px ' + Math.round(bodyBgSize.height) + 'px', backgroundSize: Math.round(bodyBgSize.width) + 'px ' + Math.round(bodyBgSize.height) + 'px',
backgroundPosition: Math.floor(-position.left + bodyBgSize.positionX) + 'px ' + Math.floor(-position.top + bodyBgSize.positionY) + 'px' backgroundPosition: Math.floor(bodyBgSize.positionX) + 'px ' + Math.floor(bodyBgSize.positionY) + 'px'
}); });
} }

View File

@ -39,7 +39,7 @@
finalWidth = elemW; finalWidth = elemW;
finalHeight = (elemW * imgRatio); finalHeight = (elemW * imgRatio);
} }
return { width: finalWidth, height: finalHeight, positionX: (elemW - finalWidth) / 2, positionY: (elemH - finalHeight) / 2 }; return { width: finalWidth, height: finalHeight, positionX: (elemW - finalWidth)/2, positionY: (elemH - finalHeight)/2};
}; };
} }