Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨[Feature Request]: Addition of Preloader and Custom Cursor. #403

Merged
merged 3 commits into from
Jun 1, 2024
Merged

✨[Feature Request]: Addition of Preloader and Custom Cursor. #403

merged 3 commits into from
Jun 1, 2024

Conversation

Anjaliavv51
Copy link
Contributor

@Anjaliavv51 Anjaliavv51 commented Jun 1, 2024

Description

[Please include a brief description of the changes or features added]
Added Preloader and Custom Cursor.

Related Issues

[Cite any related issue(s) this pull request addresses. If none, simply state “None”]

Type of PR

  • Bug fix
  • Feature enhancement
  • Documentation update
  • Other (specify): _______________

Screens

20240601-1025-50.8490700.mp4

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I have performed a self-review of my code
  • I have tested the changes thoroughly before submitting this pull request.
  • I have provided relevant issue numbers, screenshots, and videos after making the changes.
  • I have commented my code, particularly in hard-to-understand areas.

Additional context:

[Include any additional information or context that might be helpful for reviewers.]

Added Code:

<!--Cursor-->
  <script>

    //Custom Cursor

    const coords = { x: 0, y: 0 };
    const circles = document.querySelectorAll(".circle");

    const colors = [
      "#55a5ea",
      "#55a5ea",
      "#55a5ea",
      "#55a5ea",
      "#55a5ea",
      "#55a5ea",
      "#55a5ea",
      "#55a5ea",
      "#3fbcc0c6",
      "#3fbcc0c6",
      "#3fbcc0c6",
      "#3fbcc0c6",
      "#3fbcc0c6",
      "#3fbcc0c6",
      "fff",
      "fff",
      "fff",
      "fff",
      "fff",
      "fff",
      "fff"
    ];

    circles.forEach(function (circle, index) {
      circle.x = 0;
      circle.y = 0;
      circle.style.backgroundColor = colors[index % colors.length];
    });

    window.addEventListener("mousemove", function (e) {
      coords.x = e.clientX;
      coords.y = e.clientY;

    });

    function animateCircles() {

      let x = coords.x;
      let y = coords.y;

      circles.forEach(function (circle, index) {
        circle.style.left = x - 12 + "px";
        circle.style.top = y - 12 + "px";

        circle.style.scale = (circles.length - index) / circles.length;

        circle.x = x;
        circle.y = y;

        const nextCircle = circles[index + 1] || circles[0];
        x += (nextCircle.x - x) * 0.3;
        y += (nextCircle.y - y) * 0.3;
      });

      requestAnimationFrame(animateCircles);
    }

    animateCircles();


    // Function to toggle dark mode
    function toggleDarkMode() {
      const isDarkMode = isDarkModePreferred();
      setDarkModePreference(!isDarkMode);
      applyDarkModePreference();
    }

    // Function to apply dark mode preference
    function applyDarkModePreference() {
      const isDarkMode = isDarkModePreferred();
      if (isDarkMode) {
        document.body.classList.add('dark-mode');
        document.getElementById('theme-icon').src = 'assets/images/icons8-sun.svg';
      } else {
        document.body.classList.remove('dark-mode');
        document.getElementById('theme-icon').src = 'assets/images/moon_solid.svg';
      }
    }

    // Function to set dark mode preference
    document.addEventListener('DOMContentLoaded', () => {
      const currentTheme = localStorage.getItem('theme');
      const switchCheckbox = document.getElementById('switch'); // Define switchCheckbox here
      const starRating = document.querySelector('.star_rating');
      const thankYouMessage = document.querySelector(".thank_you_message");
      if (switchCheckbox) { // Check if switchCheckbox is not null
        function applyDarkModeStyles() {
          document.body.classList.remove('light-mode');
          document.body.classList.add('dark-mode');
          starRating.style.backgroundColor = '#2d2828';
          thankYouMessage.style.backgroundColor = '#2d2828';
        }

        function applyLightModeStyles() {
          document.body.classList.remove('dark-mode');
          document.body.classList.add('light-mode');
          starRating.style.backgroundColor = 'white';
          thankYouMessage.style.backgroundColor = 'white';
        }

        if (currentTheme) {
          if (currentTheme === 'dark-mode') {
            applyDarkModeStyles();
            switchCheckbox.checked = true;
          } else {
            applyLightModeStyles();
          }
        }

        switchCheckbox.addEventListener('change', () => {
          if (switchCheckbox.checked) {
            applyDarkModeStyles();
            localStorage.setItem('theme', 'dark-mode');
          } else {
            applyLightModeStyles();
            localStorage.setItem('theme', 'light-mode');
          }
        });
      } else {
        console.error("Switch checkbox not found!"); // Log an error if switchCheckbox is null
      }
    });
  </script>
<div class="circle-container">
    <div class="circle" style="background-color: #55a5ea; left: 504px; top: 59px; scale: 1;"></div>
    <div class="circle" style="background-color: #55a5ea; left: 504px; top: 59px; scale: 0.95;"></div>
    <div class="circle" style="background-color: #55a5ea; left: 504px; top: 59px; scale: 0.9;"></div>
    <div class="circle" style="background-color: #55a5ea; left: 504px; top: 59px; scale: 0.9;"></div>
    <div class="circle" style="background-color: #3fbcc0c6; left: 504px; top: 59px; scale: 0.85;"></div>
    <div class="circle" style="background-color: #3fbcc0c6; left: 504px; top: 59px; scale: 0.85;"></div>
    <div class="circle" style="background-color: #3fbcc0c6; left: 504px; top: 59px; scale: 0.85;"></div>
    <div class="circle" style="background-color: #3fbcc0c6; left: 504px; top: 59px; scale: 0.85;"></div>
    <div class="circle" style="background-color: #fff; left: 504px; top: 59px; scale: 0.8;"></div>
    <div class="circle" style="background-color: #fff; left: 504px; top: 59px; scale: 0.8;"></div>
    <div class="circle" style="background-color: #fff; left: 504px; top: 59px; scale: 0.8;"></div>
    <div class="circle" style="background-color: #fff; left: 504px; top: 59px; scale: 0.8;"></div>
</div>
  <div id="preloader">
    <div id="loader"></div>
</div>
    <style>
      /*Preloader CSS*/
#preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%; 
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 2s ease-out, visibility 2s ease-out;
  opacity: 1;
  visibility: visible;
  z-index: 9999; 
}

#preloader.hidden {
  opacity: 0;
  visibility: hidden;
}

#loader {
  display: block;
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #55a5ea;
  animation: spin 3s linear infinite;
}

#loader:before {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #3fbcc0c6;
  animation: spin 3s linear infinite;
}

#loader:after {
  content: "";
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 15px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #fff;
  animation: spin 1.5s linear infinite;
}

@keyframes spin {
  0% {
      transform: rotate(0deg);
  }
  100% {
      transform: rotate(360deg);
  }
}
    </style>
    <!--Cursor-->
    <style>
      .circle{
   z-index: 10000;
   width: 20px;
   height: 20px;
   border-radius: 50%;
   pointer-events: none;
    animation: colors 5s infinite;
    position: fixed;
  transform: translate(-50%,-50%);
}
.circle::before {
    content: "";
    position: fixed;
  width: 50px;
  height: 50px;
  opacity: 0.2;
  transform: translate(-30%,-30%);
  border-radius: 50%;
}
    </style>

Copy link

vercel bot commented Jun 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rapidoc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 1, 2024 4:53pm

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @Anjaliavv51! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project.We will promptly review your changes and offer feedback. Keep up the excellent work! Kindly remember to check our contributing guidelines

@Anjaliavv51
Copy link
Contributor Author

@varshith257 please review the PR

@varshith257
Copy link
Collaborator

ippudu add cheyu changes index.html lo, maybe issue is that fork isn't sync with this main

@Anjaliavv51
Copy link
Contributor Author

Anjaliavv51 commented Jun 1, 2024

@varshith257 please check now again , nuvvu pettina file ki add chesa,changes

@varshith257 varshith257 added gssoc level2 medium (enhancements) labels Jun 1, 2024
@varshith257 varshith257 merged commit 358f816 into Anishkagupta04:main Jun 1, 2024
3 checks passed
Copy link
Contributor

github-actions bot commented Jun 1, 2024

🎉 Your pull request has been successfully merged! 🎉 Thank you for your contribution to our project. Your efforts are greatly appreciated. Keep up the fantastic work! 🚀

@varshith257
Copy link
Collaborator

varshith257 commented Jun 1, 2024

@Anjaliavv51 Thanks for this feature added to project

@Anjaliavv51
Copy link
Contributor Author

Anjaliavv51 commented Jun 1, 2024

@varshith257 i want to modify the Readme.md file
Can i rise an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc level2 medium (enhancements)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants