Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to register open/close listeners for side drawers(left | right). #821

Closed
mP1 opened this issue Aug 22, 2023 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@mP1
Copy link

mP1 commented Aug 22, 2023

I would like the ability to register listeners for the drawers. As mentioned on gitter im not sure when the open listener should fire, but i guess it should fire when the drawer is fully open after animations have completed. THe same would be true of the close listener.

@vegegoku vegegoku self-assigned this Aug 22, 2023
@vegegoku vegegoku added the enhancement New feature or request label Aug 22, 2023
@vegegoku vegegoku added this to the 2.0.0-RC2 milestone Aug 22, 2023
@mP1
Copy link
Author

mP1 commented Aug 23, 2023

WORKAROUND:

A simple workaround which i am using now is to simply replace the original toggle icon with my own icon, which i have added my own click listener.

        final Icon<?> rightToggleIcon = Icons.menu_open();
        rightToggleIcon.addClickListener(this::appLayoutRightToggleIconOnClick);
        layout.setRightDrawerToggleIcon(rightToggleIcon);

@vegegoku vegegoku changed the title v2: AppLayout ability to register open/close listeners for side drawers(left | right). Ability to register open/close listeners for side drawers(left | right). Aug 27, 2023
@vegegoku
Copy link
Member

As mentioned in the chat support channel, open/close or expand/collapse have been standarized touse CollapseStrategy which already have the ability to register such listeners, there might be some component that might miss that so in that case if reported we will implement the feature in that standard way. for the layout drawers it was different since they dont use that and the animation is controlled with a css class attached/removed from the main layout, in general we added a new utility that is available for domino-ui components to listen to transition events.

check the TransitionListeners class, which is already part now of the BaseDominoElement
The user can now use the class like this :

TransitionListeners.of(element)
                .onTransitionStart(target -> {
                    DomGlobal.console.info("Transition started");
                })
                .onTransitionEnd(target -> {
                    DomGlobal.console.info("Transition Ends");
                })
                .onTransitionCancel(target -> {
                    DomGlobal.console.info("Transition Canceled");
                });

or directly on a domino-ui component :

element
                .onTransitionStart(target -> {
                    DomGlobal.console.info("Transition started");
                })
                .onTransitionEnd(target -> {
                    DomGlobal.console.info("Transition Ends");
                })
                .onTransitionCancel(target -> {
                    DomGlobal.console.info("Transition Canceled");
                });

The new API is now used to also add open/close listeners for the layout left/right drawers and the handlers can be registered like :

 layout.onLeftDrawerOpen((parent, drawer) -> {
            DomGlobal.console.info(">>::::::::: LEFT Drawer open");
        });

        layout.onLeftDrawerClosed((parent, drawer) -> {
            DomGlobal.console.info("<<::::::::: LEFT Drawer close");
        });

        layout.onRightDrawerOpen((parent, drawer) -> {
            DomGlobal.console.info(">>::::::::: RIGHT Drawer open");
        });

        layout.onRightDrawerClosed((parent, drawer) -> {
            DomGlobal.console.info("<<::::::::: RIGHT Drawer close");
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants