1097 }
1098 function x(t) {
1099 if (!t) return document.body;
1100 switch (t.nodeName) {1101 case "HTML":1102 case "BODY":1103 return t.ownerDocument.body;1104 case "#document":1105 return t.body;1106 }1107 var e = I(t),
1108 n = e.overflow,
1109 i = e.overflowX,
583 }),
584 (e._keydown = function (t) {
585 if (!/input|textarea/i.test(t.target.tagName))
586 switch (t.which) { 587 case 37: 588 t.preventDefault(), this.prev(); 589 break; 590 case 39: 591 t.preventDefault(), this.next(); 592 } 593 }),
594 (e._getItemIndex = function (t) {
595 return (
1143 pJS.interactivity.mouse.click_time = new Date().getTime();
1144
1145 if (pJS.interactivity.events.onclick.enable) {
1146 switch (pJS.interactivity.events.onclick.mode) {1147 case "push":1148 if (pJS.particles.move.enable) {1149 pJS.fn.modes.pushParticles(1150 pJS.interactivity.modes.push.particles_nb,1151 pJS.interactivity.mouse,1152 );1153 } else {1154 if (pJS.interactivity.modes.push.particles_nb == 1) {1155 pJS.fn.modes.pushParticles(1156 pJS.interactivity.modes.push.particles_nb,1157 pJS.interactivity.mouse,1158 );1159 } else if (pJS.interactivity.modes.push.particles_nb > 1) {1160 pJS.fn.modes.pushParticles(1161 pJS.interactivity.modes.push.particles_nb,1162 );1163 }1164 }1165 break;11661167 case "remove":1168 pJS.fn.modes.removeParticles(1169 pJS.interactivity.modes.remove.particles_nb,1170 );1171 break;11721173 case "bubble":1174 pJS.tmp.bubble_clicking = true;1175 break;11761177 case "repulse":1178 pJS.tmp.repulse_clicking = true;1179 pJS.tmp.repulse_count = 0;1180 pJS.tmp.repulse_finish = false;1181 setTimeout(function () {1182 pJS.tmp.repulse_clicking = false;1183 }, pJS.interactivity.modes.repulse.duration * 1000);1184 break;1185 }1186 }
1187 });
1188 }
603 }
604
605 /* out of canvas modes */
606 switch (pJS.particles.move.out_mode) { 607 case "bounce": 608 if (p.x + p.radius > pJS.canvas.w) p.vx = -p.vx; 609 else if (p.x - p.radius < 0) p.vx = -p.vx; 610 if (p.y + p.radius > pJS.canvas.h) p.vy = -p.vy; 611 else if (p.y - p.radius < 0) p.vy = -p.vy; 612 break; 613 } 614
615 /* events */
616 if (isInArray("grab", pJS.interactivity.events.onhover.mode)) {
438 pJS.canvas.ctx.fillStyle = color_value;
439 pJS.canvas.ctx.beginPath();
440
441 switch (p.shape) { 442 case "circle": 443 pJS.canvas.ctx.arc(p.x, p.y, radius, 0, Math.PI * 2, false); 444 break; 445 446 case "edge": 447 pJS.canvas.ctx.rect(p.x - radius, p.y - radius, radius * 2, radius * 2); 448 break; 449 450 case "triangle": 451 pJS.fn.vendors.drawShape( 452 pJS.canvas.ctx, 453 p.x - radius, 454 p.y + radius / 1.66, 455 radius * 2, 456 3, 457 2, 458 ); 459 break; 460 461 case "polygon": 462 pJS.fn.vendors.drawShape( 463 pJS.canvas.ctx, 464 p.x - radius / (pJS.particles.shape.polygon.nb_sides / 3.5), // startX 465 p.y - radius / (2.66 / 3.5), // startY 466 (radius * 2.66) / (pJS.particles.shape.polygon.nb_sides / 3), // sideLength 467 pJS.particles.shape.polygon.nb_sides, // sideCountNumerator 468 1, // sideCountDenominator 469 ); 470 break; 471 472 case "star": 473 pJS.fn.vendors.drawShape( 474 pJS.canvas.ctx, 475 p.x - (radius * 2) / (pJS.particles.shape.polygon.nb_sides / 4), // startX 476 p.y - radius / ((2 * 2.66) / 3.5), // startY 477 (radius * 2 * 2.66) / (pJS.particles.shape.polygon.nb_sides / 3), // sideLength 478 pJS.particles.shape.polygon.nb_sides, // sideCountNumerator 479 2, // sideCountDenominator 480 ); 481 break; 482 483 case "image": 484 function draw() { 485 pJS.canvas.ctx.drawImage( 486 img_obj, 487 p.x - radius, 488 p.y - radius, 489 radius * 2, 490 (radius * 2) / p.img.ratio, 491 ); 492 } 493 494 if (pJS.tmp.img_type == "svg") { 495 var img_obj = p.img.obj; 496 } else { 497 var img_obj = pJS.tmp.img_obj; 498 } 499 500 if (img_obj) { 501 draw(); 502 } 503 504 break; 505 } 506
507 pJS.canvas.ctx.closePath();
508
Some code conventions require that all switch statements have a default case, even if the default case is empty. The idea is to always explicitly state what the default behavior should be so that it's clear that the developer didn't forget to handle the default fallback case.
switch (a) {
case 1:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
default:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
// no default
}
switch (a) {
case 1:
/* code */
break;
// No Default
}