<h1 class="block-title-suffix block-title-segment"></h1>
- <script type="text/javascript">
- var options = {
- useEasing: true,
- useGrouping: true,
- separator: ',',
- decimal: '.',
- };
-
- title_id = <?php echo $block->ID;?>;
-
- var page = jQuery('body');
- var title_prefix = page.find('#block-title-'+title_id+'-wrapper .block-title-prefix')[0];
- var title_suffix = page.find('#block-title-'+title_id+'-wrapper .block-title-suffix')[0];
-
- myTitle = jQuery("#block-title-"+title_id).text();
-
- // Remove all commas and periods for regex work. CountUp should add those back as needed
- myTitle = myTitle.replace(/[,.]/g, "");
-
- thePrefix = myTitle.match(/^(\D+)/g);
- theNumber = myTitle.match(/(\d+)/g);
- theSuffix = myTitle.match(/(\D+)$/g);
-
- // Throw the prefix and suffix text into individual elements so they remain unaffected by CountUp
- // code which removes the main block title id.
- if (thePrefix) {
- title_prefix.textContent = thePrefix[0];
- }
- if (theSuffix) {
- title_suffix.textContent = theSuffix[0];
- }
-
- var our_impact_counter = new CountUp('block-title-'+title_id, 0, parseInt(theNumber), 0, 2.5, options);
- if (!our_impact_counter.error) {
- our_impact_counter.start();
- } else {
- console.error(our_impact_counter.error);
- }
-
- </script>
-
-
</div>
<p class="block-description"><?php echo $block->post_content;?></p>
<?php if($block->url):?>
</div>
</div>
-<?php endif;?>
\ No newline at end of file
+<?php endif;?>
+
+<script type="text/javascript">
+ var countup_options = {
+ useEasing: true,
+ useGrouping: true,
+ separator: ',',
+ decimal: '.',
+ };
+
+ var page = jQuery('body');
+ var our_impact = page.find('#our-impact');
+ var our_impact_items = our_impact.find('#our-impact-items');
+ var our_impact_item_array = our_impact_items.children(".our-impact-item");
+ var our_impact_items_linked = our_impact_item_array.children('.linked');
+
+ var our_impact_seen = false;
+
+ jQuery(window).scroll(function(){
+
+ // Add extra
+ var ourImpactStart = (our_impact_items.offset().top+100);
+ var bottomPos = $(window).scrollTop() + $(window).height();
+ if ( bottomPos >= ourImpactStart && our_impact_seen == false ) {
+
+ our_impact_item_array.each(function() {
+
+ block_id = this.id.replace("block-","");
+ title_prefix = jQuery(this).find('.block-title-prefix')[0];
+ title_suffix = jQuery(this).find('.block-title-suffix')[0];
+ the_title = jQuery(this).find('.block-title-number').text();
+
+ // Remove all commas and periods for regex work. CountUp should add those back as needed
+ the_title = the_title.replace(/[,.]/g, "");
+
+ // Create prefix/suffix separate from whole title to append
+ the_prefix = the_title.match(/^(\D+)/g);
+ the_number = the_title.match(/(\d+)/g);
+ the_suffix = the_title.match(/(\D+)$/g);
+
+ // Throw the prefix and suffix text into individual elements so they remain unaffected by CountUp
+ // code which removes the main block title id.
+ if (the_prefix) {
+ title_prefix.textContent = the_prefix[0];
+ }
+ if (the_suffix) {
+ title_suffix.textContent = the_suffix[0];
+ }
+ var our_impact_counter = new CountUp('block-title-'+block_id, 0, parseInt(the_number), 0, 2.5, countup_options);
+ if (!our_impact_counter.error) {
+ our_impact_counter.start();
+ } else {
+ console.error(our_impact_counter.error);
+ }
+ });
+ // To avoid the numbers counting up multiple times
+ our_impact_seen = true;
+ }
+
+ });
+
+ // Add click event to each linked item on our_impact since they can not be anchors
+ our_impact_items_linked.each(function() {
+ this.addEventListener("click", function() {
+ window.location = jQuery(this).attr("href");
+ })
+ });
+
+
+</script>
+
\ No newline at end of file