29 January 2025

How to add google auto search places and change date picker format in elementor's input?

Add google auto search places and change date picker format in elementor's input

add_action('wp_footer',function(){

    ?>


<script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.13/flatpickr.min.js" integrity="sha512-K/oyQtMXpxI4+K0W7H25UopjM8pzq0yrVdFdG21Fh5dBe91I40pDd9A4lzNlHPHBIP2cwZuoxaUSX0GJSObvGA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAPvILrgZkge5Bhu37t6Vi4kL-iSwx3t-k&libraries=places" defer></script>


<script>

    jQuery(document).ready(function($) {


        $('input[name="form_fields[field_0b486bd]"], input[name="form_fields[field_ffb1494]"]').each(function() {

            var input = this; 


            if (typeof google !== 'undefined') {


                var autocomplete = new google.maps.places.Autocomplete(input, {

                    componentRestrictions: { country: 'ca' },  

                    types: ['geocode']  

                });


                google.maps.event.addListener(autocomplete, 'place_changed', function() {

                    var place = autocomplete.getPlace();

                    if (place.geometry) {


                        console.log("Selected place: ", place);

                    } else {

                        console.log("Place not found");

                    }

                });

            }

        });


    });


jQuery(document).ready(function($){


    setTimeout(function() {

        flatpickr(".flatpickr-input", {

            minDate: "today",  

            dateFormat: "Y-m-d", 

        });

    }, 1000); 

});


</script>


<?php

});

How to create section Showcase/Scale animation in viewport with Scrollmagic?

Section Showcase/Scale animation in viewport with Scrollmagic 


add_action("wp_head", function () {

    ?>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.1/gsap.min.js"></script> <!-- GSAP -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script> <!-- ScrollMagic GSAP Plugin -->

    <script>


document.addEventListener("DOMContentLoaded", function() {


var controller = new ScrollMagic.Controller();


var targetElement = document.querySelector("#animate2");

var bodyElement = document.querySelector("body");

var triggerElement1 = document.querySelector("#trigger3"); 

var triggerElement2 = document.querySelector("#trigger4"); 


if (targetElement && triggerElement1 && triggerElement2) {


    var screenWidth = screen.width;

    var screenHeight = screen.height;


    console.log("Screen resolution: " + screenWidth + "x" + screenHeight);


   var scene2 = new ScrollMagic.Scene({

      triggerElement: "#trigger3",   

      triggerHook: 0.5,                

      duration: screenHeight,                 

    })

    .on("progress", function(e) {


      var progressHeight = e.progress * screenHeight; 

      targetElement.style.height = progressHeight + "px"; 

    })

    .setTween(

      gsap.to(targetElement, {

        backgroundColor: "green", 

        ease: "power1.out", 

      })

    )


    .addTo(controller); 


    var animationPlaying = false;


    triggerElement2.addEventListener("click", function() {

        if (animationPlaying) {


            scene.reverse();

            resetAnimation(targetElement); 

            animationPlaying = false; 

        }

    });


    scene.on("start", function() {

        animationPlaying = true; 

    });


    scene.on("end", function() {

        animationPlaying = false; 

        resetAnimation(targetElement); 

    });


} else {

    console.error("Elements #animate1, #trigger1 or #trigger2 not found!");

}


function resetAnimation(element) {

    element.style.backgroundColor = ""; 

    element.style.transform = ""; 

}

});

    </script>

    <?php

});

?>


/*---------------------CSS---------------------------*/

.home {

    position: relative;

 }

 body::after {

     background: #fff5f9c9;

     width: 100%;

     height: 100%;

     content: "";

     position: fixed;

     top: 0;

     bottom: 0;

     left: 0;

     right: 0;

     z-index: 9999;

     transition: 0.5s all;

     opacity: 0;

     pointer-events: none;

 }

 .activeOverlay::after{

     opacity: 1;

     pointer-events: unset;

 }

 #animate1{

     transition: 0.5s all;

     z-index: 999999; 

 }

 .activeScaleAnimation {

     transition: 0.5s all;

     transform: scale(1.2);

 }

 

How to create bubble scale animation with Scrollmagic?

 Create bubble scale animation with Scrollmagic

add_action("wp_head", function () {

    ?>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.1/gsap.min.js"></script> <!-- GSAP -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script> <!-- ScrollMagic GSAP Plugin -->

    <script>


document.addEventListener("DOMContentLoaded", function() {

    var controller = new ScrollMagic.Controller();

    var scene = new ScrollMagic.Scene({

triggerElement: "#bubbleTrigger1"

})

                        .setClassToggle(".bubbleAnimate", "activebubble") 

                        .addTo(controller);


});

</script>

<?php

});

?>


/*---------------------CSS---------------------------*/

.bubbleAnimate {

    position: relative;

    overflow: hidden !important;

}

.bubbleAnimate::after {

    width: 30px;

    height: 30px;

    z-index: -2;

    content: "";

    background: #FFF5F9;

    position: absolute;

    top: -15px;

    left: 0;

    right: 0;

    border-radius: 200%;

    margin: auto;

    transition: 0.9s all;

}

.activebubble::after{

    transform: scale(100);

}

How to create section progress bar with Scrollmagic?

Create section progress bar with Scrollmagic 


add_action("wp_head", function () {

    ?>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.1/gsap.min.js"></script> <!-- GSAP -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script> <!-- ScrollMagic GSAP Plugin -->

    <script>

       document.addEventListener("DOMContentLoaded", function() {


    var controller = new ScrollMagic.Controller();


    var targetElement = document.querySelector("#animate1");

    var bodyElement = document.querySelector("body");

    var triggerElement1 = document.querySelector("#trigger1"); 

    var triggerElement2 = document.querySelector("#trigger2"); 


    if (targetElement && triggerElement1 && triggerElement2) {


             var scene1 = new ScrollMagic.Scene({

            triggerElement: triggerElement1, 

            triggerHook: 0.2, 

            duration: 800 

        })

        .setClassToggle(bodyElement, 'activeOverlay') 


        .addTo(controller); 


        var scene2 = new ScrollMagic.Scene({

            triggerElement: triggerElement1, 

            triggerHook: 0.2, 

            duration: 800 

        })

        .setClassToggle(targetElement, 'activeScaleAnimation') 


        .addTo(controller); 


        var animationPlaying = false;


        triggerElement2.addEventListener("click", function() {

            if (animationPlaying) {


                scene.reverse();

                resetAnimation(targetElement); 

                animationPlaying = false; 

            }

        });


        scene.on("start", function() {

            animationPlaying = true; 

        });


        scene.on("end", function() {

            animationPlaying = false; 

            resetAnimation(targetElement); 

        });


    } else {

        console.error("Elements #animate1, #trigger1 or #trigger2 not found!");

    }


    function resetAnimation(element) {


        element.style.backgroundColor = ""; 

        element.style.transform = ""; 

    }

});

</script>

<?php

});

?>


/*---------------------CSS---------------------------*/


#animate2 {

    background: #ffe9f2 !important;

    width: 3px;

    height: 0px;

    position: absolute;

    top: -21px;

    left: 0;

    right: 0;

    margin: auto;

    z-index: 0;

}

.scrollBarSection{

    position: relative;

}

How to create CSS Animation?

Create CSS Animation


/*-------zoom out and in Animation----*/  

@keyframes animation-5 {

0% {

  transform: scale(1);

}

100% {

  transform: scale(1.1);

}

}

  

.aniamtion-key-5 {

    position: relative;

    animation-name: animation-5;

    animation-duration: 1.5s;

    animation-iteration-count: infinite;

    animation-direction: alternate;

    transition: all 0.4s ease-in-out;

}


/*-------Left to right Animation----*/ 

  @keyframes animation-2 {

    0% {

      transform: translateX(0);

    }

    100% {

      transform: translateX(50px);

    }

  }


.aniamtion-key-2 {

    position: relative;

    animation-name: animation-2;

    animation-duration: 2.5s;

    animation-iteration-count: infinite;

    animation-direction: alternate;

}


/*-------Top to bottom Animation----*/ 

@keyframes animation-1 {

0% {

  transform: translateY(0);

}

100% {

  transform: translateY(30px);

}

}


.aniamtion-key-1 {

    position: relative;

    animation-name: animation-1;

    animation-duration: 3s;

    animation-iteration-count: infinite;

    animation-direction: alternate;

}


/*-------Rotating Animation----*/  

@keyframes animation-7 {

0% {

  transform: rotate(0);

}

100% {

  transform: rotate(-1000deg);

}

}

  

.keyframe5 {

    position: relative;

    animation-name: animation-7;

    animation-duration: 90s;

    animation-iteration-count: infinite;

    animation-direction: alternate;

    animation-timing-function: cubic-bezier(0.59, 0.59, 1, 1);

}

 

How to track truck/Ball on track/Road animation with scroll trigger(GSAP Animation)?

 Track truck/Ball on track/Road animation with scroll trigger(GSAP Animation)




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Truck on Curvy Road</title>
  <style>
    body {
      margin: 0;
      font-family: Arial, sans-serif;
    }

    .container {
      position: relative;
      width: 100%;
      height: 4320px; /* Height based on your path's size */
      overflow: hidden;
    }

    .road {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 4320px; /* Match the height of the container */
    }
.truck {
    position: absolute;
    width: 60px;
    height: 60px;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

    .blocks {
      height: 100vh;
      width: 100%;
      background: pink;
      display: block;
      border: 1px solid black;
    }



.circle {
    display: block;
    width: 100px;
    height: 100px;
    background: #FFE9F2;
    border-radius: 50%;
    background: -webkit-radial-gradient(15px 10px, circle, #FFE9F2, #ffc0cb);
    background: -moz-radial-gradient(25px 25px, circle, red, #000);
    background: radial-gradient(25px 25px, circle, red, #000);
    -webkit-animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite;
    -moz-animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite;
    -ms-animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite;
    animation: spin 1000ms linear infinite, moveLeftToRight 5s linear infinite;
    -webkit-transition: all 1s ease;
    transition: all 1s ease;
    position: absolute;
    left: 0;
}

/* Spinning the sphere using key frames */
@-ms-keyframes spin {
  from { -ms-transform: rotate(0deg); }
  to { -ms-transform: rotate(360deg); }
}
@-moz-keyframes spin {
  from { -moz-transform: rotate(0deg); }
  to { -moz-transform: rotate(360deg); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@-webkit-keyframes spin {
  from { -webkit-transform: rotate(0deg); }
  to { -webkit-transform: rotate(360deg); }
}


  </style>
</head>
<body>
  <div class="blocks"></div>
  <div class="container">
    <!-- SVG Path for the road -->
    <svg class="road" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 4320">
      <defs>
        <style>
          .st0, .st1 {
            fill: none;
            stroke: #FFE9F2;
            stroke-miterlimit: 10;
          }

          .st1 {
            stroke-width: 5px;
          }
        </style>
      </defs>
      <path class="st1" id="road-path"  d="M2000.7,4860l-1690.4-887.7c-179.2-94.1-179.2-290.6,0-384.7l1324.1-695.3c179.2-94.1,179.2-290.6,0-384.7L310.3,1812.3c-179.2-94.1-179.2-290.6,0-384.7l1189.9-624.8c210.8-110.7,165.5-350.8-78.2-414.7L-56,0"/>
    </svg>
    
    <!-- Truck image -->
<div class="truck">

<div class="circle"></div></div>
  </div>
  <div class="blocks">

</div>

  <!-- GSAP and ScrollTrigger Libraries -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/MotionPathPlugin.min.js"></script>

  <script>
    // Register GSAP plugins
    gsap.registerPlugin(MotionPathPlugin, ScrollTrigger);

    // Create a GSAP timeline for the truck animation
    const truckTimeline = gsap.timeline({
      scrollTrigger: {
        trigger: ".container", // Element that triggers the animation
        start: "top 90%", // Start when the container is centered in the viewport
        end: "bottom top", // End when the container reaches the top of the viewport
        scrub: true, // Make the animation scrubbed (follow scroll position)
        markers: true, // Show markers for debugging (remove in production)
      }
    });

    truckTimeline.to(".truck", {
      motionPath: {
        path: "#road-path",
        align: "#road-path",
        alignOrigin: [0.5, 0.5], // Center the truck on the path
        start: 1, // Start at the end of the path
        end: 0, // End at the start of the path
        autoRotate: true, // Rotate the truck to follow the path
pin:true,
      },
      ease: "linear", // No easing to keep the truck moving smoothly
    });
  </script>
</body>
</html>



11 January 2024

How to create events on google calender by any invitation email in PHP?

 <?php



require __DIR__ . '/vendor/autoload.php';


$client = new Google_Client();

$client->setAuthConfig('client_secret_397900761893-afl4gdg99gcfbaab0aip6jo1ha2824vg.apps.googleusercontent.com.json');

$client->setAccessType('offline');

$client->setPrompt('select_account consent');

$client->setRedirectUri('http://localhost'); // Update this line

$client->addScope(Google_Service_Calendar::CALENDAR);


$client->setHttpClient(new \GuzzleHttp\Client(['verify' => __DIR__ . '/cacert.pem']));


// If the token is not stored or expired, authenticate and generate a new one

if (!file_exists('token.json')) {

    // Redirect the user to the authorization URL

    $authUrl = $client->createAuthUrl();

    header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL));

    exit;

} else {

    file_put_contents('debug_token.txt', file_get_contents('token.json'));

    $accessToken = json_decode(file_get_contents('token.json'), true);

}


// Set the access token to the client

$client->setAccessToken($accessToken);


// Create a Google Calendar service object

$service = new Google_Service_Calendar($client);


// Define the event details, including the guest's email in the attendees field

$event = new Google_Service_Calendar_Event(array(

    'summary' => '11 Client Meeting 11',

    'description' => 'Discuss project details with the client.',

    'start' => array(

        'dateTime' => '2024-01-13T10:00:00',

        'timeZone' => 'Asia/Kolkata',

    ),

    'end' => array(

        'dateTime' => '2024-01-13T11:00:00',

        'timeZone' => 'Asia/Kolkata',

    ),

));


// Add guests to the event

$event->setAttendees([

    ['email' => 'jas@gmail.com']

    ['email' => 'jas@yopmail.com'],

]);


// Insert the event into the primary calendar

$calendarId = 'primary';

$event = $service->events->insert($calendarId, $event, ['sendUpdates' => 'all']);


// Print the event ID

printf('Event created: %s', $event->getId());


How to fetch instagram posts data?

Fetch Instagram posts data by pasting this code in browser console. (() => { /* ====================================================...