Kaynağa Gözat

fix(filmstrip): allow pinning of participants without streams

Click handling was added to the local thumbnail only after
receiving video. Click handling was added to remote thumbnails
only after receiving a stream. To allow for pinning through
the filmstrip in any case, always attach the click handler
on thumbnail init.
master
Leonard Kim 8 yıl önce
ebeveyn
işleme
b37bbcc622

+ 39
- 36
modules/UI/videolayout/LocalVideo.js Dosyayı Görüntüle

@@ -48,6 +48,8 @@ function LocalVideo(VideoLayout, emitter) {
48 48
 
49 49
     this.addAudioLevelIndicator();
50 50
     this.updateIndicators();
51
+
52
+    this.container.onclick = this._onContainerClick.bind(this);
51 53
 }
52 54
 
53 55
 LocalVideo.prototype = Object.create(SmallVideo.prototype);
@@ -95,42 +97,6 @@ LocalVideo.prototype.setDisplayName = function(displayName) {
95 97
 LocalVideo.prototype.changeVideo = function(stream) {
96 98
     this.videoStream = stream;
97 99
 
98
-    const localVideoClick = event => {
99
-        // TODO Checking the classes is a workround to allow events to bubble
100
-        // into the DisplayName component if it was clicked. React's synthetic
101
-        // events will fire after jQuery handlers execute, so stop propogation
102
-        // at this point will prevent DisplayName from getting click events.
103
-        // This workaround should be removeable once LocalVideo is a React
104
-        // Component because then the components share the same eventing system.
105
-        const $source = $(event.target || event.srcElement);
106
-        const { classList } = event.target;
107
-
108
-        const clickedOnDisplayName
109
-            = $source.parents('.displayNameContainer').length > 0;
110
-        const clickedOnPopover
111
-            = $source.parents('.connection-info').length > 0;
112
-        const clickedOnPopoverTrigger
113
-            = $source.parents('.popover-trigger').length > 0
114
-                || classList.contains('popover-trigger');
115
-
116
-        const ignoreClick = clickedOnDisplayName
117
-            || clickedOnPopoverTrigger
118
-            || clickedOnPopover;
119
-
120
-        // FIXME: with Temasys plugin event arg is not an event, but
121
-        // the clicked object itself, so we have to skip this call
122
-        if (event.stopPropagation && !ignoreClick) {
123
-            event.stopPropagation();
124
-        }
125
-
126
-        if (!ignoreClick) {
127
-            this.VideoLayout.handleVideoThumbClicked(this.id);
128
-        }
129
-    };
130
-
131
-    this.$container.off('click');
132
-    this.$container.on('click', localVideoClick);
133
-
134 100
     this.localVideoId = `localVideo_${stream.getId()}`;
135 101
 
136 102
     const localVideoContainer = document.getElementById('localVideoWrapper');
@@ -246,4 +212,41 @@ LocalVideo.prototype._enableDisableContextMenu = function(enable) {
246 212
     }
247 213
 };
248 214
 
215
+/**
216
+ * Callback invoked when the thumbnail is clicked. Will directly call
217
+ * VideoLayout to handle thumbnail click if certain elements have not been
218
+ * clicked.
219
+ *
220
+ * @param {MouseEvent} event - The click event to intercept.
221
+ * @private
222
+ * @returns {void}
223
+ */
224
+LocalVideo.prototype._onContainerClick = function(event) {
225
+    // TODO Checking the classes is a workround to allow events to bubble into
226
+    // the DisplayName component if it was clicked. React's synthetic events
227
+    // will fire after jQuery handlers execute, so stop propogation at this
228
+    // point will prevent DisplayName from getting click events. This workaround
229
+    // should be removeable once LocalVideo is a React Component because then
230
+    // the components share the same eventing system.
231
+    const $source = $(event.target || event.srcElement);
232
+    const { classList } = event.target;
233
+
234
+    const clickedOnDisplayName
235
+        = $source.parents('.displayNameContainer').length > 0;
236
+    const clickedOnPopover = $source.parents('.popover').length > 0
237
+            || classList.contains('popover');
238
+
239
+    const ignoreClick = clickedOnDisplayName || clickedOnPopover;
240
+
241
+    // FIXME: with Temasys plugin event arg is not an event, but the clicked
242
+    // object itself, so we have to skip this call
243
+    if (event.stopPropagation && !ignoreClick) {
244
+        event.stopPropagation();
245
+    }
246
+
247
+    if (!ignoreClick) {
248
+        this.VideoLayout.handleVideoThumbClicked(this.id);
249
+    }
250
+};
251
+
249 252
 export default LocalVideo;

+ 32
- 36
modules/UI/videolayout/RemoteVideo.js Dosyayı Görüntüle

@@ -80,6 +80,8 @@ function RemoteVideo(user, VideoLayout, emitter) {
80 80
         = this._requestRemoteControlPermissions.bind(this);
81 81
     this._setAudioVolume = this._setAudioVolume.bind(this);
82 82
     this._stopRemoteControl = this._stopRemoteControl.bind(this);
83
+
84
+    this.container.onclick = this._onContainerClick.bind(this);
83 85
 }
84 86
 
85 87
 RemoteVideo.prototype = Object.create(SmallVideo.prototype);
@@ -539,40 +541,6 @@ RemoteVideo.prototype.addRemoteStreamElement = function(stream) {
539 541
         this.setVideoType(stream.videoType);
540 542
     }
541 543
 
542
-    // Add click handler.
543
-    const onClickHandler = event => {
544
-        const $source = $(event.target || event.srcElement);
545
-        const { classList } = event.target;
546
-
547
-        const clickedOnPopover
548
-            = $source.parents('.connection-info').length > 0;
549
-        const clickedOnPopoverTrigger
550
-            = $source.parents('.popover-trigger').length > 0
551
-                || classList.contains('popover-trigger');
552
-        const clickedOnRemoteMenu
553
-            = $source.parents('.remotevideomenu').length > 0;
554
-
555
-        const ignoreClick = clickedOnPopoverTrigger
556
-            || clickedOnPopover
557
-            || clickedOnRemoteMenu;
558
-
559
-        if (!ignoreClick) {
560
-            this.VideoLayout.handleVideoThumbClicked(this.id);
561
-        }
562
-
563
-        // On IE we need to populate this handler on video <object>
564
-        // and it does not give event instance as an argument,
565
-        // so we check here for methods.
566
-        if (event.stopPropagation && event.preventDefault && !ignoreClick) {
567
-            event.stopPropagation();
568
-            event.preventDefault();
569
-        }
570
-
571
-        return false;
572
-    };
573
-
574
-    this.container.onclick = onClickHandler;
575
-
576 544
     if (!stream.getOriginalStream()) {
577 545
         return;
578 546
     }
@@ -596,8 +564,6 @@ RemoteVideo.prototype.addRemoteStreamElement = function(stream) {
596 564
         streamElement = stream.attach(streamElement);
597 565
     }
598 566
 
599
-    $(streamElement).click(onClickHandler);
600
-
601 567
     if (!isVideo) {
602 568
         this._audioStreamElement = streamElement;
603 569
 
@@ -676,6 +642,36 @@ RemoteVideo.prototype.removePresenceLabel = function() {
676 642
     }
677 643
 };
678 644
 
645
+/**
646
+ * Callback invoked when the thumbnail is clicked. Will directly call
647
+ * VideoLayout to handle thumbnail click if certain elements have not been
648
+ * clicked.
649
+ *
650
+ * @param {MouseEvent} event - The click event to intercept.
651
+ * @private
652
+ * @returns {void}
653
+ */
654
+RemoteVideo.prototype._onContainerClick = function(event) {
655
+    const $source = $(event.target || event.srcElement);
656
+    const { classList } = event.target;
657
+
658
+    const ignoreClick = $source.parents('.popover').length > 0
659
+            || classList.contains('popover');
660
+
661
+    if (!ignoreClick) {
662
+        this.VideoLayout.handleVideoThumbClicked(this.id);
663
+    }
664
+
665
+    // On IE we need to populate this handler on video <object> and it does not
666
+    // give event instance as an argument, so we check here for methods.
667
+    if (event.stopPropagation && event.preventDefault && !ignoreClick) {
668
+        event.stopPropagation();
669
+        event.preventDefault();
670
+    }
671
+
672
+    return false;
673
+};
674
+
679 675
 RemoteVideo.createContainer = function(spanId) {
680 676
     const container = document.createElement('span');
681 677
 

Loading…
İptal
Kaydet