Browse Source

Fix so iframe and thumb can be in tree and not root of player

Joachim M. Giæver 4 years ago
parent
commit
2784964340
1 changed files with 10 additions and 8 deletions
  1. 10 8
      index.html

+ 10 - 8
index.html

@@ -49,7 +49,9 @@
         -->
         <div class="player">
             <img class="thumb" src="./thumb.png" alt="Thumbnail" />
+            <div class="something wf realated classed and shit">
             <iframe src="https://www.youtube-nocookie.com/embed/dcsvMySGmS8?enablejsapi=1" frameborder="0" allow="autoplay; encrypted-media; gyroscope" allowfullscreen></iframe>
+            </div>
         </div>
 
         <!-- additional players -->
@@ -86,8 +88,8 @@
                         return;
 
                     // Remove thumb and show iframe
-                    player.children('.thumb').slideUp();
-                    player.children('iframe').slideDown({
+                    player.find('.thumb').slideUp();
+                    player.find('iframe').slideDown({
                         complete: function () {
                             // When fully opened, plat video and change cursor
                             ytp[i].playVideo()
@@ -111,16 +113,16 @@
                     ytp[i].stopVideo();
 
                     // Hide iframe and show thumg
-                    player.children('iframe').slideUp()
-                    player.children('.thumb').slideDown(function() {
+                    player.find('iframe').slideUp()
+                    player.find('.thumb').slideDown(function() {
                         player.removeClass('stop loading').addClass('play');
                     });
                 }
 
                 // Make sure Iframe has the same size as the thumb-img
                 var adoptThumbSizeToIframe = function (player) {
-                    var ytvid = player.children('iframe');
-                    var thumb = player.children('.thumb');
+                    var ytvid = player.find('iframe');
+                    var thumb = player.find('.thumb');
 
 
                     var hidden = thumb.is(':hidden');
@@ -147,7 +149,7 @@
                     var d = $(document).scrollTop();
 
                     $('.player').each(function (i) {
-                        if ($(this).children('iframe:visible').length == 0)
+                        if ($(this).find('iframe:visible').length == 0)
                             return; // player not open (already showing thumb)
 
                         var x = $(this).offset()['top']; 
@@ -181,7 +183,7 @@
                     */
                     $(".player").each(function (i) {
                         var player = $(this).addClass('loading');
-                        var ytvid = player.children('iframe').hide();
+                        var ytvid = player.find('iframe').hide();
                         adoptThumbSizeToIframe(player);
 
                         // Generate and add id to the iframe