$layer insertBefore $menu cause page reflow
Rhain opened this issue · 1 comments
Rhain commented
layer: function (opt, zIndex) {
// add transparent layer for click area
// filter and background for Internet Explorer, Issue #23
var $layer = opt.$layer = $('<div id="context-menu-layer"></div>')
.css({
height: $win.height(),
width: $win.width(),
display: 'block',
position: 'fixed',
'z-index': zIndex,
top: 0,
left: 0,
opacity: 0,
filter: 'alpha(opacity=0)',
'background-color': '#000'
})
.data('contextMenuRoot', opt)
.insertBefore(this)
.on('contextmenu', handle.abortevent)
.on('mousedown', handle.layerClick);
// IE6 doesn't know position:fixed;
if (typeof document.body.style.maxWidth === 'undefined') { // IE6 doesn't support maxWidth
$layer.css({
'position': 'absolute',
'height': $(document).height()
});
}
return $layer;
},
the code insertBefore(this)
cause document reflow. when the page is complex, it cause much time to reflow .
Can you optimize this problem?
bbrala commented
Merged :) Thanks!