@netless/fastboard-ui 0.3.0-canary.3 → 0.3.0-canary.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/fastboard-ui",
3
- "version": "0.3.0-canary.3",
3
+ "version": "0.3.0-canary.6",
4
4
  "description": "The front-end of @netless/fastboard-core.",
5
5
  "main": "dist/index.js",
6
6
  "svelte": "dist/index.svelte.mjs",
@@ -10,14 +10,14 @@
10
10
  ],
11
11
  "repository": "netless-io/fastboard",
12
12
  "peerDependencies": {
13
- "@netless/fastboard-core": "0.3.0-canary.3"
13
+ "@netless/fastboard-core": "0.3.0-canary.6"
14
14
  },
15
15
  "dependencies": {
16
16
  "tippy.js": "^6.3.7"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@netless/esbuild-plugin-inline-sass": "0.1.0",
20
- "@netless/fastboard-core": "0.3.0-canary.3"
20
+ "@netless/fastboard-core": "0.3.0-canary.6"
21
21
  },
22
22
  "scripts": {
23
23
  "cleanup": "rimraf dist",
@@ -1,6 +1,8 @@
1
1
  <script lang="ts">
2
2
  import type { FastboardApp } from "@netless/fastboard-core";
3
3
  import type { Language, Theme } from "../../typings";
4
+ import { onMount } from "svelte";
5
+ import { tippy_hide_all } from "../../actions/tippy";
4
6
  import RedoUndo from "../RedoUndo";
5
7
  import ZoomControl from "../ZoomControl";
6
8
  import PageControl from "../PageControl";
@@ -15,12 +17,25 @@
15
17
 
16
18
  let container: HTMLDivElement;
17
19
 
18
- $: if (app && container) app.bindContainer(container);
19
- $: if (containerRef) containerRef(container || null);
20
+ $: try {
21
+ if (app && container) app.bindContainer(container);
22
+ } catch (err) {
23
+ console.error("[fastboard] An error occurred while binding container");
24
+ console.error(err);
25
+ }
26
+
27
+ onMount(() => {
28
+ if (containerRef) {
29
+ containerRef(container);
30
+ return () => {
31
+ if (containerRef) containerRef(null);
32
+ };
33
+ }
34
+ });
20
35
  </script>
21
36
 
22
37
  <div class="{name}-root" class:loading={!app}>
23
- <div class="{name}-view" bind:this={container} />
38
+ <div class="{name}-view" bind:this={container} on:touchstart|capture={tippy_hide_all} />
24
39
  <div class="{name}-left">
25
40
  <Toolbar {app} {theme} {language} />
26
41
  </div>
@@ -1,6 +1,8 @@
1
1
  <script lang="ts">
2
2
  import type { FastboardPlayer } from "@netless/fastboard-core";
3
3
  import type { Language, Theme } from "../../typings";
4
+ import { onMount } from "svelte";
5
+ import { tippy_hide_all } from "../../actions/tippy";
4
6
  import PlayerControl from "../PlayerControl";
5
7
 
6
8
  export let player: FastboardPlayer | null | undefined = null;
@@ -12,12 +14,25 @@
12
14
 
13
15
  let container: HTMLDivElement;
14
16
 
15
- $: if (player && container) player.bindContainer(container);
16
- $: if (containerRef) containerRef(container || null);
17
+ $: try {
18
+ if (player && container) player.bindContainer(container);
19
+ } catch (err) {
20
+ console.error("[fastboard] An error occurred while binding container");
21
+ console.error(err);
22
+ }
23
+
24
+ onMount(() => {
25
+ if (containerRef) {
26
+ containerRef(container);
27
+ return () => {
28
+ if (containerRef) containerRef(null);
29
+ };
30
+ }
31
+ });
17
32
  </script>
18
33
 
19
34
  <div class="{name}-root" class:loading={!player}>
20
- <div class="{name}-view" bind:this={container} />
35
+ <div class="{name}-view" bind:this={container} on:touchstart|capture={tippy_hide_all} />
21
36
  <div class="{name}-bottom">
22
37
  <PlayerControl {player} {theme} {language} />
23
38
  </div>
@@ -51,9 +51,16 @@
51
51
  $: shape = $memberState?.shapeType;
52
52
  $: status = app?.appsStatus;
53
53
 
54
- let top = writable(0);
54
+ $: if (applianceShapes.includes(appliance as Appliance)) {
55
+ last_shape = appliance as Shape;
56
+ } else if (shape) {
57
+ last_shape = shape;
58
+ }
59
+
55
60
  $: max_scroll = scrollable ? $scroll_height + (32 + 8) * 2 - computed_height : 0;
56
61
 
62
+ let top = writable(0);
63
+
57
64
  function scroll_up() {
58
65
  $top = clamp($top - 32 - 4, 0, max_scroll);
59
66
  }
@@ -80,11 +87,6 @@
80
87
  app?.setAppliance("shape", last_shape as Exclude<Shape, Appliance>);
81
88
  }
82
89
  }
83
- $: if (applianceShapes.includes(appliance as Appliance)) {
84
- last_shape = appliance as Shape;
85
- } else if (shape) {
86
- last_shape = shape;
87
- }
88
90
  function eraser() {
89
91
  app?.setAppliance("eraser");
90
92
  }