controlkit.js icon indicating copy to clipboard operation
controlkit.js copied to clipboard

Specifying parentDocumentElementID prevents mouseevents from reaching the parent

Open sudsy opened this issue 8 years ago • 0 comments

I noticed this behaviour while implementing controlKit.

I have found a fix which involves changing:

    if (!options.parentDomElementId) {
        node = new Node();
        document.body.appendChild(node.getElement());
    } else {
        node = Node.getNodeById(options.parentDomElementId);
    }

to

    if (!options.parentDomElementId) {
        node = new Node();
        document.body.appendChild(node.getElement());
    } else {
	node = new Node();
        document.getElementById(options.parentDomElementId).appendChild(node.getElement());
    }

Ideally though, I would like it to be something more like this to allow a domElement to be passed rather than referenced by id

    var rootElement = document.body;
    if (options.parentDomElement) {
        rootElement = options.parentDomElement
    } else if(options.parentDomElementId){
        rootElement = document.getElementById(options.parentDomElementId)
    }
    node = new Node();
    rootElement.appendChild(node.getElement());

I will make these changes in my own fork and will submit a PR if you would like to merge the changes.

sudsy avatar Feb 13 '17 03:02 sudsy