Element.prototype.colorAdd = function(){
this.setAttribute("style", "color:red; border: 1px solid blue;")
}
var elem = document.getElementById("element");
elem.colorAdd();
var lFollowX = 0,
lFollowY = 0,
x = 0,
y = 0,
friction = 1 / 30;
function moveBackground() {
x += (lFollowX - x) * friction;
y += (lFollowY - y) * friction;
translate = 'translate(' + x.toFixed(0) + 'px, ' + y.toFixed(0) + 'px) scale(1.1)';
console.log(translate)
$('.bg').css({
'-webit-transform': translate,
'-moz-transform': translate,
'transform': translate
});
window.requestAnimationFrame(moveBackground);
}
$('.wrap').on('mousemove click', function(e) {
var lMouseX = Math.max(-100, Math.min(100, $(window).width() / 2 - e.clientX)).toFixed(0);
var lMouseY = Math.max(-100, Math.min(100, $(window).height() / 2 - e.clientY)).toFixed(0);
lFollowX = (20 * lMouseX) / 100; // 100 : 12 = lMouxeX : lFollow
lFollowY = (10 * lMouseY) / 100;
});
moveBackground();