This repository was archived by the owner on Oct 20, 2023. It is now read-only.
Preload image by adding Poppy to DOM on init#2
Open
saltymouse wants to merge 7 commits intoapvarun:masterfrom
Open
Preload image by adding Poppy to DOM on init#2saltymouse wants to merge 7 commits intoapvarun:masterfrom
saltymouse wants to merge 7 commits intoapvarun:masterfrom
Conversation
apvarun
reviewed
Jul 8, 2019
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)'; |
Owner
There was a problem hiding this comment.
Transform should be applied to this.element instead of container
Owner
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's a proof-of-concept for preloading the image by inserting the Poppy element upon instantiation.
show()method toinit()which will run upon eachnew Poppy().show()method now un-hides the Poppy element with a CSS transition animation.close()method animates the Poppy element out of view, then destroys the element.I updated example in
index.htmlthat 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!