Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Preload image by adding Poppy to DOM on init #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

saltymouse
Copy link
Contributor

Here's a proof-of-concept for preloading the image by inserting the Poppy element upon instantiation.

  • I've moved the show() method to init() which will run upon each new Poppy().
  • The show() method now un-hides the Poppy element with a CSS transition animation.
  • The close() method animates the Poppy element out of view, then destroys the element.

I updated example in index.html that follows the new methods outlined above, so please take a look.
I don't know if this is the best way to implement it, so please give your feedback! Thanks!

src/Poppy.js Outdated
if (this.state.position === "topLeft" || this.state.position === "topRight") {
this.element.style.transform = 'translateY(10%)';
} else if (this.state.position === "bottomLeft" || this.state.position === "bottomRight") {
container.style.transform = 'translateY(0)';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transform should be applied to this.element instead of container

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@apvarun
Copy link
Owner

apvarun commented Jul 8, 2019

I'm not sold on the idea of initializing it on DOM before actually displaying it. Although this enables to have a transition, this would add unnecessary DOM elements without even displaying it.

Also, there is possibility that we wouldn't clean up these elements from the DOM if show/hide isn't called at all. And, for a use-case of such a pop-in message box, I don't think we would show it on page load. It would be show on state changes, new notifications, messages post page loading or on scroll.

Let's create an issue and get more opinions on the same to proceed.

@apvarun apvarun added the help wanted Extra attention is needed label Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants