From: unknown Date: Wed, 13 Apr 2011 18:34:08 +0000 (-0400) Subject: [#380] Fix getBoundingClientRect() X-Git-Tag: v0.5~1^2~7 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=7c635b114d7a7ae314febecf0869747ac614284e;p=popcorn-js.git [#380] Fix getBoundingClientRect() --- diff --git a/players/soundcloud/popcorn.soundcloud.js b/players/soundcloud/popcorn.soundcloud.js index 04e8b3c..b466813 100644 --- a/players/soundcloud/popcorn.soundcloud.js +++ b/players/soundcloud/popcorn.soundcloud.js @@ -584,9 +584,40 @@ }, 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() {