1
- $ ( document ) . ready ( function ( ) {
2
- $ ( '.fa-bars' ) . click ( function ( ) {
3
- $ ( this ) . toggleClass ( 'fa-times' ) ;
4
- $ ( '.navbar' ) . toggleClass ( 'nav-toggle' ) ;
5
- } ) ;
1
+ $ ( document ) . ready ( function ( ) {
6
2
7
- $ ( window ) . on ( 'load scroll' , function ( ) {
8
- $ ( '.fa-bars' ) . removeClass ( 'fa-times' ) ;
9
- $ ( '.navbar' ) . removeClass ( 'nav-toggle' ) ;
3
+ $ ( '.fa-bars' ) . click ( function ( ) {
4
+ $ ( this ) . toggleClass ( 'fa-times' ) ;
5
+ $ ( '.navbar' ) . toggleClass ( 'nav-toggle' ) ;
6
+ } ) ;
10
7
11
- if ( $ ( window ) . scrollTop ( ) > 35 ) {
12
- $ ( '.header' ) . css ( {
13
- 'background' : '#002e5f' ,
14
- 'box-shadow' : '0 .2rem .5rem rgba(0,0,0,.4)'
15
- } ) ;
16
- $ ( '.login' ) . css ( {
17
- 'background' : '#227EBB' ,
18
- 'box-shadow' : 'none'
19
- } ) ;
20
- } else {
21
- $ ( '.header' ) . css ( {
22
- 'background' : 'none' ,
23
- 'box-shadow' : 'none'
24
- } ) ;
25
- $ ( ".login" ) . css ( {
26
- 'background' : '#002e5f'
27
- } ) ;
28
- }
29
- } ) ;
8
+ $ ( window ) . on ( 'load scroll' , function ( ) {
9
+ $ ( '.fa-bars' ) . removeClass ( 'fa-times' ) ;
10
+ $ ( '.navbar' ) . removeClass ( 'nav-toggle' ) ;
30
11
31
- // Function to start counting for a single counter
32
- function startCounter ( counterElement , target ) {
33
- let count = 0 ;
34
- const speed = Math . ceil ( target / 200 ) ; // Adjust the speed as needed
12
+ if ( $ ( window ) . scrollTop ( ) > 35 )
13
+ {
14
+ $ ( '.header' ) . css ( { 'background' :'#002e5f' , 'box-shadow' :'0 .2rem .5rem rgba(0,0,0,.4)' } ) ;
15
+ $ ( '.login' ) . css ( { 'background' :'#227EBB' , 'box-shadow' :'none' } ) ;
16
+ }
17
+ else
18
+ {
19
+ $ ( '.header' ) . css ( { 'background' :'none' , 'box-shadow' :'none' } ) ;
20
+ $ ( ".login" ) . css ( { background : "#002e5f" } ) ;
21
+ }
22
+ } ) ;
35
23
36
- const updateCounter = ( ) => {
37
- if ( count < target ) {
38
- count += speed ;
39
- $ ( counterElement ) . text ( count + "+" ) ;
40
- setTimeout ( updateCounter , 10 ) ;
41
- } else {
42
- $ ( counterElement ) . text ( target + "+" ) ;
43
- }
44
- } ;
45
24
46
- updateCounter ( ) ;
47
- }
25
+ ( function ( $ ) {
26
+ "use strict" ;
27
+
28
+ // $(".clients-carousel").owlCarousel({
29
+ // autoplay: true,
30
+ // dots: true,
31
+ // loop: true,
32
+ // responsive: { 0: {items: 2}, 768: {items: 4}, 900: {items: 6} }
33
+ // });
48
34
49
- // Function to check if an element is in viewport with an offset
50
- function isInViewport ( element , offset = 100 ) {
51
- const rect = element . getBoundingClientRect ( ) ;
52
- return (
53
- rect . top >= 0 &&
54
- rect . left >= 0 &&
55
- rect . bottom <= ( window . innerHeight || document . documentElement . clientHeight ) + offset &&
56
- rect . right <= ( window . innerWidth || document . documentElement . clientWidth ) + offset
57
- ) ;
58
- }
35
+ // $(".testimonials-carousel").owlCarousel({
36
+ // autoplay: true,
37
+ // dots: true,
38
+ // loop: true,
39
+ // responsive: { 0: {items: 1}, 576: {items: 2}, 768: {items: 3}, 992: {items: 4} }
40
+ // });
41
+
42
+ } ) ( jQuery ) ;
43
+ } )
59
44
60
- function initCounters ( ) {
61
- $ ( ".container" ) . each ( function ( ) {
62
- const target = parseInt ( $ ( this ) . data ( "target" ) ) ;
63
- if ( isInViewport ( this , 700 ) ) { // Adjust the offset as needed
64
- startCounter ( this , target ) ;
65
- }
66
- } ) ;
67
- }
68
-
69
- // Add a scroll event listener to start counters when in view
70
- $ ( window ) . on ( 'scroll' , function ( ) {
71
- $ ( '.counter' ) . each ( function ( ) {
72
- if ( isInViewport ( this , 700 ) && ! $ ( this ) . hasClass ( 'counted' ) ) { // Adjust the offset as needed
73
- console . log ( 'Counter in view:' , this ) ; // Debug log
74
- $ ( this ) . addClass ( 'counted' ) ;
75
- const target = parseInt ( $ ( this ) . data ( 'target' ) ) ;
45
+ $ ( document ) . ready ( function ( ) {
46
+ // Function to start counting for a single counter
47
+ function startCounter ( counterElement , target ) {
48
+ let count = 0 ;
49
+ const speed = Math . ceil ( target / 200 ) ; // Adjust the speed as needed
50
+
51
+ const updateCounter = ( ) => {
52
+ if ( count < target ) {
53
+ count += speed ;
54
+ $ ( counterElement ) . text ( count + "+" ) ;
55
+ setTimeout ( updateCounter , 10 ) ;
56
+ } else {
57
+ $ ( counterElement ) . text ( target + "+" ) ; // Ensure the final value is accurate
58
+ }
59
+ } ;
60
+
61
+ updateCounter ( ) ;
62
+ }
63
+
64
+ // Function to initialize all counters
65
+ function initCounters ( ) {
66
+ $ ( ".counter" ) . each ( function ( ) {
67
+ const target = parseInt ( $ ( this ) . data ( "target" ) ) ;
76
68
startCounter ( this , target ) ;
77
- }
78
- } ) ;
79
- } ) ;
80
-
81
- // Initial check to start counters if already in view
82
- $ ( window ) . trigger ( 'scroll' ) ;
83
- } ) ;
69
+ } ) ;
70
+ }
71
+
72
+ // Call the initCounters function when the document is ready
73
+ initCounters ( ) ;
74
+ } ) ;
0 commit comments