精华内容
下载资源
问答
  • JS鼠标点击图片放大查看是一款基于javascript库实现的鼠标点击全屏查看图片特效。
  • JS鼠标点击图片放大查看
  • JS鼠标点击图片放大查看是一款基于javascript库实现的鼠标点击全屏查看图片特效。
  • 原生js图片跟随鼠标移动点击放大图片3D展示 原生js图片跟随鼠标移动点击放大图片3D展示
  • 原生js鼠标拖动鼠标控制图片放大缩小效果
  • 功能点:点击图片放大,滚动鼠标滚轮可再次放大缩小,鼠标点击可拖动图片位置 使用方法: js已经封装好了,只要在将选择器筛选之后的对象当作参数传入方法中即可: js调用: 加载完页面之后绑定下事件: //$(...

    功能点:点击图片放大,滚动鼠标滚轮可再次放大缩小,鼠标点击可拖动图片位置

    jQuery缩放插件Zoomify只能实现图片点击放大缩小,不满足要求

    使用方法:

    js已经封装好了,只要在将选择器筛选之后的对象当作参数传入方法中即可:

    js调用:

    加载完页面之后绑定下事件:

    //$(".kc-media-div p img:not([name='messageName'])")是要实现此功能测图片对象(防止有些视频对象也用img标签)
    imgZoom($(".kc-media-div p img:not([name='messageName'])"))

    js工具类:

    var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
            toBind = ('onwheel' in document || document.documentMode >= 9) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
            slice = Array.prototype.slice, nullLowestDeltaTimeout, lowestDelta;
        if ($.event.fixHooks) {
            for (var i = toFix.length; i;) {
                $.event.fixHooks[toFix[--i]] = $.event.mouseHooks;
            }
        }
        var special = $.event.special.mousewheel = {
            version: '3.1.9', setup: function () {
                if (this.addEventListener) {
                    for (var i = toBind.length; i;) {
                        this.addEventListener(toBind[--i], handler, false);
                    }
                } else {
                    this.onmousewheel = handler;
                }
                $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
                $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
            }, teardown: function () {
                if (this.removeEventListener) {
                    for (var i = toBind.length; i;) {
                        this.removeEventListener(toBind[--i], handler, false);
                    }
                } else {
                    this.onmousewheel = null;
                }
            }, getLineHeight: function (elem) {
                return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);
            }, getPageHeight: function (elem) {
                return $(elem).height();
            }, settings: {adjustOldDeltas: true}
        };
        $.fn.extend({
            mousewheel: function (fn) {
                return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
            }, unmousewheel: function (fn) {
                return this.unbind('mousewheel', fn);
            }
        });
    
        function handler(event) {
            var orgEvent = event || window.event, args = slice.call(arguments, 1), delta = 0, deltaX = 0, deltaY = 0,
                absDelta = 0;
            event = $.event.fix(orgEvent);
            event.type = 'mousewheel';
            if ('detail' in orgEvent) {
                deltaY = orgEvent.detail * -1;
            }
            if ('wheelDelta' in orgEvent) {
                deltaY = orgEvent.wheelDelta;
            }
            if ('wheelDeltaY' in orgEvent) {
                deltaY = orgEvent.wheelDeltaY;
            }
            if ('wheelDeltaX' in orgEvent) {
                deltaX = orgEvent.wheelDeltaX * -1;
            }
            if ('axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) {
                deltaX = deltaY * -1;
                deltaY = 0;
            }
            delta = deltaY === 0 ? deltaX : deltaY;
            if ('deltaY' in orgEvent) {
                deltaY = orgEvent.deltaY * -1;
                delta = deltaY;
            }
            if ('deltaX' in orgEvent) {
                deltaX = orgEvent.deltaX;
                if (deltaY === 0) {
                    delta = deltaX * -1;
                }
            }
            if (deltaY === 0 && deltaX === 0) {
                return;
            }
            if (orgEvent.deltaMode === 1) {
                var lineHeight = $.data(this, 'mousewheel-line-height');
                delta *= lineHeight;
                deltaY *= lineHeight;
                deltaX *= lineHeight;
            } else if (orgEvent.deltaMode === 2) {
                var pageHeight = $.data(this, 'mousewheel-page-height');
                delta *= pageHeight;
                deltaY *= pageHeight;
                deltaX *= pageHeight;
            }
            absDelta = Math.max(Math.abs(deltaY), Math.abs(deltaX));
            if (!lowestDelta || absDelta < lowestDelta) {
                lowestDelta = absDelta;
                if (shouldAdjustOldDeltas(orgEvent, absDelta)) {
                    lowestDelta /= 40;
                }
            }
            if (shouldAdjustOldDeltas(orgEvent, absDelta)) {
                delta /= 40;
                deltaX /= 40;
                deltaY /= 40;
            }
            delta = Math[delta >= 1 ? 'floor' : 'ceil'](delta / lowestDelta);
            deltaX = Math[deltaX >= 1 ? 'floor' : 'ceil'](deltaX / lowestDelta);
            deltaY = Math[deltaY >= 1 ? 'floor' : 'ceil'](deltaY / lowestDelta);
            event.deltaX = deltaX;
            event.deltaY = deltaY;
            event.deltaFactor = lowestDelta;
            event.deltaMode = 0;
            args.unshift(event, delta, deltaX, deltaY);
            if (nullLowestDeltaTimeout) {
                clearTimeout(nullLowestDeltaTimeout);
            }
            nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
            return ($.event.dispatch || $.event.handle).apply(this, args);
        }
    
        function nullLowestDelta() {
            lowestDelta = null;
        }
    
        function shouldAdjustOldDeltas(orgEvent, absDelta) {
            return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
        }
    
        var imgZoom = function (obj) {
            var mask = "<div style = 'position: fixed;width: 100%;z-index: 5555;height: 100%;top: 0;left: 0;background: rgba(0,0,0,0.5);display:none;' id='imgZoomMask'></div>";
            $("html").append(mask);
            var windowWidth = $(window).width();
            var windowHeight = $(window).height();
            $(window).resize(function () {
                windowWidth = $(window).width();
                windowHeight = $(window).height();
            });
            obj.each(function () {
                $(this).click(function () {
                    $("#imgZoomMask").show();
                    var src = $(this).data("src") == undefined ? $(this).attr("src") : $(this).data("src");
                    var img = new Image();
                    img.src = src;
                    img.onload = function () {
                        var dom = "";
                        var displayWidth = 0;
                        var displayHeight = 0;
                        var style = "";
                        if (img.width > img.height) {
                            displayWidth = windowWidth / 2;
                            displayHeight = img.height * displayWidth / img.width;
                            style = "z-index:6666;position:fixed;top:" +
                                windowHeight / 2 +
                                "px;margin-top:-" +
                                displayHeight / 2 +
                                "px;left:" +
                                windowWidth / 2 +
                                "px;margin-left:-" +
                                displayWidth / 2 +
                                "px;cursor:pointer;";
                            dom = "<img draggable='true' src = '" +
                                src +
                                "' width = '50%' style='" +
                                style +
                                "' id='imgZoomImg'>";
                        } else {
                            displayHeight = windowHeight / 2;
                            displayWidth = displayHeight * img.width / img.height;
                            style = "z-index:6666;position:fixed;top:" +
                                windowHeight / 2 +
                                "px;margin-top:-" +
                                displayHeight / 2 +
                                "px;left:" +
                                windowWidth / 2 +
                                "px;margin-left:-" +
                                displayWidth / 2 +
                                "px;cursor:pointer;";
                            dom = "<img draggable='true' src = '" +
                                src +
                                "' height = '50%' style=' " +
                                style +
                                "' id='imgZoomImg'>";
                        }
                        $("body").append(dom);
                        dragging({move: "both", randomPosition: false},$("#imgZoomImg"));
                    }
                });
            });
            $(document).on("click", "#imgZoomMask", function () {
                $("#imgZoomMask").hide();
                $("#imgZoomImg").fadeOut().remove();
                $("body").css('overflow','');
            });
            $(document).on("mousewheel", function (e, d) {
                if (d === 1) {
                    var width = $("#imgZoomImg").width();
                    var height = $("#imgZoomImg").height();
                    $("#imgZoomImg").css({"width": width * 1.2, "height": height * 1.2});
                }
                if (d === -1) {
                    var width = $("#imgZoomImg").width();
                    var height = $("#imgZoomImg").height();
                    $("#imgZoomImg").css({"width": width / 1.2, "height": height / 1.2});
                }
            });
        }
        var dragging = function (data,obj) {
            var $this = obj;
            var xPage;
            var yPage;
            var X;
            var Y;
            var xRand = 0;
            var yRand = 0;
            var father = $this.parent();
            var defaults = {move: 'both', randomPosition: true, hander: 1}
            var opt = $.extend({}, defaults, data);
            var movePosition = opt.move;
            var random = opt.randomPosition;
            var hander = opt.hander;
            if (hander === 1) {
                hander = $this;
            } else {
                hander = $this.find(opt.hander);
            }
            father.css({"position": "relative", "overflow": "hidden"});
            $this.css({"position": "fixed"});
            hander.css({"cursor": "move"});
            var faWidth = father.width();
            var faHeight = father.height();
            var thisWidth = $this.width() + parseInt($this.css('padding-left')) + parseInt($this.css('padding-right'));
            var thisHeight = $this.height() + parseInt($this.css('padding-top')) + parseInt($this.css('padding-bottom'));
            var mDown = false;
            var positionX;
            var positionY;
            var moveX;
            var moveY;
            if (random) {
                $thisRandom();
            }
    
            function $thisRandom() {
                $this.each(function (index) {
                    var randY = parseInt(Math.random() * (faHeight - thisHeight));
                    var randX = parseInt(Math.random() * (faWidth - thisWidth));
                    if (movePosition.toLowerCase() == 'x') {
                        obj.css({left: randX});
                    } else if (movePosition.toLowerCase() == 'y') {
                        obj.css({top: randY});
                    } else if (movePosition.toLowerCase() == 'both') {
                        obj.css({top: randY, left: randX});
                    }
                });
            }
    
            hander.mousedown(function (e) {
                father.children().css({"zIndex": "0"});
                $this.css({"zIndex": "6666"});
                mDown = true;
                X = e.pageX;
                Y = e.pageY;
                positionX = $this.position().left;
                positionY = $this.position().top;
                return false;
            });
            $(document).mouseup(function (e) {
                mDown = false;
            });
            $(document).mousemove(function (e) {
                xPage = e.pageX;
                moveX = positionX + xPage - X;
                yPage = e.pageY;
                moveY = positionY + yPage - Y;
    
                function thisXMove() {
                    if (mDown == true) {
                        $this.css({"left": moveX});
                    } else {
                        return;
                    }
                    if (moveX < 0) {
                        $this.css({"left": "0"});
                    }
                    if (moveX > (faWidth - thisWidth)) {
                        $this.css({"left": faWidth - thisWidth});
                    }
                    return moveX;
                }
    
                function thisYMove() {
                    if (mDown == true) {
                        $this.css({"top": moveY});
                    } else {
                        return;
                    }
                    if (moveY < 0) {
                        $this.css({"top": "0"});
                    }
                    if (moveY > (faHeight - thisHeight)) {
                        $this.css({"top": faHeight - thisHeight});
                    }
                    return moveY;
                }
    
                function thisAllMove() {
                    if (mDown == true) {
                        $this.css({"left": moveX, "top": moveY});
                    } else {
                        return;
                    }
                    if (moveX < 0) {
                        $this.css({"left": "0"});
                    }
                    if (moveY < 0) {
                        $this.css({"top": "0"});
                    }
                }
    
                if (movePosition.toLowerCase() == "x") {
                    thisXMove();
                } else if (movePosition.toLowerCase() == "y") {
                    thisYMove();
                } else if (movePosition.toLowerCase() == 'both') {
                    thisAllMove();
                }
            });
        }

     

    展开全文
  • 瀑布流排版鼠标点击全屏放大图片代码是一款采用瀑布流排版样式,鼠标点击相册可以网站全屏放大展示大图,同时也支持手机移动端网页。
  • js+css鼠标点击图片放大再次点击时返回原。 js+css鼠标点击图片放大再次点击时返回原。
  • 鼠标实现图片放大跟随鼠标 <style> .picture-list img { width: 300px; height: 80px; } .big-picture img { width: 600px; height: 160px; } .big-picture { position

    鼠标实现图片放大跟随鼠标

        <style>
            .picture-list img {
                width: 300px;
                height: 80px;
            }
    
            .big-picture img {
                width: 600px;
                height: 160px;
            }
    
            .big-picture {
                position: absolute;
            }
        </style>
    </head>
    <!-- 图片大图显示 -->
    <body>
        <div class="picture-list">
            <img src="img/banner_1.jpg" alt="">
            <img src="img/banner_2.jpg" alt="">
            <img src="img/banner_3.jpg" alt="">
        </div>
        <div class="big-picture"></div>
    
        <script>
            // 获取对象节点进行操作
            let imglist = document.querySelectorAll(`.picture-list img`);
            let bigpic = document.querySelector(`.big-picture`);
            let picList = document.querySelector(`.picture-list`);
            // 数组遍历循环显示
            for (let i in imglist) {
                imglist[i].onmouseenter = function () {
                    console.log(this.src);
                    bigpic.innerHTML = `        <img src="${this.src}" alt="">`;
                }
                imglist[i].onmouseleave = function () {
                    bigpic.innerHTML = ``;
                }
            }
            picList.onmousemove = function (e) {
                let x = e.clientX;
                let y = e.clientY;
                // 细节加像素距离,避免重复显示图片掉帧,变得更顺滑!
                console.log(`x坐标${x},y坐标${y}`);
                bigpic.style.top = y + 10 + "px";
                bigpic.style.left = x + 10 + "px";
    
            }
        </script>
    </body>
    
    

    学习记录,自检!

    展开全文
  • 仿百度空间JS鼠标悬停图片放大动画特效代码,挺不错的JS特效,基于jQuery实现,对于提升 用户体验是非常不错的特效,实现的原理也很简单,需要学习的同学可以看看代码。
  • 实现效果: 瀑布流排版鼠标点击放大图片代码,当鼠标点击图片,弹出放大后的图片,这样的效果很美观,展示商品或者展示个人相册都是很好的选择。php中文网推荐下载!
  • js+css鼠标点击图片放大再次点击时返回原位置。 首次发资源,希望各位多多支持,谢谢
  • JS实现图片鼠标移上放大,JS实现在复制图片功能,JS图片自动放大类,Javascriopt图片控制 考虑到程序的藕合度,可移植度,最好封装一个图片自动放大,点击复制JS类,对于所要操作放大的图象对象实现松藕合,即对WEB界面实现...
  • jquery css3鼠标点击图片滑动放大切换
  • 本文实例讲述了JavaScript实现图片放大缩小及拖拽功能。分享给大家供大家参考,具体如下:实现效果如下:实现代码:Titlediv{width:400px;height:400px;overflow:hidden;position:relative;border:1px solid #000;...

    本文实例讲述了JavaScript实现图片的放大缩小及拖拽功能。分享给大家供大家参考,具体如下:

    实现效果如下:

    239bc59454cb5c1165832972c686e170.gif

    实现代码:

    Title

    div{width:400px;height:400px;overflow:hidden;position:relative;border:1px solid #000;}

    div img{position:absolute;height:100%;width:auto;cursor:move;}

    zs.jpg

    var params = {

    zoomVal:1,

    left: 0,

    top: 0,

    currentX: 0,

    currentY: 0,

    flag: false

    };

    //图片缩放

    function bbimg(o){

    var o=o.getElementsByTagName("img")[0];

    params.zoomVal+=event.wheelDelta/1200;

    if (params.zoomVal >= 0.2) {

    o.style.transform="scale("+params.zoomVal+")";

    } else {

    params.zoomVal=0.2;

    o.style.transform="scale("+params.zoomVal+")";

    return false;

    }

    }

    //获取相关CSS属性

    var getCss = function(o,key){

    return o.currentStyle? o.currentStyle[key] : document.defaultView.getComputedStyle(o,false)[key];

    };

    //拖拽的实现

    var startDrag = function(bar, target, callback){

    if(getCss(target, "left") !== "auto"){

    params.left = getCss(target, "left");

    }

    if(getCss(target, "top") !== "auto"){

    params.top = getCss(target, "top");

    }

    //o是移动对象

    bar.onmousedown = function(event){

    params.flag = true;

    if(!event){

    event = window.event;

    //防止IE文字选中

    bar.onselectstart = function(){

    return false;

    }

    }

    var e = event;

    params.currentX = e.clientX;

    params.currentY = e.clientY;

    };

    document.onmouseup = function(){

    params.flag = false;

    if(getCss(target, "left") !== "auto"){

    params.left = getCss(target, "left");

    }

    if(getCss(target, "top") !== "auto"){

    params.top = getCss(target, "top");

    }

    };

    document.onmousemove = function(event){

    var e = event ? event: window.event;

    if(params.flag){

    var nowX = e.clientX, nowY = e.clientY;

    var disX = nowX - params.currentX, disY = nowY - params.currentY;

    target.style.left = parseInt(params.left) + disX+ "px";

    target.style.top = parseInt(params.top) + disY+ "px";

    if (typeof callback == "function") {

    callback((parseInt(params.left) || 0) + disX, (parseInt(params.top) || 0) + disY);

    }

    if (event.preventDefault) {

    event.preventDefault();

    }

    return false;

    }

    }

    };

    startDrag(document.getElementById("img"),document.getElementById("img"))

    希望本文所述对大家JavaScript程序设计有所帮助。

    展开全文
  • 特效描述:jquerycss3 鼠标点击 图片滑动 放大切换。jquery css3动画属性制作鼠标点击图片滑动放大切换显示代码结构1. 引入CSS2. 引入JS3. HTML代码鼠标点击图片试试效果var imgs=["images/island_1x.png","images/...

    特效描述:jquerycss3 鼠标点击 图片滑动 放大切换。jquery css3动画属性制作鼠标点击图片滑动放大切换显示

    代码结构

    1. 引入CSS

    2. 引入JS

    3. HTML代码

    鼠标点击图片试试效果

    var imgs=[

    "images/island_1x.png",

    "images/banana.png",

    "images/rescued-illos_1x.png",

    "images/rivalry_1x.png",

    "images/sir_crags_a_lot_1x.png",

    "images/sf-cryptids_1x.png",

    "images/db_space_1x.png",

    "images/xmas1_1x.png"

    ];

    var counter =0;

    $(document).ready(function () {

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

    $(this).removeClass("zoomIn").addClass("fadeOutRight");

    counter++;

    setTimeout(function(){

    if(counter==imgs.length) counter=0;

    $(".center img").remove();

    $("").attr("src",imgs[counter]).addClass("animated zoomIn").insertBefore($(".center p"));

    if(imgs[counter+1]!=undefined) $(".center").css("backgroundImage","url("+imgs[counter+1]+")")

    },500);

    });

    });

    展开全文
  • 原生js鼠标滑过缩略图片放大展示原图片提示图片文字信息 原生js鼠标滑过缩略图片放大展示原图片提示图片文字信息 原生js鼠标滑过缩略图片放大展示原图片提示图片文字信息
  • 主要为大家详细介绍了js实现图片旋转,滚动鼠标中间对图片放大缩小等效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
  • JS脚本特效,实现鼠标移动放大图片,类似于一个图片放大镜。当移动鼠标时,会在右侧缩略图中生成一个边框以确定放大位置,然后随着你的鼠标移动左侧经放大的图像显示出来,看上去很逼真。
  • 鼠标经过图片显示放大效果js
  • 这是一款轻量级的纯JavaScript炫酷鼠标滑过图片放大特效插件。该插件有两种显示形式:鼠标点击鼠标滑过。两种方式都可以制作出图片放大镜效果,并且还可以将这两种放大镜效果结合在一起使用。安装可以通过NPM或...
  • <SCRIPT language=JavaScript> drag = 0 move = 0 function init() { window.document.onmousemove = mouseMove window.document.onmousedown = mouseDown window.document.onmouseup = mouseUp window.document...
  • 真正模仿Discuz点击图片放大、拖动、随鼠标滚动放大缩小,实现之后,我想,能不能在文章展示页面直接用jquery循环文章所在id里的img ,然后设置id、class、onclick,可是我试了,点击图片没有反应,不知道为啥。...
  • 代码简介:jQuery鼠标悬浮图片放大特效是一款鼠标移到图片上突出放大显示。
  • 这是一款使用纯js制作的炫酷随鼠标位置变化移动速度图片放大缩小展示特效。整个js代码短小精悍,100多行代码即完成了令人惊叹的效果。HTMLhtml结构非常简单:Loading... CSScss代码如下,只是简单的定位一些元素和给...
  • vue鼠标悬停图片放大特效是一款基于vue.js跟css3制作的相册图片悬停弹出3d放大展示代码。
  • JavaScript实现鼠标移入图片放大效果,JavaScript实现鼠标移入图片放大效果,好东西大家共享
  • JavaScript语言:JaveScriptBabelCoffeeScript确定var w = 800,h = 1200,offsetX = $('#imgBox').offset().left,scale = 1.5,scaling = false;$('#imgBox').click(function(e) {scaling = true;(scale < 3.5) ? ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 21,376
精华内容 8,550
关键字:

js鼠标点击图片放大