Add option to show modal on page load if hash in URL matches an id of initialized modal #383
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.
Thanks for the project @ghosh, @kakadiadarpan and @kalpeshsingh! It's my favorite library for modals.
But in my opinion, it's missing an important feature - being able to open the page with an opened modal.
This feature is especially useful in multipage CMS-driven websites. For example, if a backend developer needs to open the page with an already opened modal and he may not want to make it with JS directly.
I implement this option trying not to break anything. Now you could set this option to true (default is false) and add a hash that matches the id of initialized with triggers (not programmatically, of course) modal, the modal will be shown on page load.
I've tried not to bump library size, also have fixed some issues in naming, inconsistencies in quotes usage and replaced let with const in two place, where value is not changing anytime some.
I've updated the docs accordingly and turn the feature on for the demo page in case anyone would want to try it out. (works with
#modal-1
)It's my first contribution to open-source, so if I've made something wrong, sorry in advance. Oh, I accidently commit from another account, just forgot to change credentials.
Have a nice day :)