<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var leftgap = 10; var rightgap = 10; var defaultgap = 50; var caption = true; var reveal = 0.5; $('.jDesign').each(function () {
var i = $(this); var img_mask = i.children('img:eq(0)').attr('src'); var img_bg = i.children('img:eq(1)').attr('src'); var img_cap_one = i.children('img:eq(0)').attr('alt'); var width = i.children('img:eq(0)').width(); var height = i.children('img:eq(0)').height(); i.find('img').hide(); i.css({'overflow': 'hidden', 'position': 'relative'}); i.append('<div class="ba-mask"></div>'); i.append('<div class="ba-bg"></div>'); i.append('<div class="ba-caption">' + img_cap_one + '</div>'); i.children('.ba-mask, .ba-bg').width(width); i.children('.ba-mask, .ba-bg').height(height); i.children('.ba-mask').css('backgroundImage','url(' + img_mask + ')'); i.children('.ba-bg').css('backgroundImage','url(' + img_bg + ')'); i.children('.ba-mask').animate({'width':width - defaultgap}, 1000); if (caption) i.children('.caption').show(); else i.children('.ba-caption').hide(); }).mousemove(function (e) {
var i = $(this); pos_img = i.position()['left']; pos_mouse = e.pageX; new_width = pos_mouse - pos_img; img_width = i.width(); img_cap_one = i.children('img:eq(0)').attr('alt'); img_cap_two = i.children('img:eq(1)').attr('alt'); /* // for debugging purposes $('#debug').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY); $('#debug2').html(i.position()['left']); $('#debug3').html(new_width); */
if (new_width > leftgap && new_width < (img_width - rightgap)) { i.children('.ba-mask').width(new_width); }
if (new_width < (img_width * reveal)) { i.children('.ba-caption').html(img_cap_two); } else { i.children('.ba-caption').html(img_cap_one); } }); }); </script> <style type="text/css"> .jDesign_info { text-align:right; font-size:small; direction:rtl; font-family: Tahoma; padding:6px; margin-right: 200px; margin-left: 200px; border: 5px solid #006CD9; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0px 0px 5px #ac987e; -moz-box-shadow: 0px 0px 5px #ac987e; box-shadow: 0px 0px 5px #ac987e; } .jDesign_info a {color: #006CD9;text-decoration: none;} .jDesign_info a:hover {color:#fff;background:#006CD9;text-shadow:2px 1px 3px #000;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:2px;-webkit-transition-property:background;-webkit-transition-duration:.3s;-webkit-transition-timing-function:linear, ease-in;-moz-transition:background .3s ease-in;-o-transition:background .3s ease-in;} #jDesign_ir {width:501px; margin:0 auto;} .jDesign {width:501px; height:188px;} .ba-mask {position:absolute; top:0; left:0; z-index:100; border-right:3px solid #333; overflow:hidden; box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.6);box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.6); -webkit-box-shadow: 5px 5px 7px rgba(0, 0, 0, 0.6); -moz-box-shadow: 5px 0 7px rgba(0, 0, 0, 0.6);} .ba-bg {position:absolute; top:0; left:0; z-index:0;} .ba-caption { position:absolute; bottom:10px; left:10px; z-index:120; background:#000; color:#fff; text-align:center; padding:5px; font-size:12px; font-family:Tahoma; filter:alpha(opacity=80);-moz-opacity:0.8;-khtml-opacity: 0.8;opacity: 0.8; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; } </style></head><body><br/>
<div id="jDesign_ir">
<div class="jDesign"> <img src="http://jdesign.ir/admin-up/demo-free-cods/jDesign-before-after/jDesign.jpg" alt="www.jDesign.ir" width="501" height="188"/> <img src="http://jdesign.ir/admin-up/demo-free-cods/jDesign-before-after/jDesign1.jpg" alt="گروه طراحی جی دیزاین" width="501" height="188"/> </div> <p id="debug"></p> <p id="debug2"></p> <p id="debug3"></p> </div>