We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

thelian

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Classes for annotations #28857
    thelian
    Participant

    @Mikhail
    I have actually been able to solve it with a simple trick. But first what I have tried and why it didn’t work.

    1. Tried separate HTML elements and bind them to the objects, but I loose on “transparent annotation” functionality and the whole toggle annotations logic
    2. Tried to put html elements inside of the annotation label (it actually takes HTML, not a string), but then I couldn’t use the annotation container, as the innerHTML was covering it.

    Now the solution was actually to wrap annotations right after creation

    `
    app.ExternalInterface.annotations = function wrapAnnotations() {
    var addnotations = document.getElementsByClassName(‘v3d-annotation’)
    for (var i = 0; i < addnotations.length; ++i) {
    var item = addnotations;
    var wrapper = document.createElement(‘div’);
    wrapper.classList.add(‘annotation-wrapper’)
    wrapper.classList.add(‘color-blue’)
    item.parentNode.insertBefore(wrapper, item);
    wrapper.appendChild(item);
    }
    }
    `
    then I can target the annotation-wrapper class in JS, so I can add classes to it. Having wrapper I can target any child of it :yahoo:
    P.S. i’m not used to vanillaJS, so the above code might require refactoring

    in reply to: Classes for annotations #28827
    thelian
    Participant

    @Mikhail I am trying to add class with your method, with custom JS function or any other method. In the inspector I can see that there has been a change in class for this element (as it highlights), however the class returns to just being “v3d-annotation” at the same time.
    I have added switch button that changes specific colors in my project. I want this switch to change colors of annotations as well. There is possibility of changing the style of annotation with puzzles, but
    1. I can’t target :before of the dialog with puzzles
    2. I have 11 annotations and using setStyle for each of them seems inefficient.
    simple addClass would do the work

Viewing 2 posts - 1 through 2 (of 2 total)