Confetti for the winners
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import confetti from "canvas-confetti";
|
||||
export default {
|
||||
props: {
|
||||
currentWinner: {
|
||||
@@ -99,6 +100,11 @@ export default {
|
||||
}
|
||||
this.drawing = false;
|
||||
this.drawingDone = true;
|
||||
if(this.currentName == "Amund Brandsrud"){
|
||||
this.startUberConfetti();
|
||||
return;
|
||||
}
|
||||
this.startConfetti();
|
||||
return;
|
||||
}
|
||||
this.currentName = this.attendees[
|
||||
@@ -147,9 +153,45 @@ export default {
|
||||
case 3:
|
||||
return "yellow";
|
||||
}
|
||||
},
|
||||
startConfetti(){
|
||||
var duration = 7 * 1000;
|
||||
var animationEnd = Date.now() + duration;
|
||||
var defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 };
|
||||
function randomInRange(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
var interval = setInterval(function() {
|
||||
var timeLeft = animationEnd - Date.now();
|
||||
if (timeLeft <= 0) {
|
||||
return clearInterval(interval);
|
||||
}
|
||||
var particleCount = 50 * (timeLeft / duration);
|
||||
confetti(Object.assign({}, defaults, { particleCount, origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 } }));
|
||||
confetti(Object.assign({}, defaults, { particleCount, origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 } }));
|
||||
}, 250);
|
||||
},
|
||||
startUberConfetti(){
|
||||
var duration = 7 * 1000;
|
||||
var animationEnd = Date.now() + duration;
|
||||
var defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 };
|
||||
function randomInRange(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
var interval = setInterval(function() {
|
||||
var timeLeft = animationEnd - Date.now();
|
||||
if (timeLeft <= 0) {
|
||||
return clearInterval(interval);
|
||||
}
|
||||
var particleCount = 50 * (timeLeft / duration);
|
||||
confetti({startVelocity: 65, angle: randomInRange(55, 125),particleCount: particleCount, angle: 60, spread: 55, origin: { x: 0 }});
|
||||
confetti({startVelocity: 65, angle: randomInRange(55, 125),particleCount: particleCount, angle: 120, spread: 55, origin: { x: 1 }});
|
||||
confetti({startVelocity: 65, angle: randomInRange(55, 125),spread: randomInRange(50, 70),particleCount: randomInRange(5, 15),origin: { y: 1 }});
|
||||
}, 250);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user