У меня есть SVG, который представляет собой ряд ящиков, которые я хочу масштабировать на 150% при прокрутке окна, а затем обратно в исходный размер.Как масштабировать SVG на свитке?
Я довольно новичок в JavaScript, поэтому не знаю, почему он не работает.
Вот мой JSFiddle
Ниже мой код:
HTML:
<div class="container">
<svg class="scale" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 219.7 104.3" style="enable-background:new 0 0 219.7 104.3;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#000000;stroke-width:5;stroke-miterlimit:10;}
</style>
<rect x="18.9" y="15.3" class="st0" width="22.2" height="22.2"/>
<rect x="71.5" y="15.3" class="st0" width="22.2" height="22.2"/>
<rect x="125.3" y="15.3" class="st0" width="22.2" height="22.2"/>
<rect x="177.8" y="15.3" class="st0" width="22.2" height="22.2"/>
<rect x="18.9" y="60.8" class="st0" width="22.2" height="22.2"/>
<rect x="71.5" y="60.8" class="st0" width="22.2" height="22.2"/>
<rect x="125.3" y="60.8" class="st0" width="22.2" height="22.2"/>
<rect x="177.8" y="60.8" class="st0" width="22.2" height="22.2"/>
</svg>
</div>
<div class="spacer"></div>
<div class="spacer"></div>
CSS:
.container {
width:800px;
}
.spacer {
height:500px;
}
JS:
$(window).scroll(function() {
$(".scale").css({"-moz-transform": scale(150), "webkit-transform": scale(150)});
});
Спасибо, я очень ценю помощь!
Ах, спасибо вам за помощь! Однако он просто масштабирует svg по умолчанию, но не при прокрутке страницы. – user3663071