天天看点

banner鼠标交互动画

//banner鼠标交互动画
    $(".layerTransform").on("mousemove", function(e){
        var _this = $(this);
        var x = e.pageX;
        var y = e.pageY;
        //console.log(x);
        var w = _this.width();
        var h = _this.height();
        //console.log(w + "|" + h);
        var moveX = (x / w - .5) * -25 || 10,
            moveY = -(y / h - .5) * -20 || 10;
        _this.find(".layerTransformInner").css({"transform":"rotateX("+ moveY +"deg) rotateY("+ moveX +"deg)"});
    });