zoukankan      html  css  js  c++  java
  • 点击图片查看大图

    之前在慕课网上看到的一个关于点击图片放大显示的方法,刚好在一个项目中遇到

    感觉挺有用,放这以后需要自提,哈哈哈:

    //点击图片-加载大图
    $scope.loadBigImg=function(imgSrc){

    $scope.bigImageUrl=imgSrc;
    $scope.bigImage = true;//显示大图

    var img = new Image();

    img.onload = function(){

    var imgWidth = this.width;
    var imgHeight = this.height;

    var winWidth = win.width();
    var winHeight = win.height();

    var realw = winHeight*imgWidth/imgHeight;
    var realh = winWidth*imgHeight/imgWidth;

    var margin_left = parseInt((winWidth-realw)/2);
    var margin_top = parseInt((winHeight-realh)/2);

    if(imgHeight/imgWidth>1.2){//此处为竖图
    $('#largeImg').attr('src',imgSrc).css({
    'height':winHeight,
    'width':realw,
    'margin-left':margin_left
    });
    }else{//此处为横图
    $('#largeImg').attr('src',imgSrc).css({
    'height':realh,
    'width':winWidth,
    'margin-top':margin_top
    });
    }
    }
    img.src = imgSrc;
    }
  • 相关阅读:
    订单模块
    69.Sqrt(x)
    28.Implement strStr()---kmp
    26.Remove Duplicates from Sorted Array
    27.Remove Element---两指针
    支付模块
    Oracle维护:每天的工作
    Oracle Hint
    latch相关视图整理
    oracle常用视图介绍
  • 原文地址:https://www.cnblogs.com/maochunyan/p/6894435.html
Copyright © 2011-2022 走看看