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

Experimental support for CSS Drag detection #1750

Merged
merged 3 commits into from
Aug 18, 2022
Merged

Conversation

leaanthony
Copy link
Member

@leaanthony leaanthony commented Aug 15, 2022

This PR adds experimental support for CSS defined drag regions using the --wails-drag CSS variable. To test:

  • Add style property to draggable element
<body>
    <div id="root" style="--wails-draggable: drag"></div>
    <script src="./src/main.jsx" type="module"></script>
</body>
  • Compile app in debug mode
    wails build -debug
  • Open dev console and run wails.useCSSDrag()

image

Drag type can be toggled so you can test both original and new drag testers:

<body>
    <div id="root" data-wails-drag style="--wails-draggable: drag"></div>
    <script src="./src/main.jsx" type="module"></script>
</body>

To specify a non-draggable region within a draggable region, use any value other than drag for the css variable.

@brys0
Copy link

brys0 commented Aug 16, 2022

Hey! Sorry to get back to you so late. That does seem to work

@leaanthony
Copy link
Member Author

Thanks for testing @brys0 ! I've added a small update that will enable this feature via an experimental option:

// Create application with options
	err := wails.Run(&options.App{
		Title:            "reactsprojec",
		Width:            1024,
		Height:           768,
		Assets:           assets,
		BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
		OnStartup:        app.startup,
		Bind: []interface{}{
			app,
		},
		Experimental: &options.Experimental{
			UseCSSDrag: true,
		},
	})

For now it still outputs a message to the console indicating which drag method it's using. If this works, I'll update docs and merge 👍

@leaanthony leaanthony marked this pull request as ready for review August 18, 2022 10:38
@leaanthony
Copy link
Member Author

Merging this experimental flag as a means for people to test css drag before deprecating the current way

@leaanthony leaanthony merged commit f2568f1 into master Aug 18, 2022
@leaanthony leaanthony deleted the feature/faster-drag branch August 18, 2022 10:39
@brys0
Copy link

brys0 commented Aug 23, 2022

Hey! So, there's an actually with the current CSS draggable implementation.

In vue if you try to make the style dynamic i.e :style="--wails-draggable: drag;" it doesnt work. It also doesnt work with another css style applied. It however, does work with just no dynamic templating i.e style="--wails-draggable: drag;"

@brys0
Copy link

brys0 commented Aug 23, 2022

I suspect this is also an issue on other dynamically generated template. Like Svelte, or React as well.

@leaanthony
Copy link
Member Author

I think that's fine. The requirement is to have that style there in whatever way you want. If it isn't there, the CSS selector won't work.

@brys0
Copy link

brys0 commented Aug 23, 2022

So, it's the intended effect not to work with dynamic styling?

@leaanthony
Copy link
Member Author

That's not the intent but it is a side effect. Applying it directly works though. We could change it to a CSS property but there isn't a standard one and in my testing, the ones commonly used weren't always picked up by the CSS selector. Happy to also add a CSS property as a trigger if you can find one that works cross platform and doesn't override any intended behaviour of the attribute. Could also make it user configurable 🤔 that sounds awesome 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants