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

🐛 Bug?: Emojisplosion effect snaps down when mobile keyboard disappears #129

Open
joemcil opened this issue Apr 20, 2023 · 3 comments
Open
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛

Comments

@joemcil
Copy link

joemcil commented Apr 20, 2023

Overview

...

using it here (https://julians-fantabulous-site-0260b5.webflow.io/old-home) on the 'join waitlist' button. on desktop it works great but on mobile it doesnt explode out of the button but just below.

using code straight from the library

<script async src="https://unpkg.com/emojisplosion/lib/global.js"></script>

<script>
window.addEventListener('DOMContentLoaded', () => {
    const button = document.querySelector('[data-trigger="emoji"]');

    const cumulativeOffset = (element) => {
        let top = 0,
            left = 0;
        do {
            top += element.offsetTop || 0;
            left += element.offsetLeft || 0;
            element = element.offsetParent;
        } while (element);

        return {
            top: top,
            left: left
        };
    };

    button.addEventListener("click", function() {
        
        emojisplosion({
        	emojis: ["🤫"],
            physics: {
                fontSize: 28,
                initialVelocities: {
                    rotation: {
                        max: 28,
                        min: -28
                    }
                },
                rotationDecelaration: 1.01
            },

 
                      
              position() {
                const offset = cumulativeOffset(button);

                return {
                    x: offset.left + button.clientWidth / 2,
                    y: offset.top + button.clientHeight / 2
                   
                   
                };
            }
        });
    });
});

</script>
@JoshuaKGoldberg JoshuaKGoldberg changed the title EmojiSplosion effect not working well on mobile EmojiSplosion effect snaps down when mobile keyboard dissapears Apr 21, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title EmojiSplosion effect snaps down when mobile keyboard dissapears EmojiSplosion effect snaps down when mobile keyboard disappears Apr 21, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title EmojiSplosion effect snaps down when mobile keyboard disappears 🐛 Bug?: Emojisplosion effect snaps down when mobile keyboard disappears Apr 23, 2023
@JoshuaKGoldberg JoshuaKGoldberg added status: needs investigation Further research required...? 🔎 type: bug Something isn't working :( 🐛 labels Apr 23, 2023
@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Apr 23, 2023

Ok @joemcil I poked around at this - and I think it's not a bug in Emojisplosion, but just a consequence of how mobile keyboard interact with the main webpage.

Context: emojis right now are positioned with CSS:

  • position: relative:
  • transform: translate(443.433px, 463.129px) rotate(189deg);

You can see how these work together by:

  1. Visiting https://julians-fantabulous-site-0260b5.webflow.io/old-home
  2. In the console, running something like setTimeout(() => { debugger; }, 2000)
  3. Clicking join the waitlist
  4. In the elements panel, selecting an emoji

Issue: because emojis are positioned relative to the page, anything that makes the page move up or down suddenly -such as a mobile keyboard- will shift the emojis. You can simulate this by running something like document.body.style.marginTop = '-10rem'; in the console.

I think the only way around this would be to make the emojis parent container relative to the bottom of the page. position: fixed; bottom: 0; height 100%;. Right now that parent container is just an unstyled <div>.

Accepting PRs to add those styles to the emojis container! But note that I haven't tried this out personally - so you'll want to make sure this doesn't add any new, unexpected bugs. 🙂

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs and removed status: needs investigation Further research required...? 🔎 labels Apr 23, 2023
@JoshuaKGoldberg JoshuaKGoldberg added status: accepting prs Please, send a pull request to resolve this! 🙏 and removed accepting prs labels Mar 27, 2024
@JoshuaKGoldberg
Copy link
Owner

@all-contributors please add @joemcil for bug.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action.
Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.
...and of course, thank you for contributing! 💙

Copy link
Contributor

@JoshuaKGoldberg

I've put up a pull request to add @joemcil! 🎉

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

JoshuaKGoldberg pushed a commit that referenced this issue Apr 1, 2024
Adds @joemcil as a contributor for bug.

This was requested by JoshuaKGoldberg [in this
comment](#129 (comment))

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛
Projects
None yet
Development

No branches or pull requests

2 participants