Browse Source

Makes decision what to show in avatar consistent (in updateView).

j8
damencho 8 years ago
parent
commit
2807346bdf

+ 1
- 1
css/_videolayout_default.scss View File

@@ -85,7 +85,7 @@
85 85
     position: relative;
86 86
     width: 100%;
87 87
     height: 100%;
88
-    display: none;
88
+    visibility: hidden;
89 89
     background: rgba(0,0,0,.6);
90 90
     z-index: 2;
91 91
 }

+ 13
- 0
modules/UI/util/JitsiPopover.js View File

@@ -98,14 +98,27 @@ var JitsiPopover = (function () {
98 98
         var self = this;
99 99
         $(".jitsipopover").on("mouseenter", function () {
100 100
             self.popoverIsHovered = true;
101
+            if(typeof self.onHoverPopover === "function") {
102
+                self.onHoverPopover(self.popoverIsHovered);
103
+            }
101 104
         }).on("mouseleave", function () {
102 105
             self.popoverIsHovered = false;
103 106
             self.hide();
107
+            if(typeof self.onHoverPopover === "function") {
108
+                self.onHoverPopover(self.popoverIsHovered);
109
+            }
104 110
         });
105 111
 
106 112
         this.refreshPosition();
107 113
     };
108 114
 
115
+    /**
116
+     * Adds a hover listener to the popover.
117
+     */
118
+    JitsiPopover.prototype.addOnHoverPopover = function (listener) {
119
+        this.onHoverPopover = listener;
120
+    };
121
+
109 122
     /**
110 123
      * Refreshes the position of the popover.
111 124
      */

+ 7
- 0
modules/UI/videolayout/ConnectionIndicator.js View File

@@ -439,4 +439,11 @@ ConnectionIndicator.prototype.updateResolutionIndicator = function () {
439 439
     }
440 440
 };
441 441
 
442
+/**
443
+ * Adds a hover listener to the popover.
444
+ */
445
+ConnectionIndicator.prototype.addPopoverHoverListener = function (listener) {
446
+    this.popover.addOnHoverPopover(listener);
447
+};
448
+
442 449
 export default ConnectionIndicator;

+ 1
- 1
modules/UI/videolayout/LocalVideo.js View File

@@ -11,6 +11,7 @@ function LocalVideo(VideoLayout, emitter) {
11 11
     this.videoSpanId = "localVideoContainer";
12 12
     this.container = $("#localVideoContainer").get(0);
13 13
     this.localVideoId = null;
14
+    this.createConnectionIndicator();
14 15
     this.bindHoverHandler();
15 16
     if(config.enableLocalVideoFlip)
16 17
         this._buildContextMenu();
@@ -28,7 +29,6 @@ function LocalVideo(VideoLayout, emitter) {
28 29
     // Set default display name.
29 30
     this.setDisplayName();
30 31
 
31
-    this.createConnectionIndicator();
32 32
     this.addAudioLevelIndicator();
33 33
 }
34 34
 

+ 62
- 24
modules/UI/videolayout/SmallVideo.js View File

@@ -21,11 +21,27 @@ const DISPLAY_VIDEO = 0;
21 21
 const DISPLAY_AVATAR = 1;
22 22
 /**
23 23
  * Display mode constant used when neither video nor avatar is being displayed
24
- * on the small video.
24
+ * on the small video. And we just show the display name.
25 25
  * @type {number}
26 26
  * @constant
27 27
  */
28
-const DISPLAY_BLACKNESS = 2;
28
+const DISPLAY_BLACKNESS_WITH_NAME = 2;
29
+
30
+/**
31
+ * Display mode constant used when video is displayed and display name
32
+ * at the same time.
33
+ * @type {number}
34
+ * @constant
35
+ */
36
+const DISPLAY_VIDEO_WITH_NAME = 3;
37
+
38
+/**
39
+ * Display mode constant used when neither video nor avatar is being displayed
40
+ * on the small video. And we just show the display name.
41
+ * @type {number}
42
+ * @constant
43
+ */
44
+const DISPLAY_AVATAR_WITH_NAME = 4;
29 45
 
30 46
 function SmallVideo(VideoLayout) {
31 47
     this.isAudioMuted = false;
@@ -34,6 +50,7 @@ function SmallVideo(VideoLayout) {
34 50
     this.videoStream = null;
35 51
     this.audioStream = null;
36 52
     this.VideoLayout = VideoLayout;
53
+    this.videoIsHovered = false;
37 54
 }
38 55
 
39 56
 /**
@@ -144,30 +161,26 @@ SmallVideo.getStreamElementID = function (stream) {
144 161
 };
145 162
 
146 163
 /**
147
- * Configures hoverIn/hoverOut handlers.
164
+ * Configures hoverIn/hoverOut handlers. Depends on connection indicator.
148 165
  */
149 166
 SmallVideo.prototype.bindHoverHandler = function () {
150 167
     // Add hover handler
151 168
     $(this.container).hover(
152 169
         () => {
153
-            if (!this.VideoLayout.isCurrentlyOnLarge(this.id)) {
154
-                $('#' + this.videoSpanId + ' .videocontainer__overlay')
155
-                    .removeClass("hide")
156
-                    .addClass("show-inline");
157
-                UIUtil.setVisibility(this.$displayName(), true);
158
-            }
170
+            this.videoIsHovered = true;
171
+            this.updateView();
159 172
         },
160 173
         () => {
161
-            $('#' + this.videoSpanId + ' .videocontainer__overlay')
162
-                .removeClass("show-inline")
163
-                .addClass("hide");
164
-            // If the video has been "pinned" by the user we want to
165
-            // keep the display name on place.
166
-            if (!this.VideoLayout.isLargeVideoVisible() ||
167
-                !this.VideoLayout.isCurrentlyOnLarge(this.id))
168
-                UIUtil.setVisibility(this.$displayName(), false);
174
+            this.videoIsHovered = false;
175
+            this.updateView();
169 176
         }
170 177
     );
178
+    if (this.connectionIndicator) {
179
+        this.connectionIndicator.addPopoverHoverListener(
180
+            () => {
181
+                this.updateView();
182
+            });
183
+    }
171 184
 };
172 185
 
173 186
 /**
@@ -433,19 +446,34 @@ SmallVideo.prototype.isVideoPlayable = function() {
433 446
  * Determines what should be display on the thumbnail.
434 447
  *
435 448
  * @return {number} one of <tt>DISPLAY_VIDEO</tt>,<tt>DISPLAY_AVATAR</tt>
436
- * or <tt>DISPLAY_BLACKNESS</tt>.
449
+ * or <tt>DISPLAY_BLACKNESS_WITH_NAME</tt>.
437 450
  */
438 451
 SmallVideo.prototype.selectDisplayMode = function() {
439 452
     // Display name is always and only displayed when user is on the stage
440 453
     if (this.isCurrentlyOnLargeVideo()) {
441
-        return DISPLAY_BLACKNESS;
454
+        return DISPLAY_BLACKNESS_WITH_NAME;
442 455
     } else if (this.isVideoPlayable() && this.selectVideoElement().length) {
443
-        return DISPLAY_VIDEO;
456
+        // check hovering and change state to video with name
457
+        return this._isHovered() ?
458
+            DISPLAY_VIDEO_WITH_NAME : DISPLAY_VIDEO;
444 459
     } else {
445
-        return DISPLAY_AVATAR;
460
+        // check hovering and change state to avatar with name
461
+        return this._isHovered() ?
462
+            DISPLAY_AVATAR_WITH_NAME : DISPLAY_AVATAR;
446 463
     }
447 464
 };
448 465
 
466
+/**
467
+ * Checks whether current video is considered hovered. Currently it is hovered
468
+ * if the mouse is over the video, or if the connection
469
+ * indicator is shown(hovered).
470
+ * @private
471
+ */
472
+SmallVideo.prototype._isHovered = function () {
473
+    return this.videoIsHovered
474
+        || this.connectionIndicator.popover.popoverIsHovered;
475
+};
476
+
449 477
 /**
450 478
  * Hides or shows the user's avatar.
451 479
  * This update assumes that large video had been updated and we will
@@ -469,13 +497,23 @@ SmallVideo.prototype.updateView = function () {
469 497
     let displayMode = this.selectDisplayMode();
470 498
     // Show/hide video.
471 499
     UIUtil.setVisibility(   this.selectVideoElement(),
472
-                            displayMode === DISPLAY_VIDEO);
500
+                            (displayMode === DISPLAY_VIDEO
501
+                                || displayMode === DISPLAY_VIDEO_WITH_NAME));
473 502
     // Show/hide the avatar.
474 503
     UIUtil.setVisibility(   this.$avatar(),
475
-                            displayMode === DISPLAY_AVATAR);
504
+                            (displayMode === DISPLAY_AVATAR
505
+                                || displayMode === DISPLAY_AVATAR_WITH_NAME));
476 506
     // Show/hide the display name.
477 507
     UIUtil.setVisibility(   this.$displayName(),
478
-                            displayMode === DISPLAY_BLACKNESS);
508
+                            (displayMode === DISPLAY_BLACKNESS_WITH_NAME
509
+                                || displayMode === DISPLAY_VIDEO_WITH_NAME
510
+                                || displayMode === DISPLAY_AVATAR_WITH_NAME));
511
+    // show hide overlay when there is a video or avatar under
512
+    // the display name
513
+    UIUtil.setVisibility(   $('#' + this.videoSpanId
514
+                                + ' .videocontainer__overlay'),
515
+                            (displayMode === DISPLAY_AVATAR_WITH_NAME
516
+                                || displayMode === DISPLAY_VIDEO_WITH_NAME));
479 517
 };
480 518
 
481 519
 SmallVideo.prototype.avatarChanged = function (avatarUrl) {

Loading…
Cancel
Save