我正在使用 jquery.viewport 创建视口功能:我使用 jquery ui 创建滑块和自己编写的缩放功能来缩放图像。此外,使用此插件创建视口功能。
http://borbit.github.com/jquery.viewport/
问题是,我缩放图像后,可拖动区域只是内容的一部分。这意味着我不能在它的某些区域拖动内容。有没有办法解决这个问题?谢谢
html:
<div id="view">
<img src="demo/Web081112_P002_text.png" id = "largeText"/>
<img src="demo/Web081112_P002_image.jpg" id = "largeImg"/>
</div>
<div id='slider' style='display:block;position:fixed;z-index:105;height:25%;right: 2%;top:25%;'></div>
Javascript
<script>
$(document).ready(function(){
$("#view").css("height",$(window).height());
$("#view").css("width",$(window).width());
/*
$("#box").css("height",$("#largeImg").height());
$("#box").css("width",$("#largeImg").width());
*/
//initiate the viewport
var element = $('#view').viewport();
var content = element.viewport('content');
content.draggable({containment: 'parent'});
content.scraggable({containment: 'parent'});
$( "#slider" ).slider({
orientation: "vertical",
range: "min",
min: 100,
max: 200,
value: 100,
slide: function( event, ui ) {
$("#largeText").css("width",ui.value+"%");
$("
#largeImg").css("width",ui.value+"%");
$("#largeText").css("height",ui.value+"%");
$("#largeImg").css("height",ui.value+"%");
$("#largeText").css('top', ($("#view").height()/2-$("#largeText").height()/2) +'px');
$("#largeImg").css('top', ($("#view").height()/2-$("#largeImg").height()/2) +'px');
$('#largeText').css('left', ($("#view").width()/2 - $('#largeText').width()/2)+'px');
$('#largeImg').css('left', ($("#view").width()/2 - $('#largeImg').width()/2)+'px');
//element.viewport('update');
//Using this statement to update will occur error.
}
});
});
</script>
CSS:
<style>
#view {
height:600px;
width:350px;
}
#largeImg {
position:absolute;
display:block;
width: 1250px;
height: 1500px;
z-index: 100;
}
#largeText {
position:absolute;
display:block;
width: 1250px;
height: 1500px;
z-index: 101;
}
body {
width : auto;
height: auto;
overflow:hidden;
}
</style>