Skip to content

How to make dialog draggable? #3594

Closed Answered by vahuynh12
vahuynh12 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks everyone for your help on this! I've settled with the below code using gsap for now, even though it doesn't limit the draggable area to just the top bar of the dialog.

from nicegui import ui

ui.add_head_html("""
        <script src="https://unpkg.com/gsap@3.12.5/dist/gsap.min.js"></script>
        <script src="https://unpkg.com/gsap@3.12.5/dist/Draggable.min.js"></script>
    """)

ui.add_body_html("""
    <script>
        function initDraggableClass() {
            Draggable.create(".draggable", {
                type: "x,y",
                dragClickables: false,
                allowEventDefault: true,
            });
        };
        window.addEventListener("DOMContentLoaded…

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@v479038280
Comment options

@vahuynh12
Comment options

@python-and-fiction
Comment options

@vahuynh12
Comment options

@v479038280
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by vahuynh12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
community question A question for the NiceGUI community
5 participants