1 回答

TA贡献1951条经验 获得超3个赞
您必须定义minZoom和maxZoom值并与 进行比较currZoom。通过包装在if条件和更改元素中比较值CSS。
试试这个代码。
<button class="zoomIn">Zoom In</button>
<button class="zoomOff">Reset</button>
<button class="zoomOut">Zoom Out</button>enter code here
<script>
$('.open-book').css({
// 'position' : 'absolute',
'top' : '0px',
'left' : '0px',
'height' : $('.outboard').height(),
'width' : $('.outboard').width()
});
var currZoom = 1;
var minZoom = 1;
var maxZoom = 2;
$(".zoomIn").click(function(){
if(maxZoom >= currZoom){
currZoom+=0.1;
$('.open-book').css({
// 'position' : 'absolute',
// 'top' : '45px',
// 'left' : '20px',
// 'height' : $(window).height()-65,
// 'width' : $(window).width()-40,
'zoom' : currZoom
});
}
});
$(".zoomOff").click(function(){
currZoom=1;
$(".open-book").css({
// 'position' : 'absolute',
// 'top' : '45px',
// 'left' : '20px',
// 'height' : $(window).height()-65,
// 'width' : $(window).width()-40,
'zoom' : currZoom
});
});
$(".zoomOut").click(function(){
if(minZoom <= currZoom){
currZoom-=0.1;
$('.open-book').css({
// 'position' : 'absolute',
// 'top' : '45px',
// 'left' : '20px',
// 'height' : $(window).height()-65,
// 'width' : $(window).width()-40,
'zoom' : currZoom
});
}
});
</script>
添加回答
举报