RadhaKrishnaKiJaya
asked on
Add confetti animation to a jquery dialog box
Hi Experts,
I have a pop up dialog in jquery. Is it possible to add some confetti animation effect when the pop up is displayed?
Thanks in advance!
<div id="WelcomeGiftpageModalMessage" style="background-color: #e8e8e8;">
@Display(Model.WelcomeGiftPage)
</div>
<script type="text/javascript">
jQuery(document).ready(function () {
var ShowPopUp = jQuery('#ShowPopUp').val();
if (ShowPopUp == 'TRUE') {
jQuery("#WelcomeGiftpageModalMessage").dialog({
autoOpen: true,
resizable: false,
modal: true,
width: 600,
position: 'center',
});
}
});
</script>
ASKER
Thank you so much for trying to help me. The code is working. But the confetti is falling all over the page. Instead how can I just add to the popup window? Thank you again!
Noted. In this case, tweak your code to call out this confetti effect via dialog window.
<script type="text/javascript">
jQuery(document).ready(function () {
var ShowPopUp = jQuery('#ShowPopUp').val();
if (ShowPopUp == 'TRUE') {
//call confetti effect
ConfettiPopup();
jQuery("#WelcomeGiftpageModalMessage").dialog({
autoOpen: true,
resizable: false,
modal: true,
width: 600,
position: 'center',
});
}
});
function ConfettiPopup()
{
// for starting the confetti
const start = () => {
setTimeout(function() {confetti.start()}, 1000);};
// for stopping the confetti
const stop = () => {
setTimeout(function() {confetti.stop()}, 5000);};
start();
stop();
}
</script>
ASKER
Still it is happening in the whole page instead of only in the pop up. Please suggest. I really appriciate your time and help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am sorry, but it is still the same.
Thank you!
Thank you!
Can I know where's current this <div> reside in your current environment?
<div id="WelcomeGiftpageModalMessage" style="background-color: #e8e8e8;">
@Display(Model.WelcomeGiftPage)</div>
ASKER
It is in the index.cshtml file. Thank you!
@using Draftfcb.PurchasEdge.Member.ViewModels
@model MemberWelcomeGiftPageViewModel
@{
Script.Require("jQueryUI_Dialog").AtFoot();
Style.Require("jQueryUI_Orchard").AtFoot();
Script.Require("Confetti").AtFoot();
}
<div id="WelcomeGiftpageModalMessage" style="background-color: #e8e8e8;">
@Display(Model.WelcomeGiftPage)
</div>
Noted. Set dialog's autoOpen: false;
Furthermore, can I know in what condition the value will be changed to TRUE in ShowPopUp control and call out the jQuery dialog?
Furthermore, can I know in what condition the value will be changed to TRUE in ShowPopUp control and call out the jQuery dialog?
var ShowPopUp = jQuery('#ShowPopUp').val();
if (ShowPopUp == 'TRUE') {
jQuery("#WelcomeGiftpageModalMessage").dialog({
autoOpen: false,
ASKER
Unfortunately, when I make autoOpen: false, it does not pop up the dialog at all. Also for testing purpose I removed all the conditions. So It displays the dialog on document ready.
Thank you so much for your time!
Thank you so much for your time!
Can i know how you assign the "TRUE" value for this control?
Furthermore, can you share all the related code for further inspection anything keep trigger the dialog popup?
var ShowPopUp = jQuery('#ShowPopUp').val();
Furthermore, can you share all the related code for further inspection anything keep trigger the dialog popup?
ASKER
Actually the code is very simple.
Thank you so much!
if (Model.WelcomeGiftPage != null)
{
<div id="WelcomeGiftpageModalMessage" style="background-color: #e8e8e8;">
@Display(Model.WelcomeGiftPage)
</div>
@Html.Hidden("ShowPopUp", "TRUE")
Also, it is not possible for me to share all the code because of policy. Is it possible for you to make a sample program in fiddle and share with me? That would be helpful.Thank you so much!
Hi RadhaKrishnaKiJaya,
No need to share all the code here... Now only left out the challenge where the confetti effect as given only need to show at dialog box call out as mentioned in your previous post, but now somehow show in all the page: https://www.experts-exchange.com/questions/29240892/Add-confetti-animation-to-a-jquery-dialog-box.html#a43430920
So, the focus now is find out where you call out the confetti effect code will resolve the entire hassle, right?
Based on your one of the past comment at: https://www.experts-exchange.com/questions/29240892/Add-confetti-animation-to-a-jquery-dialog-box.html#a43431030 , can i get your confirmation where your dialog box will appear at footer, that could be the reason it will keep trigger and show in all pages?
No need to share all the code here... Now only left out the challenge where the confetti effect as given only need to show at dialog box call out as mentioned in your previous post, but now somehow show in all the page: https://www.experts-exchange.com/questions/29240892/Add-confetti-animation-to-a-jquery-dialog-box.html#a43430920
So, the focus now is find out where you call out the confetti effect code will resolve the entire hassle, right?
Based on your one of the past comment at: https://www.experts-exchange.com/questions/29240892/Add-confetti-animation-to-a-jquery-dialog-box.html#a43431030 , can i get your confirmation where your dialog box will appear at footer, that could be the reason it will keep trigger and show in all pages?
@using Draftfcb.PurchasEdge.Member.ViewModels
@model MemberWelcomeGiftPageViewModel
@{
Script.Require("jQueryUI_Dialog").AtFoot();
Style.Require("jQueryUI_Orchard").AtFoot();
Script.Require("Confetti").AtFoot();//call confetti function at footer?
}
<div id="WelcomeGiftpageModalMessage" style="background-color: #e8e8e8;">
@Display(Model.WelcomeGiftPage)
</div>
ASKER
May be you are right. But I am not sure where to add the Confetti .js? Any suggestion?
Thanks a lot!
Thanks a lot!
You can place the confetti script tag at end of the <body> section in the page that you want to show the confetti effect only.
Hi,
by default the css of the script you are using will display the confetti to the body so you need to adjust the CSS to display to a specific div in your popup / specific container
*To my opinion it is ok to display on the whole page body.
I would use another confetti script which has a css container, different confetti design and also have promise so you have more control on it.
Code https://github.com/loonywizard/js-confetti/tree/main/site_dist
Options https://github.com/loonywizard/js-confetti
Demo https://loonywizard.github.io/js-confetti/
by default the css of the script you are using will display the confetti to the body so you need to adjust the CSS to display to a specific div in your popup / specific container
*To my opinion it is ok to display on the whole page body.
I would use another confetti script which has a css container, different confetti design and also have promise so you have more control on it.
Code https://github.com/loonywizard/js-confetti/tree/main/site_dist
Options https://github.com/loonywizard/js-confetti
Demo https://loonywizard.github.io/js-confetti/
ASKER
Thank you so much Mr. David for your help! Right now I think it is ok if it shows on the whole page!
Thank you lenamtl for your opinion!
Thank you lenamtl for your opinion!
Open in new window
Open in new window
Include following script after your WelcomeGiftpageModalMessage <div> tag.
Open in new window
Open in new window
Open in new window
More information:
https://dev.to/official_fire/creating-a-confetti-effect-in-5-minutes-16h3