Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make fb-video mobile responsive ? #151

Open
SimranChawla1995 opened this issue Mar 17, 2019 · 2 comments
Open

How to make fb-video mobile responsive ? #151

SimranChawla1995 opened this issue Mar 17, 2019 · 2 comments

Comments

@SimranChawla1995
Copy link

No description provided.

@SimranChawla1995
Copy link
Author

It's adding top padding. I'm not able to remove it from div with class
._3wo2._7gxm{
padding-top: 89px
}

@szymsza
Copy link

szymsza commented Apr 27, 2020

I get the same error with just pure FB SDK only on touch devices - weird situation. This workaround works for me

window.fbAsyncInit = function() {
    FB.init({
        // ...
    });

    // ------------------ FACEBOOK EMBEDDED VIDEO MOBILE WORKAROUND
    var removeTopPadding = 89;

    if ('ontouchstart' in document.documentElement) {
        FB.Event.subscribe('xfbml.render', function (a, b) {
	    var videos = $("[fb-xfbml-state='rendered'][data-href*='videos']");

	    videos.each(function () {
	        var $iframe = $(this).find("iframe");
		$iframe.height($iframe.height() + removeTopPadding);
		$iframe.css("margin-top", "-" + removeTopPadding + "px");
	    });
         });
     }
};

It increases height of the iframe by 89 pixels and moves it 89 pixels up, negating the effect of the padding.

However, this might not work in the future if the SDK changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants