Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Customize CSS classes in drawHandle #40

Open
AlexMili opened this issue May 10, 2022 · 2 comments
Open

Customize CSS classes in drawHandle #40

AlexMili opened this issue May 10, 2022 · 2 comments

Comments

@AlexMili
Copy link
Contributor

Hi,
I need to customize the CSS of the starting/closing handle using BetterPolygon to apply a specific style.
I did a POC here, do you think this something that could be added to Annotorious ?

@rsimon
Copy link
Member

rsimon commented May 13, 2022

I'd approach it from a slightly different angle. The method should really just create the handle, IMO. Since it returns the SVG g element, the calling method can still attach custom CSS classes outside of the drawHandle method.

But regardless of this problem: I like the thought of being able to apply different styles to start and closing handles. Perhaps there should be default built-in behavior that attaches an extra a9s-first-handle and a9s-last-handle (or something like that)?

FWIW: as a workaround, you could also use CSS :first-child and :last-child selectors to apply custom styles I think.

@AlexMili
Copy link
Contributor Author

Indeed another function adding the class would be better for consistency.

I would write something like that:

extraClass = (container, extraClasses) => {
    let newClass = container.className+ " ";

    if (typeof extraClasses == "string") {
        newClass += extraClasses;
    }
    else if (extraClasses instanceof Array) {
        newClass += extraClasses.join(" ");
    }

    container.setAttribute("class", newClass);
}

What do you think ?

Since I already have an opened PR, I don't think I can create a new one without the code of the previous one. Let me know if it is possible, I will gladly open a new one.

@rsimon rsimon transferred this issue from annotorious/annotorious Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants