Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
- if (!isMobile && jQuery().zoom) {
- $('.gr-image-zoom').zoom({
- magnify: 1,
- duration: 10,
- onZoomIn: function(){
- $(this).parent().addClass('hide_small_pic');
- },
- onZoomOut: function(){
- $(this).parent().removeClass('hide_small_pic');
- },
- callback: function(){
- var $zoomImg = $(this);
- var zoomImgHeight = Math.floor($zoomImg.height());
- var zoomImgWidth = Math.floor($zoomImg.width());
- var floatHeight = Math.floor(20 * zoomImgHeight / 100);
- var floatWidth = Math.floor(20 * zoomImgWidth / 100);
- var prevWidth = Math.floor($(this).prev().outerWidth());
- var prevHeight = Math.floor($(this).prev().outerHeight());
- var zoomFloatHeight = zoomImgHeight + floatHeight;
- var zoomFloatWidth = zoomImgWidth + floatWidth;
- var finalHeight = prevHeight+floatHeight;
- var finalWidth = prevWidth+floatWidth;
- if (zoomFloatHeight<=prevHeight-floatHeight || zoomFloatWidth<=prevWidth-floatWidth) {
- $(this).parent().addClass('hide_big_pic');
- };
- if (zoomImgHeight<=prevHeight || zoomImgWidth <=prevWidth) {
- $zoomImg.css({
- 'width': finalWidth,
- 'height': finalHeight
- });
- }
- }
- });
- };
Add Comment
Please, Sign In to add comment