JSFiddle - React, Tailwind, and code Playground

by vvv vvvv

HTML

<header>
     <h1>Something fabulous to write</h1>

    <p>The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts?</p>
    <p>The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts?</p>
    <p>The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts?</p>
</header>
<p>The documentation indicates that the default replaces all, and that "-1" also indicates to replace all, but it is unsuccessful. Any thoughts? The documentation indicates that the default replaces...

CSS

body {
    background-color: #EDF8F2;
}
header {
    padding: 80px;
    padding-right: 50%;
    background: url(http://blog.spoongraphics.co.uk/wp-content/uploads/2012/retro-pattern/triangle-pattern.jpg) pink repeat 0 0;
    font-family: Helvetica;
    color: white;
}
h1 {
    text-shadow: 0 0 7px #000;
    font-size: 72px;
}
header > p {
    color: blue;
    background-color: white;
}

JavaScript

var parallax = {
    init: function (target,strength,opposite) {
        this.target = target;
        this.movStrength = strength || 30; //Optional
        this.movOpposite = opposite || true; //Effect against the cursor movement? - Opt.
        
        var bgPos = $(this.target).css("background-position"),
            i;
        cObj = this;

        //Reverse the movements (or not)
        this.movOpposite = this.movOpposite ? 1 : -1;

        //
        this.movPointX = this.movStrength / $(window).width();
        this.movPointY = this.movStrength / $(window).height();

        //Prevent the occurence of a blank rim on top and left side
        this.bgPosTbl = bgPos.replace(/px/g, "").split(" ");
        i = this.bgPosTbl.length;
        for (i; i > 0; i--) {
            this.bgPosTbl[i] = -(this.movStrength);
        }

        $(this.target).mousemove(this.effect);
    },

    effect: function (e) {

        var pageX = e.pageX - $(window).width() / 2;
        var pageY = e.pageY - $(window).height() / 2;

        var newvalueX = cObj.bgPosTbl[0] - cObj.movPointX * pageX * cObj.movOpposite;
        var newvalueY = cObj.bgPosTbl[1] - cObj.movPointY * pageY * cObj.movOpposite;

        $(cObj.target).css("background-position", newvalueX + "px " + newvalueY + "px");
    }
};

parallax.init("header",50);