-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add js support * add js support to demo app Signed-off-by: Calvin Liang <[email protected]> --------- Signed-off-by: Calvin Liang <[email protected]> Co-authored-by: Calvin Liang <[email protected]>
- Loading branch information
1 parent
62c7392
commit 298101c
Showing
7 changed files
with
69 additions
and
1 deletion.
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
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,13 @@ | ||
import androidx.compose.ui.ExperimentalComposeUiApi | ||
import androidx.compose.ui.window.CanvasBasedWindow | ||
import org.jetbrains.skiko.wasm.onWasmReady | ||
import sh.calvin.reorderable.demo.ui.App | ||
|
||
@OptIn(ExperimentalComposeUiApi::class) | ||
fun main() { | ||
onWasmReady { | ||
CanvasBasedWindow(canvasElementId = "ComposeTarget") { | ||
App() | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
demoApp/composeApp/src/jsMain/kotlin/sh/calvin/reorderable/demo/haptics.js.kt
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,27 @@ | ||
package sh.calvin.reorderable.demo | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import kotlinx.browser.window | ||
|
||
@Composable | ||
actual fun rememberReorderHapticFeedback(): ReorderHapticFeedback { | ||
val reorderHapticFeedback = remember { | ||
object : ReorderHapticFeedback() { | ||
override fun performHapticFeedback(type: ReorderHapticFeedbackType) { | ||
when (type) { | ||
ReorderHapticFeedbackType.START -> | ||
window.navigator.vibrate(5) | ||
|
||
ReorderHapticFeedbackType.MOVE -> | ||
window.navigator.vibrate(1) | ||
|
||
ReorderHapticFeedbackType.END -> | ||
window.navigator.vibrate(3) | ||
} | ||
} | ||
} | ||
} | ||
|
||
return reorderHapticFeedback | ||
} |
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Compose App</title> | ||
<script type="application/javascript" src="skiko.js"></script> | ||
</head> | ||
<body> | ||
<canvas id="ComposeTarget"></canvas> | ||
<script src="composeApp.js"></script> | ||
</body> | ||
</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
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