Листья, летящие при сильном ветре с использованием jQuery
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
.leaf { position: absolute; right: 0; background-image: url("/img/maple.png"); width: 50px; height: 50px; background-repeat: no-repeat; background-size: contain; } .leaf:nth-child(1) { -webkit-filter: blur(1px); filter: blur(1px); top: 49vh; right: -70vh; } .leaf:nth-child(2) { -webkit-filter: blur(1px); filter: blur(1px); top: 19vh; right: -61vh; } .leaf:nth-child(3) { -webkit-filter: blur(1px); filter: blur(1px); top: 99vh; right: -35vh; } .leaf:nth-child(4) { -webkit-filter: blur(1px); filter: blur(1px); top: 37vh; right: -45vh; } .leaf:nth-child(5) { -webkit-filter: blur(1px); filter: blur(1px); top: 70vh; right: -6vh; } .leaf:nth-child(6) { -webkit-filter: blur(1px); filter: blur(1px); top: 59vh; right: -89vh; } .leaf:nth-child(7) { -webkit-filter: blur(1px); filter: blur(1px); top: 22vh; right: -5vh; } .leaf:nth-child(8) { -webkit-filter: blur(1px); filter: blur(1px); top: 56vh; right: -43vh; } .leaf:nth-child(9) { -webkit-filter: blur(1px); filter: blur(1px); top: 44vh; right: -68vh; } .leaf:nth-child(10) { -webkit-filter: blur(1px); filter: blur(1px); top: 91vh; right: -84vh; } .leaf:nth-child(11) { -webkit-filter: blur(1px); filter: blur(1px); top: 2vh; right: -8vh; } .leaf:nth-child(12) { -webkit-filter: blur(1px); filter: blur(1px); top: 8vh; right: -3vh; } .leaf:nth-child(13) { -webkit-filter: blur(1px); filter: blur(1px); top: 100vh; right: -87vh; } .leaf:nth-child(14) { -webkit-filter: blur(1px); filter: blur(1px); top: 3vh; right: -59vh; } .leaf:nth-child(15) { -webkit-filter: blur(1px); filter: blur(1px); top: 72vh; right: -10vh; } .leaf:nth-child(16) { -webkit-filter: blur(1px); filter: blur(1px); top: 32vh; right: -10vh; } .leaf:nth-child(17) { -webkit-filter: blur(1px); filter: blur(1px); top: 93vh; right: -4vh; } .leaf:nth-child(18) { -webkit-filter: blur(1px); filter: blur(1px); top: 7vh; right: -56vh; } .leaf:nth-child(19) { -webkit-filter: blur(1px); filter: blur(1px); top: 64vh; right: -49vh; } .leaf:nth-child(20) { -webkit-filter: blur(1px); filter: blur(1px); top: 10vh; right: -8vh; } |
1 2 |
<script src='//cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js'></script> <script src='/js/lodash.min2.js'></script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <div class="leaf"></div> <script > $('.leaf').each(function () {var _this = this; var tl = new TimelineMax({ repeat: -1 }); tl.to(this, 10 + Math.random() * 10, { rotationX: Math.random() * 3360, rotationY: Math.random() * 3360, rotationZ: Math.random() * 3360, z: Math.random() * 700, x: -window.innerWidth * 3, y: window.innerWidth / 2, ease: Power4.easeOut, onUpdate: function onUpdate(e) { //var x = this.vars.css.x; if ($(_this).position().left < -100) { tl.seek(0); } } }); }); </script> |