Home  >  Article  >  Web Front-end  >  jQuery picture special effects plug-in Revealing realizes stretching and magnification_jquery

jQuery picture special effects plug-in Revealing realizes stretching and magnification_jquery

WBOY
WBOYOriginal
2016-05-16 16:02:381210browse

Click on the picture and the picture will be stretched and enlarged. The effect is great!

How to use:

1. Head area reference files jquery.js, photorevealer.js, datouwang.css

2. Add 4fe5d0b678c5ba2dfd7510dee7b92bc9d2d0dc6c55787d0ab0740f9b3680fd36region code

3. The number of pictures can be increased or decreased freely, just add or deleteb6c5a531a458a2e790c1fd6421739d1cb90dd5946f0946207856a8a37f441edf

4. If the image has more information and requires more space, you can modify the number on line 36 in photorevealer.js

Core code:

$(document).ready(function(){
     
$('.photo_slider').each(function(){
   
  var $this = $(this).addClass('photo-area');
  var $img = $this.find('img');
  var $info = $this.find('.info_area');
     
  var opts = {};
   
  $img.load(function(){
    opts.imgw = $img.width();
    opts.imgh = $img.height();
  });
   
  opts.orgw = $this.width();
  opts.orgh = $this.height();
   
  $img.css ({
    marginLeft: "-150px",
    marginTop: "-150px"
  });
   
  var $wrap = $('<div class="photo_slider_img">').append($img).prependTo($this);
 
  var $open = $('<a href="#" class="more_info">More Info ></a>').appendTo($this);
   
  var $close = $('<a class="close">Close</a>').appendTo($info);
   
  opts.wrapw = $wrap.width();
  opts.wraph = $wrap.height();
   
  $open.click(function(){
    $this.animate({ 
      width: opts.imgw,
      height: (opts.imgh+30),
      borderWidth: "10"
    }, 600 );
         
    $open.fadeOut();
     
    $wrap.animate({ 
      width: opts.imgw,
      height: opts.imgh
    }, 600 );
 
    $(".info_area",$this).fadeIn();
     
    $img.animate({
      marginTop: "0px",
      marginLeft: "0px"
    }, 600 );
     
    return false;
  });
   
  $close.click(function(){
    $this.animate({ 
      width: opts.orgw,
      height: opts.orgh,
      borderWidth: "1"
     }, 600 );
     
    $open.fadeIn();
     
    $wrap.animate({ 
      width: opts.wrapw,
      height: opts.wraph
       }, 600 );
     
      $img.animate({
        marginTop: "-150px",
        marginLeft: "-150px"
      }, 600 );
 
    $(".info_area",$this).fadeOut();
    return false;
  });
   
});
 
});

The above is the entire code of this article, I hope you all like it.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn