瀏覽代碼

Make filmstrip indicators to resize dynamically

master
Ilya Daynatovich 8 年之前
父節點
當前提交
f3dbeea091
共有 3 個檔案被更改,包括 153 行新增96 行删除
  1. 2
    2
      css/_variables.scss
  2. 73
    68
      css/_videolayout_default.scss
  3. 78
    26
      modules/UI/videolayout/FilmStrip.js

+ 2
- 2
css/_variables.scss 查看文件

@@ -13,8 +13,8 @@ $hangupFontSize: 2em;
13 13
 $defaultToolbarSize: 50px;
14 14
 
15 15
 // Video layout.
16
-$thumbnailToolbarHeight: 22px;
17
-$thumbnailIndicatorBorder: 0px;
16
+$thumbnailToolbarHeight: 3em;
17
+$thumbnailIndicatorBorder: 0;
18 18
 $thumbnailIndicatorSize: $thumbnailToolbarHeight;
19 19
 $thumbnailVideoMargin: 2px;
20 20
 

+ 73
- 68
css/_videolayout_default.scss 查看文件

@@ -47,7 +47,76 @@
47 47
     top: 0;
48 48
     padding: $toolbarPadding;
49 49
     padding-bottom: 0;
50
-    height: $thumbnailIndicatorSize + $toolbarPadding;
50
+
51
+    span.indicator {
52
+        position: relative;
53
+        font-size: 8px;
54
+        text-align: center;
55
+        line-height: $thumbnailToolbarHeight;
56
+        display: none;
57
+        padding: 0;
58
+        margin-right: em(5, 8);
59
+        float: left;
60
+        @include circle($thumbnailIndicatorSize);
61
+        box-sizing: border-box;
62
+        z-index: 3;
63
+        background: $dominantSpeakerBg;
64
+        color: $thumbnailPictogramColor;
65
+        border: $thumbnailIndicatorBorder solid $thumbnailPictogramColor;
66
+
67
+        &:last-child {
68
+            margin-right: 0;
69
+        }
70
+
71
+        .indicatoricon {
72
+            position: absolute;
73
+            top: 50%;
74
+            left: 0;
75
+            @include transform(translateY(-50%));
76
+            width: $thumbnailIndicatorSize - 2 * $thumbnailIndicatorBorder;
77
+            height: $thumbnailIndicatorSize - 2 * $thumbnailIndicatorBorder;
78
+            line-height: $thumbnailIndicatorSize - 2 * $thumbnailIndicatorBorder;
79
+        }
80
+
81
+        .connection {
82
+            position: relative;
83
+            margin: 0 auto;
84
+            width: 12px;
85
+            height: 8px;
86
+
87
+            &_empty
88
+            {
89
+                @include topLeft();
90
+                max-width: 12px;
91
+                width: 12px;
92
+                color: #8B8B8B;/*#FFFFFF*/
93
+                overflow: hidden;
94
+            }
95
+
96
+            &_lost
97
+            {
98
+                @include topLeft();
99
+                max-width: 12px;
100
+                width: 12px;
101
+                color: #8B8B8B;
102
+                overflow: visible;
103
+            }
104
+
105
+            &_full
106
+            {
107
+                @include topLeft();
108
+                max-width: 12px;
109
+                width: 12px;
110
+                color: #FFFFFF;/*#15A1ED*/
111
+                overflow: hidden;
112
+            }
113
+        }
114
+
115
+        .icon-connection,
116
+        .icon-connection-lost {
117
+            font-size: 1em;
118
+        }
119
+    }
51 120
 }
52 121
 
53 122
 .videocontainer__hoverOverlay {
@@ -217,72 +286,6 @@
217 286
   background: $connectionIndicatorBg;
218 287
 }
219 288
 
220
-.videocontainer__toptoolbar span.indicator {
221
-    position: relative;
222
-    font-size: 8pt;
223
-    text-align: center;
224
-    line-height: $thumbnailToolbarHeight;
225
-    display: none;
226
-    padding: 0;
227
-    margin-right: 5px;
228
-    float: left;
229
-    @include circle($thumbnailIndicatorSize);
230
-    box-sizing: border-box;
231
-    z-index: 3;
232
-    background: $dominantSpeakerBg;
233
-    color: $thumbnailPictogramColor;
234
-    border: $thumbnailIndicatorBorder solid $thumbnailPictogramColor;
235
-
236
-    .indicatoricon {
237
-        position: absolute;
238
-        top: 50%;
239
-        left: 0;
240
-        @include transform(translateY(-50%));
241
-        width: $thumbnailIndicatorSize - 2 * $thumbnailIndicatorBorder;
242
-        height: $thumbnailIndicatorSize - 2 * $thumbnailIndicatorBorder;
243
-        line-height: $thumbnailIndicatorSize - 2 * $thumbnailIndicatorBorder;
244
-    }
245
-
246
-    .connection {
247
-        position: relative;
248
-        margin: 0 auto;
249
-        width: 12px;
250
-        height: 8px;
251
-
252
-        &_empty
253
-        {
254
-            @include topLeft();
255
-            max-width: 12px;
256
-            width: 12px;
257
-            color: #8B8B8B;/*#FFFFFF*/
258
-            overflow: hidden;
259
-        }
260
-
261
-        &_lost
262
-        {
263
-            @include topLeft();
264
-            max-width: 12px;
265
-            width: 12px;
266
-            color: #8B8B8B;
267
-            overflow: visible;
268
-        }
269
-
270
-        &_full
271
-        {
272
-            @include topLeft();
273
-            max-width: 12px;
274
-            width: 12px;
275
-            color: #FFFFFF;/*#15A1ED*/
276
-            overflow: hidden;
277
-        }
278
-    }
279
-
280
-    .icon-connection,
281
-    .icon-connection-lost {
282
-        font-size: 6pt;
283
-    }
284
-}
285
-
286 289
 .remotevideomenu
287 290
 {
288 291
     display: inline-block;
@@ -400,8 +403,10 @@
400 403
 
401 404
 .userAvatar {
402 405
     @include maxSize(60px);
403
-    @include circle(50%);
404 406
     @include absoluteAligning();
407
+    border-radius: 50%;
408
+    height: 50%;
409
+    width: auto;
405 410
 }
406 411
 
407 412
 .sharedVideoAvatar {

+ 78
- 26
modules/UI/videolayout/FilmStrip.js 查看文件

@@ -3,6 +3,15 @@
3 3
 import UIEvents from "../../../service/UI/UIEvents";
4 4
 import UIUtil from "../util/UIUtil";
5 5
 
6
+/**
7
+ * Contains sizes of thumbnails
8
+ * @type {{SMALL: number, MEDIUM: number}}
9
+ */
10
+const ThumbnailSizes = {
11
+    SMALL: 60,
12
+    MEDIUM: 80
13
+};
14
+
6 15
 const FilmStrip = {
7 16
     /**
8 17
      *
@@ -368,39 +377,82 @@ const FilmStrip = {
368 377
 
369 378
         return new Promise(resolve => {
370 379
             let thumbs = this.getThumbs(!forceUpdate);
371
-            if(thumbs.localThumb)
372
-                thumbs.localThumb.animate({
373
-                    height: local.thumbHeight,
374
-                    width: local.thumbWidth
375
-                }, {
376
-                    queue: false,
377
-                    duration: animate ? 500 : 0,
378
-                    complete:  resolve
379
-                });
380
-            if(thumbs.remoteThumbs)
381
-                thumbs.remoteThumbs.animate({
382
-                    height: remote.thumbHeight,
383
-                    width: remote.thumbWidth
384
-                }, {
385
-                    queue: false,
386
-                    duration: animate ? 500 : 0,
387
-                    complete:  resolve
388
-                });
389
-
390
-            this.filmStrip.animate({
391
-                // adds 2 px because of small video 1px border
392
-                height: remote.thumbHeight + 2
393
-            }, {
394
-                queue: false,
395
-                duration: animate ? 500 : 0
396
-            });
380
+            let promises = [];
381
+
382
+            if(thumbs.localThumb) {
383
+                promises.push(new Promise((resolve) => {
384
+                    thumbs.localThumb.animate({
385
+                        height: local.thumbHeight,
386
+                        width: local.thumbWidth
387
+                    }, this._getAnimateOptions(animate, resolve));
388
+                }));
389
+            }
390
+            if(thumbs.remoteThumbs) {
391
+                promises.push(new Promise((resolve) => {
392
+                    thumbs.remoteThumbs.animate({
393
+                        height: remote.thumbHeight,
394
+                        width: remote.thumbWidth
395
+                    }, this._getAnimateOptions(animate, resolve));
396
+                }));
397
+            }
398
+            promises.push(new Promise((resolve) => {
399
+                this.filmStrip.animate({
400
+                    // adds 2 px because of small video 1px border
401
+                    height: remote.thumbHeight + 2
402
+                }, this._getAnimateOptions(animate, resolve));
403
+            }));
404
+            promises.push(new Promise((resolve) => {
405
+                let fontSize = this._getIndicatorFontSize(remote.thumbHeight);
406
+                this.filmStrip.find('.indicator').animate({
407
+                    fontSize
408
+                }, this._getAnimateOptions(animate, resolve));
409
+            }));
397 410
 
398 411
             if (!animate) {
399 412
                 resolve();
400 413
             }
414
+
415
+            Promise.all(promises).then(resolve);
401 416
         });
402 417
     },
403 418
 
419
+    /**
420
+     * Helper method. Returns options for jQuery animation
421
+     * @param animate {Boolean} - animation flag
422
+     * @param cb {Function} - complete callback
423
+     * @returns {Object} - animation options object
424
+     * @private
425
+     */
426
+    _getAnimateOptions(animate, cb = $.noop) {
427
+        return {
428
+            queue: false,
429
+            duration: animate ? 500 : 0,
430
+            complete: cb
431
+        };
432
+    },
433
+
434
+    /**
435
+     * Returns font size for indicators according to current
436
+     * height of thumbnail
437
+     * @param height
438
+     * @returns {Number} - font size for current height
439
+     * @private
440
+     */
441
+    _getIndicatorFontSize(height) {
442
+        const { SMALL, MEDIUM } = ThumbnailSizes;
443
+        let fontSize;
444
+
445
+        if (height <= SMALL) {
446
+            fontSize = 5;
447
+        } else if (height > SMALL && height <= MEDIUM) {
448
+            fontSize = 6;
449
+        } else {
450
+            fontSize = 8;
451
+        }
452
+
453
+        return fontSize;
454
+    },
455
+
404 456
     /**
405 457
      * Returns thumbnails of the filmstrip
406 458
      * @param only_visible

Loading…
取消
儲存