Examples

Basic gradients animation

Basic gradients animation with 3 gradients in queue composed of 2 colors.

                
var basicGraderInstance = new Grader({
    name: 'simple-gradient-grader',
    element: '#simplegradient',
    gradientType: 'linear',
    gradientOrigin: 'to top right',
    states: {
        "default-state": {
            gradients: [
                ['#42275a', '#734b6d'],
                ['#3a6186', {color: '#89253e', opacity: 0.85}],
                ['#FFA17F', '#00223E']
            ],
            loop: true
        }
    }
});
                
              
<div id="simplegradient"></div>
div {
    height: 100%;
    width: 100%;
}

Radial gradients animation

Radial gradients animation with 3 gradients in queue composed of 2 colors.


var radialGraderInstance = new Grader({
    name: 'radial-gradient-grader',
    element: '#radialgradient',
    gradientType: 'radial',
    gradientOrigin: 'circle closest-corner',
    animationStep: 50,
    states: {
        "default-state": {
            gradients: [
                ['#42275a', '#734b6d'],
                ['#3a6186', {color: '#89253e', opacity: 0.85}],
                ['#FFA17F', '#00223E']
            ],
            loop: true
        }
    }
});
              
<div id="radialgradient"></div>
div {
    height: 100%;
    width: 100%;
}

Radial gradients with an image

Radial gradients with 3 colors, different sizes and a foreground image.


var frontImageGraderInstance = new Grader({
    name: 'front-image-gradient-grader',
    element: '#frontimagegradient',
    gradientType: 'radial',
    gradientOrigin: 'ellipse farthest-side',
    animationStep: 50,
    backgroundImage: 'url("assets/images/sun.png") no-repeat center',
    states: {
        "default-state": {
            gradients: [
                ['#004e92', {color: '#004e92', size: 0.1}],
                ['#8E0E00', '#1F1C18'],
                ['#870000', '#190A05']
            ],
            transitionSpeed: 5000,
            loop: true
        }
    }
});
<div id="frontimagegradient"></div>
div {
    height: 100%;
    width: 100%;
}

Gradients on the text

Gradients on the text.
Look at the logo on the left of the header.


var frontImageGraderInstance = new Grader({
    name: 'front-image-gradient-grader',
    element: '#textgradient',
    gradientType: 'linear',
    gradientOrigin: 'to right',
    applyToText: true,
    states: {
        "default-state": {
            gradients: [
              ['#7474BF', '#348AC7'],
              [{color: '#2196f3',size: -0.2}, '#f44336'],
              ['#2c3e50', {color: '#3498db',opacity: 0.5}],
              ['#5C258D', '#4389A2'],
              ['#000317', '#002c70']
            ],
            transitionSpeed: 5000,
            loop: true
        }
    }
});
<div id="textgradient"><p>GRADER.JS</p></div>
#textgradient {
  font-family: Graduate;
  font-size: 120px;
  font-weight: 700;
}

Interactive Gradients

Create a gradients animation that responds to events.
Click on the different states in the gradient animation to see the gradients change.

var frontImageGraderInstance = new Grader({
    name: 'interactive-gradient-grader',
    element: '#interactive',
    gradientType: 'linear',
    gradientOrigin: 'to bottom right',
    stateTransitionSpeed: 1000,
    animationStep: 50,
    states: {
        "default-state": {
            gradients: [['#7474BF', '#348AC7']]
        },
        "green-state": {
            gradients: [['#6A9113', '#141517']]
        },
        "violet-state": {
            gradients: [['#6441A5', '#2a0845']]
        },
        "orange-state": {
            gradients: [['#fe8c00', '#f83600']]
        }
    }
});

// With jQuery $('#green-state-cta').hover(function() { this.frontImageGraderInstance.changeState('green-state'); }.bind(this), function() { this.frontImageGraderInstance.changeState('default-state'); }.bind(this)); $('#violet-state-cta').hover(function() { this.frontImageGraderInstance.changeState('violet-state'); }.bind(this), function() { this.frontImageGraderInstance.changeState('default-state'); }.bind(this)); $('#orange-state-cta').hover(function() { this.frontImageGraderInstance.changeState('orange-state'); }.bind(this), function() { this.frontImageGraderInstance.changeState('default-state'); }.bind(this));
<div id="interactive">
  <span>
    <a class="active" id="green-state-cta" href="#green-state">Green state</a>
    <a id="violet-state-cta" href="#violet-state">Violet animated state</a>
    <a id="orange-state-cta" href="#orange-state">Orange static state</a>
  </span>
</div>
div {
    height: 100%;
    width: 100%;
}

#interactive{ display: flex; flex-direction: column; margin: auto; }
span { text-align: center; margin: auto; }
a { text-decoration: none; font-family: Graduate; color: white; font-size: 25px; border: 1px solid white; padding: 5px; margin: 10px; }