PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.6.5
Spider Elements – Premium Elementor Widgets & Addons Library v1.6.5
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / widgets / templates / counter / counter-1.php
spider-elements / widgets / templates / counter Last commit date
counter-1.php 1 year ago counter-2.php 1 year ago
counter-1.php
98 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly.
4 }
5 ?>
6 <div class="spel-counter counters-container">
7 <?php
8 if ( ! empty( $settings['counter_value'] ) ) {
9 ?>
10 <div class="skill_item ezd-text-center">
11 <svg class="radial-progress" data-percentage="<?php echo $settings['counter_value']; ?>" viewBox="0 0 80 80">
12 <circle class="incomplete" cx="40" cy="40" r="35"></circle>
13 <circle class="complete" cx="40" cy="40" r="35"></circle>
14
15 <div class="counter-wrap">
16 <?php
17 if ( ! empty( $settings['counter_prefix'] ) ) { ?>
18 <span class="counter-prefix">
19 <?php echo $settings['counter_prefix']; ?>
20 </span>
21 <?php
22 }
23 ?>
24 <text class="percentage" x="50%" y="57%" transform="matrix(0, 1, -1, 0, 80, 0)">
25 <?php echo $settings['counter_value']; ?>
26 </text>
27 <?php
28 if ( ! empty( $settings['counter_suffix'] ) ) { ?>
29 <span class="counter-suffix">
30 <?php echo $settings['counter_suffix']; ?>
31 </span>
32 <?php
33 }
34 ?>
35 </div>
36
37 </svg>
38 </div>
39 <?php
40 }
41 if ( ! empty( $settings['counter_text'] ) ) {
42 ?>
43 <h6 class="spel_counter_title">
44 <?php echo $settings['counter_text']; ?>
45 </h6>
46 <?php
47 }
48 ?>
49 </div>
50
51 <script type=text/javascript>
52 document.addEventListener("DOMContentLoaded", function () {
53 "use strict";
54
55 // Remove svg.radial-progress .complete inline styling
56 var radialProgressElements = document.querySelectorAll("svg.radial-progress");
57 radialProgressElements.forEach(function (element) {
58 var completeCircle = element.querySelector("circle.complete");
59 if (completeCircle) {
60 completeCircle.removeAttribute("style");
61 }
62 });
63
64 window.addEventListener("scroll", function () {
65 radialProgressElements.forEach(function (element) {
66 // If svg.radial-progress is approximately 25% vertically into the window when scrolling from the top or the bottom
67 var rect = element.getBoundingClientRect();
68 var windowHeight = window.innerHeight || document.documentElement.clientHeight;
69 if (
70 rect.top <= windowHeight * 0.75 &&
71 rect.bottom >= windowHeight * 0.25
72 ) {
73 // Get percentage of progress
74 var percent = parseInt(element.getAttribute("data-percentage"));
75
76 // Get radius of the svg's circle.complete
77 var completeCircle = element.querySelector("circle.complete");
78 if (completeCircle) {
79 var radius = parseInt(completeCircle.getAttribute("r"));
80
81 // Get circumference (2πr)
82 var circumference = 2 * Math.PI * radius;
83
84 // Get stroke-dashoffset value based on the percentage of the circumference
85 var strokeDashOffset = circumference - (percent * circumference) / 100;
86
87 // Transition progress for 1.25 seconds
88 completeCircle.style.transition = "stroke-dashoffset 1.25s";
89 completeCircle.style.strokeDashoffset = strokeDashOffset;
90 }
91 }
92 });
93 });
94
95 // Trigger scroll event to initialize animations
96 window.dispatchEvent(new Event("scroll"));
97 });
98 </script>