finom/vanillatree

Wrong context-menu position

ststeiger opened this issue · 0 comments

You have this code to set the context-menu position.

$.extend(menu.style, {
    top: evt.offsetY,
    left: evt.offsetX + 18,
    display: 'block'
});

This gives the wrong position (at least in google-chrome and Opera).
The context-menu should be placed at the bottom of the first line of the object where it was called.
Your position is at the bottom of the complete UL-element that was clicked.
Correct would be:

var rect = evt.target.getBoundingClientRect();
$.extend(menu.style, {
    top: (evt.target.offsetTop + rect.height).toString() + "px",
    left: evt.target.offsetLeft.toString() + "px",
    display: 'block'
});