';
$('.productView').off('mouseenter mousemove mouseleave','.picbox');
$('.productView').on('mouseenter','.picbox',function(){
ImgBox=$('.productImg .now').offset();
var zoonbox_now = $(this).parents('.zoonbox'),
big_pic = zoonbox_now.attr('big-pic');
var _this = $(this);
viewbox = _this.find('.viewbox');
var image = new Image();
image.src = "/upload_files/fonlego-rwd/prodpic/"+big_pic;
image.onload = function() {
ImgBox_h = image.height;
ImgBox_w = image.width;
scale_h = _this.height()/ImgBox_h;
scale_w = _this.width()/ImgBox_w;
viewbox_h = _this.height()*(scale_h);
viewbox_w = _this.width()*(scale_w);
viewbox_b = _this.height()-viewbox_h;
viewbox_r = _this.width()-viewbox_w;
viewbox.css({
'opacity':1,
'height':viewbox_h,
'width':viewbox_w,
});
preview_str += '

';
zoonbox_now.append(preview_str);
preview = zoonbox_now.find('.preview');
preview_img = preview.find('img');
}
})
.on('mousemove','.picbox',function(e){
if(ImgBox.top){
var bigpicTop = e.pageY-ImgBox.top,
bigpicLeft = e.pageX-ImgBox.left;
if(bigpicTop-(viewbox_h/2) > 0 && bigpicTop-(viewbox_h/2) < viewbox_b ){
viewbox.css({
'top':bigpicTop-(viewbox_h/2),
});
preview_img.css({
'top':(-bigpicTop+(viewbox_h/2))/scale_h,
});
}else if(bigpicTop-(viewbox_h/2) < 0 ){
viewbox.css({
'top':0,
});
preview_img.css({
'top':0,
});
}else if(bigpicTop-(viewbox_h/2) > viewbox_b ){
viewbox.css({
'top': viewbox_b,
});
preview_img.css({
'top':-viewbox_b/scale_h,
});
}
if( bigpicLeft-(viewbox_w/2) > 0 && bigpicLeft-(viewbox_w/2)< viewbox_r ){
viewbox.css({
'left':bigpicLeft-(viewbox_w/2),
});
preview_img.css({
'left':(-bigpicLeft+(viewbox_w/2))/scale_w,
});
}else if( bigpicLeft-(viewbox_w/2) < 0 ){
viewbox.css({
'left':0,
});
preview_img.css({
'left':0,
});
}else if( bigpicLeft-(viewbox_w/2) > viewbox_r ){
viewbox.css({
'left':viewbox_r,
});
preview_img.css({
'left':-viewbox_r/scale_w,
});
}
}
})
.on('mouseleave','.picbox',function(){
$('.productImg .viewbox').css({
'opacity':0,
});
$('.productImg .preview').remove();
preview_str= ''
});
}
/*影片效果*/
function videoBox(){
//影片控制
$(".moreview").on('click','.video_control',function(){
var video = document.getElementById("Video");
if(video.paused){
$(this).addClass('fa-pause').removeClass('fa-play');
video.play();
}else{
$(this).addClass('fa-play').removeClass('fa-pause');
video.pause();
}
});
//影片預覽圖
if(document.getElementById("Video")){
document.getElementById("Video").oncanplay=function(){
var video = $("#Video").get(0);
var canvas = document.getElementById("video_review");
canvas.getContext('2d').drawImage(video, 0, 0, 66, 92);
};
}
}