Geek7 commited on
Commit
1e3bc1b
·
1 Parent(s): b521abc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -25
app.py CHANGED
@@ -1,29 +1,27 @@
1
- import streamlit as st
2
  import streamlit.components.v1 as components
3
 
4
- # JavaScript code for confetti animation
5
- confetti_animation_script = """
6
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
7
- <script>
8
- function triggerConfetti() {
9
- confetti({
10
- angle: randomInRange(55, 125),
11
- particleCount: randomInRange(50, 100),
12
- origin: { y: 0.6 },
13
- spread: randomInRange(50, 70),
14
- });
15
- }
16
 
17
- function randomInRange(min, max) {
18
- return Math.random() * (max - min) + min;
19
- }
20
- </script>
21
- """
 
 
 
 
 
22
 
23
- # Display the confetti animation script
24
- components.html(confetti_animation_script, height=0)
25
-
26
- # Button to trigger confetti
27
- if st.button("Click for Confetti"):
28
- st.empty() # Optional, clears the button after clicking
29
- st.write("Confetti time!")
 
 
1
+ import streamlit as st
2
  import streamlit.components.v1 as components
3
 
4
+ components.html(
5
+ """
6
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
7
+ <button onclick="triggerConfetti()">Click for Confetti</button>
 
 
 
 
 
 
 
 
8
 
9
+ <script>
10
+ // Function to trigger the confetti effect with random directions
11
+ function triggerConfetti() {
12
+ confetti({
13
+ angle: randomInRange(55, 125),
14
+ particleCount: randomInRange(50, 100),
15
+ origin: { y: 0.6 },
16
+ spread: randomInRange(50, 70),
17
+ });
18
+ }
19
 
20
+ function randomInRange(min, max) {
21
+ return Math.random() * (max - min) + min;
22
+ }
23
+ </script>
24
+ """
25
+ )
26
+
27
+