浏览代码

Fix aligning of indicator icon; Update logic for dynamically change of thumb indicators via font-size

j8
Ilya Daynatovich 8 年前
父节点
当前提交
9bc24e1caa
共有 4 个文件被更改,包括 66 次插入75 次删除
  1. 1
    1
      css/_mixins.scss
  2. 4
    35
      css/_videolayout_default.scss
  3. 53
    0
      modules/UI/util/UIUtil.js
  4. 8
    39
      modules/UI/videolayout/FilmStrip.js

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

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

+ 4
- 35
css/_videolayout_default.scss 查看文件

68
             }
68
             }
69
 
69
 
70
             .indicatoricon {
70
             .indicatoricon {
71
-                position: absolute;
72
-                top: 50%;
73
-                left: 0;
74
-                @include transform(translateY(-50%));
75
-                width: 100%;
71
+                @include absoluteAligning();
76
             }
72
             }
77
 
73
 
78
             .connection {
74
             .connection {
79
                 position: relative;
75
                 position: relative;
76
+                display: inline-block;
80
                 margin: 0 auto;
77
                 margin: 0 auto;
81
-                width: 12px;
82
-                height: 8px;
78
+                left: 0;
79
+                @include transform(translate(0, -50%));
83
 
80
 
84
                 &_empty
81
                 &_empty
85
                 {
82
                 {
86
-                    @include topLeft();
87
-                    max-width: 12px;
88
-                    width: 12px;
89
                     color: #8B8B8B;/*#FFFFFF*/
83
                     color: #8B8B8B;/*#FFFFFF*/
90
                     overflow: hidden;
84
                     overflow: hidden;
91
                 }
85
                 }
92
 
86
 
93
                 &_lost
87
                 &_lost
94
                 {
88
                 {
95
-                    @include topLeft();
96
-                    max-width: 12px;
97
-                    width: 12px;
98
                     color: #8B8B8B;
89
                     color: #8B8B8B;
99
                     overflow: visible;
90
                     overflow: visible;
100
                 }
91
                 }
102
                 &_full
93
                 &_full
103
                 {
94
                 {
104
                     @include topLeft();
95
                     @include topLeft();
105
-                    max-width: 12px;
106
-                    width: 12px;
107
                     color: #FFFFFF;/*#15A1ED*/
96
                     color: #FFFFFF;/*#15A1ED*/
108
                     overflow: hidden;
97
                     overflow: hidden;
109
                 }
98
                 }
116
         }
105
         }
117
     }
106
     }
118
 
107
 
119
-    &_small {
120
-        span.indicator {
121
-            font-size: 5px;
122
-
123
-            .connection {
124
-                height: 5px;
125
-            }
126
-        }
127
-    }
128
-
129
-    &_medium {
130
-        span.indicator {
131
-            font-size: 6px;
132
-
133
-            .connection {
134
-                height: 6px;
135
-            }
136
-        }
137
-    }
138
-
139
     &__hoverOverlay {
108
     &__hoverOverlay {
140
         position: relative;
109
         position: relative;
141
         width: 100%;
110
         width: 100%;

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

27
     'list-item': 'show-list-item'
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
  * Created by hristo on 12/22/14.
50
  * Created by hristo on 12/22/14.
32
  */
51
  */
463
 
482
 
464
         if (indicators.length <= 0) {
483
         if (indicators.length <= 0) {
465
             indicatorSpan = document.createElement('span');
484
             indicatorSpan = document.createElement('span');
485
+
466
             indicatorSpan.className = 'indicator';
486
             indicatorSpan.className = 'indicator';
467
             indicatorSpan.id = indicatorId;
487
             indicatorSpan.id = indicatorId;
468
 
488
 
475
                 APP.translation.translateElement($(indicatorSpan));
495
                 APP.translation.translateElement($(indicatorSpan));
476
             }
496
             }
477
 
497
 
498
+            this._resizeIndicator(indicatorSpan);
499
+
478
             document.getElementById(videoSpanId)
500
             document.getElementById(videoSpanId)
479
                 .querySelector('.videocontainer__toptoolbar')
501
                 .querySelector('.videocontainer__toptoolbar')
480
                 .appendChild(indicatorSpan);
502
                 .appendChild(indicatorSpan);
483
         }
505
         }
484
 
506
 
485
         return indicatorSpan;
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
 

+ 8
- 39
modules/UI/videolayout/FilmStrip.js 查看文件

3
 import UIEvents from "../../../service/UI/UIEvents";
3
 import UIEvents from "../../../service/UI/UIEvents";
4
 import UIUtil from "../util/UIUtil";
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
-
15
 const FilmStrip = {
6
 const FilmStrip = {
16
     /**
7
     /**
17
      *
8
      *
402
                 }, this._getAnimateOptions(animate, resolve));
393
                 }, this._getAnimateOptions(animate, resolve));
403
             }));
394
             }));
404
 
395
 
405
-            this._setThumbnailsClasses(remote.thumbHeight);
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
+            }));
406
 
404
 
407
             if (!animate) {
405
             if (!animate) {
408
                 resolve();
406
                 resolve();
427
         };
425
         };
428
     },
426
     },
429
 
427
 
430
-    /**
431
-     * Set thumbnail classes according to the current size of thumbnail
432
-     * @param height
433
-     * @private
434
-     */
435
-    _setThumbnailsClasses(height) {
436
-        const { SMALL, MEDIUM } = ThumbnailSizes;
437
-        const { localThumb, remoteThumbs } = this.getThumbs();
438
-        let smallClass = 'videocontainer_small';
439
-        let mediumClass = 'videocontainer_medium';
440
-        let className = '';
441
-
442
-        if (height <= SMALL) {
443
-            className = smallClass;
444
-        } else if (height > SMALL && height <= MEDIUM) {
445
-            className = mediumClass;
446
-        }
447
-
448
-        localThumb
449
-            .removeClass(`${smallClass} ${mediumClass}`)
450
-            .addClass(className);
451
-
452
-        if (remoteThumbs) {
453
-            remoteThumbs
454
-                .removeClass(`${smallClass} ${mediumClass}`)
455
-                .addClass(className);
456
-        }
457
-    },
458
-
459
     /**
428
     /**
460
      * Returns thumbnails of the filmstrip
429
      * Returns thumbnails of the filmstrip
461
      * @param only_visible
430
      * @param only_visible

正在加载...
取消
保存