@realsee/five 6.8.0-alpha.26 → 6.8.0-alpha.27

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.
@@ -131,15 +131,20 @@ five.on("pano.prepare", (event) => {
131
131
  );
132
132
  });
133
133
 
134
- // 示例:结合 preventDefault waitUntil 实现条件拦截
135
- five.on("pano.prepare", async (event) => {
136
- const allowed = await checkPermission(event.pano);
137
- if (!allowed) {
138
- event.preventDefault();
139
- }
134
+ // 示例:通过 waitUntil reject 来取消走点
135
+ five.on("pano.prepare", (event) => {
136
+ event.waitUntil(
137
+ showConfirmDialog("是否前往该点位?").then((confirmed) => {
138
+ if (!confirmed) {
139
+ throw new Error("用户取消走点");
140
+ }
141
+ })
142
+ );
140
143
  });
141
144
  ```
142
145
 
146
+ > **注意**: `preventDefault` 和 `waitUntil` 必须在事件回调的同步执行阶段调用,不能放在 `await` 之后。
147
+
143
148
  ## Concepts
144
149
 
145
150
  Five 的事件系统将事件主要分为以下几类:
@@ -158,7 +163,7 @@ Five 的事件系统将事件主要分为以下几类:
158
163
  ### Pano Events (全景导航)
159
164
  监听全景图的点位切换过程。
160
165
 
161
- - `pano.prepare`: 准备切换到新点位。这是一个 `ExtendableEvent`,支持通过 `waitUntil(promise)` 延迟后续加载流程(如预加载资源)。
166
+ - `pano.prepare`: 准备切换到新点位。这是一个 `ExtendableEvent`,支持通过 `waitUntil(promise)` 延迟后续加载流程(如预加载资源),以及通过 `preventDefault()` 取消本次走点。
162
167
  - `pano.arrived`: 成功到达新点位(移动动画结束)。
163
168
  - `pano.moving`: 正在移动到新点位(动画进行中)。
164
169
  - `pano.willChange`: 即将发生点位变更(旧版兼容)。