Muchafoundationcognacbisquitfineartlimitedlithograph Mouse Over to Zoom Click to Enlarge

In this post, we volition talk over jQuery custom code to implement Image/ Thumbnail Zoom consequence on hover. For a number of images, we commonly place thumbnails of larger images which be selected past the user to view total-size paradigm.

In this example, we will place images in square boxes which will show thumbnails by default but zooms to original dimensions as nosotros over/ mouseover with the cursor. A user tin can too click on that epitome thumb to view total-size prototype in fullscreen.

We will utilise jQuery and some custom CSS lawmaking to requite style to thumbnails and fullscreen zoom effect. Hither we will as well use jQuery's animate role and a small login to get epitome'southward actual dimensions and apply on hover and click.

You can check the working demo hither

Let's start with implementation.

Commencement, add post-obit HTML, nosotros will have a listing with thumbnails as groundwork images. On these thumbnails, nosotros volition bind jQuery hover event to zoom the image to full dimensions.

                          <ul grade="thumb">                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" style="background-image:url(./images/1.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" style="background-image:url(./images/ii.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" manner="background-image:url(./images/3.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div course="thumbnail-wrap" mode="groundwork-image:url(./images/iv.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" way="background-image:url(./images/five.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" way="background-epitome:url(./images/half dozen.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" style="background-image:url(./images/7.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" style="groundwork-prototype:url(./images/8.jpg)"></div>                     </a>                 </li>                 <li>                     <a href="javascript:void(0)">                         <div class="thumbnail-wrap" style="groundwork-image:url(./images/9.jpg)"></div>                     </a>                 </li>             </ul>          

Add following CSS manner for thumbnail list and the fullscreen preview of the prototype.

                          ul.thumb {             float: left;             listing-style: none;             padding: 10px;             width: 360px;             margin: 80px;         }          ul.thumb li {             margin: 0;             padding: 5px;             float: left;             position: relative;             /* Gear up the absolute positioning base coordinate */             width: 110px;             meridian: 110px;         }          ul.thumb li .thumbnail-wrap {             width: 100px;             summit: 100px;             /* Gear up the pocket-sized thumbnail size */             -ms-interpolation-fashion: bicubic;             /* IE Fix for Bicubic Scaling */             edge: 1px solid #ddd;             padding: 5px;             position: absolute;             left: 0;             top: 0;             groundwork-size: cover;             background-repeat: no-repeat;              -webkit-box-shadow: inset -3px 0px 40px -15px rgba(0, 0, 0, 1);             -moz-box-shadow: inset -3px 0px 40px -15px rgba(0, 0, 0, ane);             box-shadow: inset -3px 0px 40px -15px rgba(0, 0, 0, 1);          }          ul.thumb li .thumbnail-wrap.hover {             -webkit-box-shadow: -2px 1px 22px -1px rgba(0, 0, 0, 0.75);             -moz-box-shadow: -2px 1px 22px -1px rgba(0, 0, 0, 0.75);             box-shadow: -2px 1px 22px -1px rgba(0, 0, 0, 0.75);         }          .thumnail-zoomed-wrapper {             display: none;             position: fixed;             top: 0px;             left: 0px;             pinnacle: 100vh;             width: 100%;             background: rgba(0, 0, 0, 0.two);             z-alphabetize: 99;         }          .thumbnail-zoomed-paradigm {             margin: auto;             display: block;             text-align: heart;             margin-top: 12%;         }          .thumbnail-zoomed-epitome img {             max-width: 100%;         }          .close-prototype-zoom {             z-index: 10;             float: right;             margin: 10px;             cursor: pointer;         }          

Adjacent, we have following jQuery custom code to add some outcome handlers. We volition bind a hover and hover out event to requite zoom issue using the animate method of jQuery.

We will fetch the paradigm's original dimensions to show a zoomed image with proper dimensions. Here nosotros also accept a variable named percusing which we can command zoom level of the image for example if nosotros requite 40 them image will exist 40 per centum smaller then original dimensions.

                          $(office () {             //Larger thumbnail preview             var perc = twoscore;             $("ul.thumb li").hover(function () {                 $("ul.thumb li").find(".thumbnail-wrap").css({                     "z-index": "0"                 });                 $(this).discover(".thumbnail-wrap").css({                     "z-alphabetize": "10"                 });                 var imageval = $(this).find(".thumbnail-wrap").css("background-epitome").piece(5);                 var img;                 var thisImage = this;                 img = new Paradigm();                 img.src = imageval.substring(0, imageval.length - 2);                 img.onload = function () {                     var imgh = this.meridian * (perc / 100);                     var imgw = this.width * (perc / 100);                     $(thisImage).find(".thumbnail-wrap").addClass("hover").stop()                         .animate({                             marginTop: "-" + (imgh / 4) + "px",                             marginLeft: "-" + (imgw / 4) + "px",                             width: imgw + "px",                             height: imgh + "px"                         }, 200);                 }             }, role () {                 var thisImage = this;                 $(this).find(".thumbnail-wrap").removeClass("hover").stop()                     .breathing({                         marginTop: "0",                         marginLeft: "0",                         top: "0",                         left: "0",                         width: "100px",                         height: "100px",                         padding: "5px"                     }, 400, role () {});             });              //Testify thumbnail in fullscreen             $("ul.thumb li .thumbnail-wrap").click(function () {                  var imageval = $(this).css("background-image").piece(5);                 imageval = imageval.substring(0, imageval.length - ii);                 $(".thumbnail-zoomed-image img").attr({                     src: imageval                 });                 $(".thumnail-zoomed-wrapper").fadeIn();                 return imitation;             });              //Close fullscreen preview             $(".thumnail-zoomed-wrapper .close-image-zoom").click(function () {                 $(".thumnail-zoomed-wrapper").hide();                 return false;             });         });          

That'south all, now our thumbnails volition look similar this.

Check demo here

bostictrepen.blogspot.com

Source: https://www.freakyjolly.com/image-thumbnail-zoom-effect-on-mouse-hover-using-jquery/

0 Response to "Muchafoundationcognacbisquitfineartlimitedlithograph Mouse Over to Zoom Click to Enlarge"

ارسال یک نظر

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel