Layer 相册层 图片滚轮放大、旋转

$(document).on("mousewheel DOMMouseScroll", ".layui-layer-phimg img", function(e) {
    var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || // chrome & ie
        (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); // firefox
    var imagep = $(".layui-layer-phimg").parent().parent();
    var image = $(".layui-layer-phimg").parent();
    var h = image.height();
    var w = image.width();
    if(delta > 0) {

            h = h * 1.05;
            w = w * 1.05;
        
    } else if(delta < 0) {
        if(h > 100) {
            h = h * 0.95;
            w = w * 0.95;
        }
    }
    imagep.css("top", (window.innerHeight - h) / 2);
    imagep.css("left", (window.innerWidth - w) / 2);
    image.height(h);
    image.width(w);
    imagep.height(h);
    imagep.width(w);
});

////////////////////////////////下边的是旋转

$(".content").on("click", "img", function () {

    layer.photos({
        photos: '.content',
        anim: 3,
        closeBtn: 1,
        tab:function () {
            num=0;
            $("#layui-layer-photos").append('
\n' + '\t\t\n' + '\t
'); } }); }) $(document).on("click", ".icon img", function(e) { num = (num+90)%360; $(".layui-layer.layui-layer-page.layui-layer-photos").css('transform','rotate('+num+'deg)'); //$(".layui-layer-phimg img").css('transform','rotate('+num+'deg)');此处只能旋转图片 });

 

 

 

 

 

 

 

 

你可能感兴趣的:(jquery)