[FIX] horizontal centering of edition button on images centered with margin: 0 auto in webkit-based browsers

bzr revid: xmo@openerp.com-20131122101154-fsae9uz33smy2ja9
This commit is contained in:
Xavier Morel
2013-11-22 11:11:54 +01:00
parent 73d16d6d9b
commit 1f2a40e3f7
+10 -2
View File
@@ -90,10 +90,18 @@
});
var position = $el.position();
// http://bugs.jquery.com/ticket/5445#comment:6
// if the image has margin: x auto for centering, FF & IE
// will report top/left as the "correct" value and
// marginTop/marginLeft at "0px", webkit browsers will
// report top/left as 0-ish and set marginTop and
// marginLeft
var image_top = position.top + parseInt($el.css('marginTop'), 10);
var image_left = position.left + parseInt($el.css('marginLeft'), 10);
$btn.css({
position: 'absolute',
top: $el.height() / 2 + position.top - $btn.outerHeight() / 2,
left: $el.width() / 2 + position.left - $btn.outerWidth() / 2,
top: $el.height() / 2 + image_top - $btn.outerHeight() / 2,
left: $el.width() / 2 + image_left - $btn.outerWidth() / 2,
});
}).on('mouseleave', 'img', function (e) {
var $button = $(previousSelection.$).next('button');