0
오버플로 지역 사회, 를 사용하여 스크롤하고 내가 JS와 JS에 대한 지식의 부족으로 그런 일을 만들고 싶었다 동기화 스프라이트 내가 스크롤하여 플레이 애니메이션을 찾고 있었다 ScrollMagic
발견 라이브러리. 그러나 모든 요소를 복사하여 지나치더라도 여전히 작동하지 않습니다.// initialise ScrollMagic controller
var controller = new ScrollMagic.Controller();
// create Tween
var tween = TweenMax.to("#js-animation", 1.0, {
\t backgroundPosition: "100% 0",
\t ease: SteppedEase.config(480)
})
// build scene
var scene = new ScrollMagic.Scene({duration: 15000})
\t .triggerHook("onCenter")
\t .setPin("#js-pinned")
\t .setTween(tween)
\t .addTo(controller);
body {
padding: 20px;
text-align: center;
}
.container {
font-size: 15em;
min-height: 110vh;
}
.cnc {
margin: auto;
width: 50%;
height: 50%;
background: url('http://image.gilawhost.com/16/12/29/9mq5kqgu.png') no-repeat 0 0%;
background-size: 100%;
}
h1 {
font-size: 1.2em;
}
p {
width: 60%;
margin: auto;
text-align: left;
}
.p {
margin-top: 120px;
font-size: 14px;
text-align: center;
}
<!DOCTYPE html>
<!--
come from the demo de Tom Bennet
http://www.sitepoint.com/responsive-sprite-animations-imagemagick-greensock
-->
<html >
<head>
<meta charset="UTF-8">
<title>Demo 4: Synchronising Playback with the Scrollbar</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
</head>
<body>
<h1>Demo 4: Synchronising Playback with the Scrollbar</h1>
<p>A responsive sprite animation that is synchronised with the scrollbar, and that remains in a fixed position for its duration of 1500 pixels. Scroll up and down to control playback.</p>
<div class="container" id="js-pinned">
<div class="cnc" id="js-animation"></div>
</div>
<p class="p">Demo by Tom Bennet. <a href="http://www.sitepoint.com/responsive-sprite-animations-imagemagick-greensock" target="_blank">See article</a>.</p>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.16.1/TweenMax.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.2/ScrollMagic.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.2/plugins/animation.gsap.min.js'></script>
</body>
</html>
은 잘 작동, 감사합니다! –