79771208

Date: 2025-09-22 03:41:53
Score: 1.5
Natty:
Report link

The problem is that you're trying to control both the fill color and the animation separately. The better approach is to use CSS animations for the masking effect and control them through classes that you toggle with JavaScript.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Indonesian Flag Globe Animation</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background: linear-gradient(to right, #2c3e50, #4ca1af);
            margin: 0;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        .container {
            text-align: center;
            padding: 30px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        }

        h1 {
            color: white;
            margin-bottom: 30px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .globe-container {
            position: relative;
            width: 300px;
            height: 300px;
            margin: 0 auto 30px;
        }

        .globe {
            width: 100%;
            height: 100%;
        }

        .globe-circle {
            fill: lightBlue;
            transition: fill 0.5s ease;
        }

        .mask {
            fill: white;
        }

        #mask-rect {
            transform: translateY(-100%);
            transition: transform 1s cubic-bezier(0.65, 0, 0.35, 1);
        }

        .globe-container:hover #mask-rect {
            transform: translateY(0);
        }

        .globe-container:hover .globe-circle {
            fill: url(#indo-flag);
        }

        button {
            padding: 15px 40px;
            font-size: 18px;
            background: linear-gradient(to right, #e74c3c, #e67e22);
            color: white;
            border: none;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        button:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
            background: linear-gradient(to right, #c0392b, #d35400);
        }

        .instructions {
            color: white;
            margin-top: 20px;
            font-size: 16px;
            opacity: 0.8;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Indonesian Flag Globe</h1>
        
        <div class="globe-container">
            <svg class="globe" viewBox="0 0 200 200">
                <defs>
                    <!-- Indonesian flag gradient -->
                    <linearGradient id="indo-flag" x1="0%" y1="0%" x2="0%" y2="100%">
                        <stop offset="0%" style="stop-color:#e70011;stop-opacity:1" />
                        <stop offset="100%" style="stop-color:#ffffff;stop-opacity:1" />
                    </linearGradient>
                    
                    <!-- Clip path for the globe -->
                    <clipPath id="globe-clip">
                        <circle cx="100" cy="100" r="90" />
                    </clipPath>
                </defs>
                
                <!-- Globe circle with initial color -->
                <circle class="globe-circle" cx="100" cy="100" r="90" />
                
                <!-- Mask for the animation -->
                <g clip-path="url(#globe-clip)">
                    <rect id="mask-rect" x="0" y="0" width="200" height="200" class="mask" />
                </g>
                
                <!-- Globe outline -->
                <circle cx="100" cy="100" r="90" fill="none" stroke="rgba(0,0,0,0.2)" stroke-width="2" />
            </svg>
        </div>
        
        <button id="trigger-button">Hover Me</button>
        
        <p class="instructions">Hover over the button to see the Indonesian flag colors fill the globe</p>
    </div>

    <script>
        const button = document.getElementById("trigger-button");
        const globeContainer = document.querySelector(".globe-container");
        
        // We're using CSS for the animation, but we can also control with JS if needed
        button.addEventListener('mouseenter', () => {
            globeContainer.classList.add('hover');
        });
        
        button.addEventListener('mouseleave', () => {
            globeContainer.classList.remove('hover');
        });
    </script>
</body>
</html>

is above code sufficient?

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: AndyLaode