-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v3-alpha' into feat/package-aarch64
- Loading branch information
Showing
4 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# HTML Drag and Drop API Example | ||
|
||
This example should demonstrate whether the [HTML Drag and Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API") works correctly. | ||
|
||
## Expected Behaviour | ||
|
||
When dragging the "draggable", in the console should be printed: | ||
1. "dragstart" once | ||
2. "drag" many times | ||
3. "dragend" once | ||
|
||
When dragging the "draggable" on the drop target, the inner text of the latter shoud change and in the console should be printed: | ||
1. "dragstart" once | ||
2. "drag" many times | ||
3. "dragenter" once | ||
4. "dragover" many times (alternating with "drag") | ||
5. - "drop" once (in case of a drop inside the drop target) | ||
- "dragleave" once (in case the draggable div leaves the drop target) | ||
6. "dragend" once | ||
|
||
## Running the example | ||
|
||
To run the example, simply run the following command: | ||
|
||
```bash | ||
go run main.go | ||
``` | ||
|
||
## Building the example | ||
|
||
To build the example in debug mode, simply run the following command: | ||
|
||
```bash | ||
wails3 task build | ||
``` | ||
|
||
# Status | ||
|
||
| Platform | Status | | ||
|----------|-------------| | ||
| Mac | Working | | ||
| Windows | Not Working | | ||
| Linux | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<style> | ||
body{ | ||
background-color: white; | ||
} | ||
|
||
#draggable { | ||
width: 100px; | ||
height: 100px; | ||
background-color: yellow; | ||
text-align: center; | ||
} | ||
|
||
#dropTarget { | ||
width: 200px; | ||
height: 200px; | ||
border: 2px solid red; | ||
text-align: center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>HTML Drag and Drop API Demo</h1> | ||
<br/> | ||
|
||
<div id="draggable" draggable="true" >draggable</div> | ||
|
||
<div id="dropTarget" >drop target</div> | ||
|
||
</body> | ||
|
||
<script type="module"> | ||
const draggable = document.getElementById('draggable'); | ||
|
||
draggable.addEventListener('dragstart', (event) => { | ||
console.log('dragstart'); | ||
dropTarget.innerText = 'drop target'; | ||
}); | ||
|
||
draggable.addEventListener("drag", (event) => { | ||
console.log('drag'); | ||
}); | ||
|
||
draggable.addEventListener("dragend", (event) => { | ||
console.log('dragend'); | ||
}); | ||
|
||
const dropTarget = document.getElementById('dropTarget'); | ||
|
||
dropTarget.addEventListener('dragenter', (event) => { | ||
console.log('dragenter'); | ||
}); | ||
|
||
dropTarget.addEventListener('dragleave', (event) => { | ||
console.log('dragleave'); | ||
dropTarget.innerText = 'left drop target'; | ||
}); | ||
|
||
dropTarget.addEventListener('dragover', (event) => { | ||
event.preventDefault() | ||
console.log('dragover'); | ||
dropTarget.innerText = 'dragged over'; | ||
}); | ||
|
||
dropTarget.addEventListener('drop', (event) => { | ||
console.log('drop'); | ||
dropTarget.innerText = 'dropped'; | ||
}); | ||
</script> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"embed" | ||
"log" | ||
|
||
"github.com/wailsapp/wails/v3/pkg/application" | ||
) | ||
|
||
//go:embed assets | ||
var assets embed.FS | ||
|
||
func main() { | ||
|
||
app := application.New(application.Options{ | ||
Name: "HTML Drag and Drop API Demo", | ||
Description: "A demo of the HTML Drag and drop API", | ||
Assets: application.AssetOptions{ | ||
Handler: application.BundledAssetFileServer(assets), | ||
}, | ||
Mac: application.MacOptions{ | ||
ApplicationShouldTerminateAfterLastWindowClosed: true, | ||
}, | ||
}) | ||
|
||
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ | ||
Title: "Drag-n-drop Demo", | ||
Mac: application.MacWindow{ | ||
Backdrop: application.MacBackdropTranslucent, | ||
TitleBar: application.MacTitleBarHiddenInsetUnified, | ||
InvisibleTitleBarHeight: 50, | ||
}, | ||
}) | ||
|
||
err := app.Run() | ||
|
||
if err != nil { | ||
log.Fatal(err.Error()) | ||
} | ||
} |