MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / handleEvent

Function handleEvent

assets/js/BackgroundEffect.js:41–113  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

39}
40
41function handleEvent(e) {
42 if (e.touches) {
43 e.preventDefault();
44 e = e.touches[0];
45 }
46 var currentColor = colorPicker.current();
47 var nextColor = colorPicker.next();
48 var targetR = calcPageFillRadius(e.pageX, e.pageY);
49 var rippleSize = Math.min(200, cW * 0.4);
50 var minCoverDuration = 750;
51
52 var pageFill = new Circle({
53 x: e.pageX,
54 y: e.pageY,
55 r: 0,
56 fill: nextColor,
57 });
58 var fillAnimation = anime({
59 targets: pageFill,
60 r: targetR,
61 duration: Math.max(targetR / 2, minCoverDuration),
62 easing: "easeOutQuart",
63 complete: function () {
64 bgColor = pageFill.fill;
65 removeAnimation(fillAnimation);
66 },
67 });
68
69 var ripple = new Circle({
70 x: e.pageX,
71 y: e.pageY,
72 r: 0,
73 fill: currentColor,
74 stroke: {
75 width: 3,
76 color: currentColor,
77 },
78 opacity: 1,
79 });
80 var rippleAnimation = anime({
81 targets: ripple,
82 r: rippleSize,
83 opacity: 0,
84 easing: "easeOutExpo",
85 duration: 900,
86 complete: removeAnimation,
87 });
88
89 var particles = [];
90 for (var i = 0; i < 32; i++) {
91 var particle = new Circle({
92 x: e.pageX,
93 y: e.pageY,
94 fill: currentColor,
95 r: anime.random(24, 48),
96 });
97 particles.push(particle);
98 }

Callers

nothing calls this directly

Calls 2

calcPageFillRadiusFunction · 0.85
removeAnimationFunction · 0.85

Tested by

no test coverage detected