Browse Source

feat: update

wxyyxc1992 5 years ago
parent
commit
66461864d0

+ 5
- 2
dist/cjs/board/Whiteboard/index.js View File

23
         this.isFullscreen = false;
23
         this.isFullscreen = false;
24
         this.pages = [];
24
         this.pages = [];
25
         this.isInitialized = false;
25
         this.isInitialized = false;
26
+        this.isSyncing = false;
26
         this.visiblePageIndex = 0;
27
         this.visiblePageIndex = 0;
27
         if (target) {
28
         if (target) {
28
             this.target = target;
29
             this.target = target;
207
     Whiteboard.prototype.onSnapshot = function (snap) {
208
     Whiteboard.prototype.onSnapshot = function (snap) {
208
         var _this = this;
209
         var _this = this;
209
         var id = snap.id, sources = snap.sources, pageIds = snap.pageIds, visiblePageIndex = snap.visiblePageIndex;
210
         var id = snap.id, sources = snap.sources, pageIds = snap.pageIds, visiblePageIndex = snap.visiblePageIndex;
210
-        if (!this.isInitialized) {
211
+        if (!this.isInitialized && !this.isSyncing) {
211
             this.id = id;
212
             this.id = id;
212
             this.sources = sources;
213
             this.sources = sources;
213
-            this.initSiema();
214
+            this.isSyncing = true;
214
             this.sources.forEach(function (source, i) {
215
             this.sources.forEach(function (source, i) {
215
                 var page = new index_1.WhitePage({ imgSrc: source }, {
216
                 var page = new index_1.WhitePage({ imgSrc: source }, {
216
                     mode: _this.mode,
217
                     mode: _this.mode,
222
                 _this.pages.push(page);
223
                 _this.pages.push(page);
223
                 page.open();
224
                 page.open();
224
             });
225
             });
226
+            this.initSiema();
225
         }
227
         }
226
         this.isInitialized = true;
228
         this.isInitialized = true;
229
+        this.isSyncing = false;
227
         this.onPageChange(visiblePageIndex);
230
         this.onPageChange(visiblePageIndex);
228
     };
231
     };
229
     return Whiteboard;
232
     return Whiteboard;

+ 5
- 2
dist/index.js View File

1706
         this.isFullscreen = false;
1706
         this.isFullscreen = false;
1707
         this.pages = [];
1707
         this.pages = [];
1708
         this.isInitialized = false;
1708
         this.isInitialized = false;
1709
+        this.isSyncing = false;
1709
         this.visiblePageIndex = 0;
1710
         this.visiblePageIndex = 0;
1710
         if (target) {
1711
         if (target) {
1711
             this.target = target;
1712
             this.target = target;
1893
             sources = snap.sources,
1894
             sources = snap.sources,
1894
             pageIds = snap.pageIds,
1895
             pageIds = snap.pageIds,
1895
             visiblePageIndex = snap.visiblePageIndex;
1896
             visiblePageIndex = snap.visiblePageIndex;
1896
-        if (!this.isInitialized) {
1897
+        if (!this.isInitialized && !this.isSyncing) {
1897
             this.id = id;
1898
             this.id = id;
1898
             this.sources = sources;
1899
             this.sources = sources;
1899
-            this.initSiema();
1900
+            this.isSyncing = true;
1900
             this.sources.forEach(function (source, i) {
1901
             this.sources.forEach(function (source, i) {
1901
                 var page = new index_1.WhitePage({ imgSrc: source }, {
1902
                 var page = new index_1.WhitePage({ imgSrc: source }, {
1902
                     mode: _this.mode,
1903
                     mode: _this.mode,
1908
                 _this.pages.push(page);
1909
                 _this.pages.push(page);
1909
                 page.open();
1910
                 page.open();
1910
             });
1911
             });
1912
+            this.initSiema();
1911
         }
1913
         }
1912
         this.isInitialized = true;
1914
         this.isInitialized = true;
1915
+        this.isSyncing = false;
1913
         this.onPageChange(visiblePageIndex);
1916
         this.onPageChange(visiblePageIndex);
1914
     };
1917
     };
1915
     return Whiteboard;
1918
     return Whiteboard;

+ 1
- 1
dist/index.js.map
File diff suppressed because it is too large
View File


+ 1
- 0
dist/types/board/Whiteboard/index.d.ts View File

21
     readonly activePage: WhitePage;
21
     readonly activePage: WhitePage;
22
     siema: any;
22
     siema: any;
23
     isInitialized: boolean;
23
     isInitialized: boolean;
24
+    isSyncing: boolean;
24
     visiblePageIndex: number;
25
     visiblePageIndex: number;
25
     emitInterval: any;
26
     emitInterval: any;
26
     constructor(target: HTMLDivElement, { sources, eventHub, mode, visiblePageIndex }?: {
27
     constructor(target: HTMLDivElement, { sources, eventHub, mode, visiblePageIndex }?: {

+ 6
- 2
src/board/Whiteboard/index.ts View File

49
   /** State | 内部状态 */
49
   /** State | 内部状态 */
50
   // 是否被初始化过,如果尚未被初始化,则等待来自于 Master 的同步消息
50
   // 是否被初始化过,如果尚未被初始化,则等待来自于 Master 的同步消息
51
   isInitialized: boolean = false;
51
   isInitialized: boolean = false;
52
+  isSyncing: boolean = false;
52
   visiblePageIndex: number = 0;
53
   visiblePageIndex: number = 0;
53
   emitInterval: any;
54
   emitInterval: any;
54
 
55
 
304
   private onSnapshot(snap: SerializableWhiteboard) {
305
   private onSnapshot(snap: SerializableWhiteboard) {
305
     const { id, sources, pageIds, visiblePageIndex } = snap;
306
     const { id, sources, pageIds, visiblePageIndex } = snap;
306
 
307
 
307
-    if (!this.isInitialized) {
308
+    if (!this.isInitialized && !this.isSyncing) {
308
       this.id = id;
309
       this.id = id;
309
       this.sources = sources;
310
       this.sources = sources;
310
-      this.initSiema();
311
+      this.isSyncing = true;
311
 
312
 
312
       // 初始化所有的 WhitePages
313
       // 初始化所有的 WhitePages
313
       this.sources.forEach((source, i) => {
314
       this.sources.forEach((source, i) => {
328
 
329
 
329
         page.open();
330
         page.open();
330
       });
331
       });
332
+
333
+      this.initSiema();
331
     }
334
     }
332
 
335
 
333
     this.isInitialized = true;
336
     this.isInitialized = true;
337
+    this.isSyncing = false;
334
     this.onPageChange(visiblePageIndex);
338
     this.onPageChange(visiblePageIndex);
335
   }
339
   }
336
 }
340
 }