]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#380] Fix getBoundingClientRect()
authorunknown <CDOT@.(none)>
Wed, 13 Apr 2011 18:34:08 +0000 (14:34 -0400)
committerunknown <CDOT@.(none)>
Wed, 13 Apr 2011 18:34:08 +0000 (14:34 -0400)
players/soundcloud/popcorn.soundcloud.js

index 04e8b3c0095205a8c9cc41733cd58806b3fbde0b..b466813e49caebb499d05599472d5be98ea44e86 100644 (file)
         }, timeupdateInterval);
       }
     },
+    
     getBoundingClientRect: function() {
-      return !this.swfObj || this.swfObj.getBoundingClientRect();
+      var b,
+          self = this;
+          
+      if ( this.swfObj ) {
+        b = this.swfObj.getBoundingClientRect();
+        
+        return {
+          bottom: b.bottom,
+          left: b.left,
+          right: b.right,
+          top: b.top,
+          
+          //  These not guaranteed to be in there
+          width: b.width || ( b.right - b.left ),
+          height: b.height || ( b.bottom - b.top )
+        };
+      } else {
+        //container = document.getElementById( this.playerId );
+        tmp = this._container.getBoundingClientRect();
+        
+        // Update bottom, right for expected values once the container loads
+        return {
+          left: tmp.left,
+          top: tmp.top,
+          width: self.offsetWidth,
+          height: self.offsetHeight,
+          bottom: tmp.top + this.width,
+          right: tmp.top + this.height
+        };
+      }
     },
+    
     registerPopcornWithPlayer: function( popcorn ) {
       if ( !this.swfObj ) {
         this.addEventListener( "load", function() {