瀏覽代碼

Merge pull request #1137 from BeatC/thumbnail-avatars

Thumbnail avatars
master
yanas 8 年之前
父節點
當前提交
5098b64666
共有 5 個檔案被更改,包括 196 行新增127 行删除
  1. 1
    1
      css/_mixins.scss
  2. 2
    2
      css/_variables.scss
  3. 90
    98
      css/_videolayout_default.scss
  4. 53
    0
      modules/UI/util/UIUtil.js
  5. 50
    26
      modules/UI/videolayout/FilmStrip.js

+ 1
- 1
css/_mixins.scss 查看文件

@@ -63,7 +63,7 @@
63 63
   top: 50%;
64 64
   left: 50%;
65 65
   position: absolute;
66
-  @include transform(translate(-50%, -50%))
66
+  @include transform(translate(-50%, -50%));
67 67
 }
68 68
 
69 69
 /**

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

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

+ 90
- 98
css/_videolayout_default.scss 查看文件

@@ -22,41 +22,97 @@
22 22
         height: 100%;
23 23
         background-color: black;
24 24
     }
25
-}
26 25
 
27
-/**
28
- * The toolbar of the video thumbnail.
29
- */
30
-.videocontainer__toolbar,
31
-.videocontainer__toptoolbar {
32
-    position: absolute;
33
-    left: 0;
34
-    z-index: 3;
35
-    width: 100%;
36
-    box-sizing: border-box; // Includes the padding in the 100% width.
37
-}
26
+    /**
27
+     * The toolbar of the video thumbnail.
28
+     */
29
+    &__toolbar,
30
+    &__toptoolbar {
31
+        position: absolute;
32
+        left: 0;
33
+        z-index: 3;
34
+        width: 100%;
35
+        box-sizing: border-box; // Includes the padding in the 100% width.
36
+    }
38 37
 
39
-.videocontainer__toolbar {
40
-    bottom: 0;
41
-    padding: 0 5px 0 5px;
42
-    height: $thumbnailToolbarHeight;
43
-}
38
+    &__toolbar {
39
+        bottom: 0;
40
+        padding: 0 5px 0 5px;
41
+        height: $thumbnailToolbarHeight;
42
+    }
44 43
 
45
-.videocontainer__toptoolbar {
46
-    $toolbarPadding: 5px;
47
-    top: 0;
48
-    padding: $toolbarPadding;
49
-    padding-bottom: 0;
50
-    height: $thumbnailIndicatorSize + $toolbarPadding;
51
-}
44
+    &__toptoolbar {
45
+        $toolbarPadding: 5px;
46
+        top: 0;
47
+        padding: $toolbarPadding;
48
+        padding-bottom: 0;
49
+
50
+        span.indicator {
51
+            position: relative;
52
+            font-size: 8px;
53
+            text-align: center;
54
+            line-height: $thumbnailIndicatorSize;
55
+            display: none;
56
+            padding: 0;
57
+            margin-right: em(5, 8);
58
+            float: left;
59
+            @include circle($thumbnailIndicatorSize);
60
+            box-sizing: border-box;
61
+            z-index: 3;
62
+            background: $dominantSpeakerBg;
63
+            color: $thumbnailPictogramColor;
64
+            border: $thumbnailIndicatorBorder solid $thumbnailPictogramColor;
65
+
66
+            &:last-child {
67
+                margin-right: 0;
68
+            }
69
+
70
+            .indicatoricon {
71
+                @include absoluteAligning();
72
+            }
73
+
74
+            .connection {
75
+                position: relative;
76
+                display: inline-block;
77
+                margin: 0 auto;
78
+                left: 0;
79
+                @include transform(translate(0, -50%));
80
+
81
+                &_empty
82
+                {
83
+                    color: #8B8B8B;/*#FFFFFF*/
84
+                    overflow: hidden;
85
+                }
86
+
87
+                &_lost
88
+                {
89
+                    color: #8B8B8B;
90
+                    overflow: visible;
91
+                }
92
+
93
+                &_full
94
+                {
95
+                    @include topLeft();
96
+                    color: #FFFFFF;/*#15A1ED*/
97
+                    overflow: hidden;
98
+                }
99
+            }
100
+
101
+            .icon-connection,
102
+            .icon-connection-lost {
103
+                font-size: 1em;
104
+            }
105
+        }
106
+    }
52 107
 
53
-.videocontainer__hoverOverlay {
54
-    position: relative;
55
-    width: 100%;
56
-    height: 100%;
57
-    visibility: hidden;
58
-    background: rgba(0,0,0,.6);
59
-    z-index: 2;
108
+    &__hoverOverlay {
109
+        position: relative;
110
+        width: 100%;
111
+        height: 100%;
112
+        visibility: hidden;
113
+        background: rgba(0,0,0,.6);
114
+        z-index: 2;
115
+    }
60 116
 }
61 117
 
62 118
 #localVideoWrapper {
@@ -217,72 +273,6 @@
217 273
   background: $connectionIndicatorBg;
218 274
 }
219 275
 
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 276
 .remotevideomenu
287 277
 {
288 278
     display: inline-block;
@@ -400,8 +390,10 @@
400 390
 
401 391
 .userAvatar {
402 392
     @include maxSize(60px);
403
-    @include circle(50%);
404 393
     @include absoluteAligning();
394
+    border-radius: 50%;
395
+    height: 50%;
396
+    width: auto;
405 397
 }
406 398
 
407 399
 .sharedVideoAvatar {

+ 53
- 0
modules/UI/util/UIUtil.js 查看文件

@@ -27,6 +27,25 @@ const SHOW_CLASSES = {
27 27
     'list-item': 'show-list-item'
28 28
 };
29 29
 
30
+/**
31
+ * Contains sizes of thumbnails
32
+ * @type {{SMALL: number, MEDIUM: number}}
33
+ */
34
+const ThumbnailSizes = {
35
+    SMALL: 60,
36
+    MEDIUM: 80
37
+};
38
+
39
+/**
40
+ * Contains font sizes for thumbnail indicators
41
+ * @type {{SMALL: number, MEDIUM: number}}
42
+ */
43
+const IndicatorFontSizes = {
44
+    SMALL: 5,
45
+    MEDIUM: 6,
46
+    NORMAL: 8
47
+};
48
+
30 49
 /**
31 50
  * Created by hristo on 12/22/14.
32 51
  */
@@ -463,6 +482,7 @@ const SHOW_CLASSES = {
463 482
 
464 483
         if (indicators.length <= 0) {
465 484
             indicatorSpan = document.createElement('span');
485
+
466 486
             indicatorSpan.className = 'indicator';
467 487
             indicatorSpan.id = indicatorId;
468 488
 
@@ -475,6 +495,8 @@ const SHOW_CLASSES = {
475 495
                 APP.translation.translateElement($(indicatorSpan));
476 496
             }
477 497
 
498
+            this._resizeIndicator(indicatorSpan);
499
+
478 500
             document.getElementById(videoSpanId)
479 501
                 .querySelector('.videocontainer__toptoolbar')
480 502
                 .appendChild(indicatorSpan);
@@ -483,6 +505,37 @@ const SHOW_CLASSES = {
483 505
         }
484 506
 
485 507
         return indicatorSpan;
508
+    },
509
+
510
+    /**
511
+     * Resizing indicator element passing via argument
512
+     * according to the current thumbnail size
513
+     * @param {HTMLElement} indicator - indicator element
514
+     * @private
515
+     */
516
+    _resizeIndicator(indicator) {
517
+        let height = $('#localVideoContainer').height();
518
+        let fontSize = this.getIndicatorFontSize(height);
519
+        $(indicator).css('font-size', fontSize);
520
+    },
521
+
522
+    /**
523
+     * Returns font size for indicators according to current
524
+     * height of thumbnail
525
+     * @param {Number} - height - current height of thumbnail
526
+     * @returns {Number} - font size for current height
527
+     */
528
+    getIndicatorFontSize(height) {
529
+        const { SMALL, MEDIUM } = ThumbnailSizes;
530
+        let fontSize = IndicatorFontSizes.NORMAL;
531
+
532
+        if (height <= SMALL) {
533
+            fontSize = IndicatorFontSizes.SMALL;
534
+        } else if (height > SMALL && height <= MEDIUM) {
535
+            fontSize = IndicatorFontSizes.MEDIUM;
536
+        }
537
+
538
+        return fontSize;
486 539
     }
487 540
 };
488 541
 

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

@@ -368,39 +368,63 @@ const FilmStrip = {
368 368
 
369 369
         return new Promise(resolve => {
370 370
             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
-            });
371
+            let promises = [];
372
+
373
+            if(thumbs.localThumb) {
374
+                promises.push(new Promise((resolve) => {
375
+                    thumbs.localThumb.animate({
376
+                        height: local.thumbHeight,
377
+                        width: local.thumbWidth
378
+                    }, this._getAnimateOptions(animate, resolve));
379
+                }));
380
+            }
381
+            if(thumbs.remoteThumbs) {
382
+                promises.push(new Promise((resolve) => {
383
+                    thumbs.remoteThumbs.animate({
384
+                        height: remote.thumbHeight,
385
+                        width: remote.thumbWidth
386
+                    }, this._getAnimateOptions(animate, resolve));
387
+                }));
388
+            }
389
+            promises.push(new Promise((resolve) => {
390
+                this.filmStrip.animate({
391
+                    // adds 2 px because of small video 1px border
392
+                    height: remote.thumbHeight + 2
393
+                }, this._getAnimateOptions(animate, resolve));
394
+            }));
395
+
396
+            promises.push(new Promise(() => {
397
+                let { localThumb } = this.getThumbs();
398
+                let height = localThumb.height();
399
+                let fontSize = UIUtil.getIndicatorFontSize(height);
400
+                this.filmStrip.find('.indicator').animate({
401
+                    fontSize
402
+                }, this._getAnimateOptions(animate, resolve));
403
+            }));
397 404
 
398 405
             if (!animate) {
399 406
                 resolve();
400 407
             }
408
+
409
+            Promise.all(promises).then(resolve);
401 410
         });
402 411
     },
403 412
 
413
+    /**
414
+     * Helper method. Returns options for jQuery animation
415
+     * @param animate {Boolean} - animation flag
416
+     * @param cb {Function} - complete callback
417
+     * @returns {Object} - animation options object
418
+     * @private
419
+     */
420
+    _getAnimateOptions(animate, cb = $.noop) {
421
+        return {
422
+            queue: false,
423
+            duration: animate ? 500 : 0,
424
+            complete: cb
425
+        };
426
+    },
427
+
404 428
     /**
405 429
      * Returns thumbnails of the filmstrip
406 430
      * @param only_visible

Loading…
取消
儲存