question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Twitter bento component does not resize properly

See original GitHub issue

Description

The Twitter bento component does not resize properly when the page is scrolled fast. The embed shows the unexpanded state with an expand button. In both cases, the Tweet embed will appear unbuilt when it is first scrolled into view. This indicates the intersection observer needs to be tweaked for lazy construction of the embed. This issue occurs only for the amp-twitter-1.0 version the amp-twitter-0.1 works as expected check this example for reference.

ezgif com-gif-maker

Reproduction Steps

Open https://bento-twitter-intersection-observer-issue.glitch.me URL and scroll quickly to the Twitter embed the embed should appear in non expanded state.

Relevant Logs

Uncaught (in promise) Error: changeSize attempt denied
    at Object.callback (mutator-impl.js:79)
    at Pj (resources-impl.js:927)
    at h (resources-impl.js:1642)
    at Gj.setState (finite-state-machine.js:53)
    at Ij.g.doPass (resources-impl.js:643)
    at resources-impl.js:538
    at Ll (vsync-impl.js:456)
    at Hl.g.Bh (vsync-impl.js:413)

Browser(s) Affected

No response

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

3reactions
alanorozcocommented, Feb 17, 2022

OK, right. So the issue is that Twitter is deferring the initialization until it comes inside the viewport. I guess the only two options I see are:

  1. See if Twitter’s createTweet function can be forked to initialize when further away from the current viewport, or else contact Twitter to see if they can essentially add a renderOutsideViewport parameter to createTweet.

I wonder if we can somehow hack this. When the embed is out of view we could initially style the actual twitter embed as position: fixed; opacity: 0; pointer-events: none. From the embed’s perspective, this might trick it into believing it’s in viewport and trigger the resize events. Once we get a resize event, or the container comes into view, we can revert to position: static.

2reactions
deepaklalwani97commented, Feb 21, 2022

@alanorozco Thanks for your suggestion I have created a PR https://github.com/ampproject/amphtml/pull/37740 with your mentioned workaround with this the embed now gets resized as soon as the component gets built when shown below the fold. Can you review and provide any necessary feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing the Bento component library | bentojs.dev
Bento components provide wrappers for common third party embeds that are properly sandboxed and implement performance best practices such as ...
Read more >
I2I: Create a component to display Tiktok posts #32219 - GitHub
Summary This component will consist of a Tiktok embed, which is a single video file loaded through an iframe. A TikTok video URL...
Read more >
How to Resize Pictures Properly for Twitter - Alphr
1. Open the online image converter. 2. Drag your photo into the blank box or upload it from your computer. 3. Find the...
Read more >
Akaki Khotcholava (@khotcholava9) / Twitter
Jetbrains is a company which offers a variety of IDEs and tools to developers for ... Encapsulate logic properly into an #Angular component...
Read more >
How can I make my wistia video player / playlist responsive?
Right now, videoFoam isn't dialed in for playlists - I know it is something Max wants to go back and work on, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found