效果不错就是用的js有点多啊 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>scroll effect with scrollmagic and gsap</title> <style type="text/css"> body { background:linear-gradient(to right, #062129 0%, #100a1c 100%); background-attachment: fixed; } .container { max-width: 400px; width: 100%; height: auto; margin: 60px auto; text-align: center; padding-bottom: 100px; } h1, p, h3 { color: #f1e1fd; font-family: "Open Sans", Helvetica; margin: 10px 0px; } p { line-height: 24px; font-size: 15px; } a { margin-top: 30px; display: block; } </style> </head> <body> <div class="container"> <div> <h1>Kaleidoscope</h1> <h3>Ray Bradbury</h3> </div> <p>The first concussion cut the rocket up the side with a giant can opener.</p> <p>The men were thrown into space like a dozen wriggling silverfish.</p> <p>They were scattered into a dark sea; and the ship, in a million pieces, went on, a meteor swarm seeking a lost sun.</p> <p>"Barkley, Barkley, where are you?"</p> <p>The sound of voices calling like lost children on a cold night</p> <p>"Woode, Woode!"</p> <p>"Captain!"</p> <p>"Hollis, Hollis, this is Stone."</p> <p>"Stone, this is Hollis. Where are you?"</p> <p>"I don't know. How can I? Which way is up? I'm falling. Good God, I'm falling."</p> <p>They fell. They fell as pebbles fall down wells. They were scattered as jackstones are scattered from a gigantic throw.</p> <p> And now instead of men there were only voices-all kinds of voices, disembodied and impassioned, in varying degrees of terror and resignation.</p> <p>"We're going away from each other."</p> <p>This was true. Hollis, swinging head over heels, knew this was true. He knew it with a vague acceptance. </p> <p>They were wearing their sealed-tight space suits with the glass tubes over their pale faces, but they hadn't had time to lock on their force units. </p> <p>With them they could be small lifeboats in space, saving themselves, saving others, collecting together, finding each other until they were an island of men with some plan. </p> <p> But without the force units snapped to their shoulders they were meteors, senseless, each going to a separate and irrevocable fate.</p> <p>A period of perhaps ten minutes elapsed while the first terror died and a metallic calm took its place.</p> <p>Space began to weave its strange voices in and out, on a great dark loom, crossing, recrossing, making a final pattern</p> <p>"Stone to Hollis. How long can we talk by phone?"</p> <p> "It depends on how fast you're going your way and I'm going mine.</p> <p>"An hour, I make it."</p> <p> "That should do it," said Hollis, abstracted and quiet</p> <p> "What happened?" said Hollis a minute later</p> <p> "Which way are you going?"</p> <p> "It looks like I'll hit the moon."</p> <p>"It's Earth for me. Back to old Mother Earth at ten thousand miles per hour. I'll burn like a match."</p> <p>Hollis thought of it with a queer abstraction of mind. He seemed to be removed from his body, watching it fall down and down through space, as objective as he had been in regard to the first falling snowflakes of a winter season long gone.</p> <p>The others were silent, thinking of the destiny that had brought them to this, falling, falling, and nothing they could do to change it.</p> <p> Even the captain was quiet, for there was no command or plan he knew that could put things back together again.</p> <p>"Oh, it’s a long way down. Oh, it's a long way down, a long, long, long way down," said a voice. "I don't want to die, I don’t want to die, it's a long way down."</p> <p>“Who’s that?”</p> <p>“I don’t know.”</p> <p>“Stimson, I think. Stimson, is that you?”</p> <p>“It’s a long, long way and I don’t like it. Oh, God, I don’t like it.”</p> <p>“Stimson, this is Hollis. Stimson, you hear me?”</p> <p>A pause while they fell separate from one another.</p> <p>“Stimson?”</p> <p>“Yes.” He replied at last.</p> <p>“Stimson, take it easy; we’re all in the same fix.”</p> <p>“I don’t want to be here. I want to be somewhere else.”</p> <p>“There’s a chance we’ll be found.”</p> <p>“I must be, I must be,” said Stimson. “I don’t believe this; I don’t believe any of this is happening.”</p> <p>“It’ s a bad dream,” said someone.</p> <p>“Shut up!” said Hollis.</p> <p>“Come and make me,” said the voice. It was Applegate. He laughed easily, with a similar objectivity. “Come and shut me up.”</p> <p>Hollis for the first time felt the impossibility of his position. A great anger filled him, for he wanted more than anything at this moment to be able to do something to Applegate. He had wanted for many years to do something and now it was too late. Applegate was only a telephonic voice.</p> <p>Falling, falling, falling…</p> <a href="http://www.scaryforkids.com/kaleidoscope-by-ray-bradbury/" target="_blank">full text</a> </div> </body> <script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.5/TweenMax.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/animation.gsap.js"></script> <script type="text/javascript"> var controller = new ScrollMagic.Controller(); TweenMax.fromTo($(".container"), 0.7, { autoAlpha: 0, "transform": "translateY(40px)" }, { autoAlpha: 1, "transform": "translateY(0px)" }) $("p").each(function(index, elem) { var textFadeOut = new ScrollMagic.Scene({ triggerElement: elem, triggerHook: "onLeave", duration: 400, offset: -150 }).setTween(TweenMax.fromTo($(this), 0.3, { autoAlpha: 1 }, { autoAlpha: 0, })).addTo(controller), textFadeIn = new ScrollMagic.Scene({ triggerElement: elem, triggerHook: "onEnter", duration: 400, offset: 50 }).setTween(TweenMax.fromTo($(this), 0.3, { autoAlpha: 0, "transform": "translateY(80px)" }, { autoAlpha: 1, "transform": "translateY(0px)" })).addTo(controller); }); </script> </html> 提示:你可以先修改部分代码再运行。 转载请注明:有爱前端 » scrollmagic and gsap滚动特效 喜欢 (4)or分享 (0)