HTML和Javascript
<section>
<h1>Panning and zooming with CSS3</h1>
<div class="parent">
<div class="panzoom">
<img src="image1" width="400" height="400">
</div>
</div>
<div class="buttons">
<button class="zoom-in">Zoom In</button>
<button class="zoom-out">Zoom Out</button>
<input type="range" class="zoom-range">
<button class="reset">Reset</button>
</div>
<script>
(function() {
var $section = $('section').first();
$section.find('.panzoom').panzoom({
$zoomIn: $section.find(".zoom-in"),
$zoomOut: $section.find(".zoom-out"),
$zoomRange: $section.find(".zoom-range"),
$reset: $section.find(".reset")
});
})();
</script>
</section>
我正在使用Pan Zoom插件。
https://github.com/timmywil/jquery.panzoom
如何限制Zoomout功能。我的意思是我想将图像缩小到图像的特定大小,如100像素。
演示 http://timmywil.github.io/jquery.panzoom/demo/#inverted-contain
我试过Inverted containment within the parent element (to hide what's behind)
来自演示。但对我来说它不起作用。请帮忙。
答案 0 :(得分:0)
我知道这是旧的,但如果你玩minScale,你可以得到你喜欢的。 您可以阅读README文件中的文档:
https://github.com/timmywil/jquery.panzoom/blob/master/README.md
答案 1 :(得分:0)
试试这个,这对你有用
(function() {
var $section = $('section').first();
$section.find('.panzoom').panzoom({
increment: 0.3,
minScale: 0.8,
maxScale: 1.3
});