|
| 1 | +var element = document.getElementById('mobile_control'); |
| 2 | +var hammertime = new Hammer(element); |
| 3 | + |
| 4 | +var swiped_top = false; |
| 5 | + |
| 6 | +hammertime.get('swipe').set({ direction: Hammer.DIRECTION_ALL }); |
| 7 | +hammertime.on('swipeleft', function(ev) { |
| 8 | + cmove("prev"); |
| 9 | +}); |
| 10 | +hammertime.on('swiperight', function(ev) { |
| 11 | + cmove("next"); |
| 12 | +}); |
| 13 | +hammertime.on('swipeup', function(ev) { |
| 14 | + swiped_top = true; |
| 15 | + openmodal(); |
| 16 | +}); |
| 17 | +hammertime.on('swipedown', function(ev) { |
| 18 | + closemodal(); |
| 19 | +}); |
| 20 | +/* * * * * * * * * */ |
| 21 | + |
| 22 | +$(".action").on("click", function(){ |
| 23 | + cmove($(this).attr('id')); |
| 24 | +}); |
| 25 | + |
| 26 | +$('.title').each(function(){ |
| 27 | + $(this).html("Earth".replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>")); |
| 28 | +}); |
| 29 | + |
| 30 | + |
| 31 | +anime.timeline({}) |
| 32 | +.add({ |
| 33 | + targets: '.title', |
| 34 | + opacity: [0,1], |
| 35 | + easing: "easeOutExpo", |
| 36 | + duration: 100 |
| 37 | +}) |
| 38 | +.add({ |
| 39 | + targets: '.title .letter', |
| 40 | + translateX: [40,0], |
| 41 | + translateZ: 0, |
| 42 | + opacity: [0,1], |
| 43 | + easing: "easeOutExpo", |
| 44 | + duration: 1200, |
| 45 | + delay: function(el, i) { |
| 46 | + return 500 + 30 * i; |
| 47 | + } |
| 48 | +}); |
| 49 | + |
| 50 | +var angle = 0; |
| 51 | +var planet_id = 0; |
| 52 | + |
| 53 | +function cmove(dir){ |
| 54 | + var n_planet = 8, next_id; |
| 55 | + var prev, next; |
| 56 | + var top = $("#pl"+ planet_id); |
| 57 | + var orbit = $(".planet_container"); |
| 58 | + |
| 59 | + top.removeClass("pt"); |
| 60 | + |
| 61 | + if(planet_id == 0){ |
| 62 | + prev = $("#pl"+ (n_planet-1)); |
| 63 | + next = $("#pl"+ (planet_id+1)%n_planet); |
| 64 | + }else{ |
| 65 | + prev = $("#pl"+ (planet_id-1)); |
| 66 | + next = $("#pl"+ (planet_id+1)%n_planet); |
| 67 | + } |
| 68 | + |
| 69 | + if(dir == "prev"){ |
| 70 | + next_id = (planet_id + 1) % n_planet; |
| 71 | + angle -= 45; |
| 72 | + next.addClass("pt"); |
| 73 | + planet_id++; |
| 74 | + }else{ |
| 75 | + if(planet_id == 0){ |
| 76 | + next_id = 7; |
| 77 | + planet_id = 7; |
| 78 | + }else{ |
| 79 | + next_id = planet_id-1; |
| 80 | + --planet_id; |
| 81 | + } |
| 82 | + angle += 45; |
| 83 | + prev.addClass("pt"); |
| 84 | + } |
| 85 | + |
| 86 | + $(".active").removeClass("active"); |
| 87 | + $("#p" + planet_id).addClass("active"); |
| 88 | + $(".info_back h1").text(planet[next_id]); |
| 89 | + |
| 90 | + if(swiped_top){ |
| 91 | + $('.info_back h1').each(function(){ |
| 92 | + $(this).html(planet[planet_id].replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>")); |
| 93 | + }); |
| 94 | + |
| 95 | + anime.timeline({}) |
| 96 | + .add({ |
| 97 | + targets: '.info_back h1', |
| 98 | + opacity: [0,1], |
| 99 | + easing: "easeOutExpo", |
| 100 | + duration: 100 |
| 101 | + }) |
| 102 | + .add({ |
| 103 | + targets: '.info_back h1 .letter', |
| 104 | + translateX: [40,0], |
| 105 | + translateZ: 0, |
| 106 | + opacity: [0,1], |
| 107 | + easing: "easeOutExpo", |
| 108 | + duration: 1200, |
| 109 | + delay: function(el, i) { |
| 110 | + return 500 + 30 * i; |
| 111 | + } |
| 112 | + }); |
| 113 | + } |
| 114 | + |
| 115 | + $('.title').each(function(){ |
| 116 | + $(this).html(planet[next_id].replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>")); |
| 117 | + }); |
| 118 | + |
| 119 | + anime.timeline({}) |
| 120 | + .add({ |
| 121 | + targets: '.title .letter', |
| 122 | + translateX: [40,0], |
| 123 | + translateZ: 0, |
| 124 | + opacity: [0,1], |
| 125 | + easing: "easeOutExpo", |
| 126 | + duration: 1200, |
| 127 | + delay: function(el, i) { |
| 128 | + return 500 + 30 * i; |
| 129 | + } |
| 130 | + }); |
| 131 | + |
| 132 | + $('.pn').each(function(){ |
| 133 | + $(this).html(planet[next_id].replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>")); |
| 134 | + }); |
| 135 | + |
| 136 | + anime.timeline({}) |
| 137 | + .add({ |
| 138 | + targets: '.pn .letter', |
| 139 | + translateX: [40,0], |
| 140 | + translateZ: 0, |
| 141 | + opacity: [0,1], |
| 142 | + easing: "easeOutExpo", |
| 143 | + duration: 1200, |
| 144 | + delay: function(el, i) { |
| 145 | + return 500 + 30 * i; |
| 146 | + } |
| 147 | + }); |
| 148 | + |
| 149 | + var ani_dir = (dir == "next") ? "0%" : "100%"; |
| 150 | + |
| 151 | + anime.timeline({}) |
| 152 | + .add({ |
| 153 | + targets: '.planet_photo', |
| 154 | + backgroundPosition: ['50% -75%', ani_dir + ' -85%'], |
| 155 | + opacity: { |
| 156 | + value: [1,0] |
| 157 | + }, |
| 158 | + duration: 700, |
| 159 | + easing: 'easeOutQuad', |
| 160 | + complete: function(anim){ |
| 161 | + $(".planet_photo").css("background-image", "url(" + photo_planet[next_id] +")"); |
| 162 | + } |
| 163 | + }) |
| 164 | + .add({ |
| 165 | + targets: '.planet_photo', |
| 166 | + backgroundPosition: ['0% -85%', '50% -75%'], |
| 167 | + opacity: [0.2,1], |
| 168 | + duration: 500, |
| 169 | + easing: 'easeOutQuad' |
| 170 | + }); |
| 171 | + |
| 172 | + $(".info_back").css("background-image", "url(" + photo_planet[next_id] +")"); |
| 173 | + orbit.css("transform", "rotateZ(" + angle + "deg)"); |
| 174 | +} |
| 175 | + |
| 176 | +$("#open_menu").on("click", function(){ |
| 177 | + $(".menu").show(); |
| 178 | +}); |
| 179 | + |
| 180 | +$(".close").on("click", function(){ |
| 181 | + $(".menu").hide(); |
| 182 | +}); |
| 183 | + |
| 184 | +$(".more").on("click", function(){ |
| 185 | + swiped_top = true; |
| 186 | + openmodal(); |
| 187 | +}); |
| 188 | + |
| 189 | +function openmodal(){ |
| 190 | + anime.timeline({}) |
| 191 | + .add({ |
| 192 | + targets: '.carousel', |
| 193 | + translateY: ["100%", 0], |
| 194 | + duration: 600, |
| 195 | + easing: 'easeOutQuad', |
| 196 | + }); |
| 197 | + |
| 198 | + $('.info_back h1').each(function(){ |
| 199 | + $(this).html(planet[planet_id].replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>")); |
| 200 | + }); |
| 201 | + |
| 202 | + anime.timeline({}) |
| 203 | + .add({ |
| 204 | + targets: '.info_back h1', |
| 205 | + opacity: [0,1], |
| 206 | + easing: "easeOutExpo", |
| 207 | + duration: 100 |
| 208 | + }) |
| 209 | + .add({ |
| 210 | + targets: '.info_back h1 .letter', |
| 211 | + translateX: [40,0], |
| 212 | + translateZ: 0, |
| 213 | + opacity: [0,1], |
| 214 | + easing: "easeOutExpo", |
| 215 | + duration: 1200, |
| 216 | + delay: function(el, i) { |
| 217 | + return 500 + 30 * i; |
| 218 | + } |
| 219 | + }); |
| 220 | +} |
| 221 | + |
| 222 | +function closemodal(){ |
| 223 | + if(swiped_top){ |
| 224 | + anime.timeline({}) |
| 225 | + .add({ |
| 226 | + targets: '.carousel', |
| 227 | + translateY: [0, "100%"], |
| 228 | + duration: 600, |
| 229 | + easing: 'easeOutQuad', |
| 230 | + }); |
| 231 | + swiped_top = false; |
| 232 | + } |
| 233 | +} |
| 234 | + |
| 235 | +var photo_planet = ["https://i.kinja-img.com/gawker-media/image/upload/s--gBFsZfZv--/c_scale,fl_progressive,q_80,w_800/18mozgxwgu2ibjpg.jpg", "https://upload.wikimedia.org/wikipedia/commons/0/02/OSIRIS_Mars_true_color.jpg", "http://cdn.sci-news.com/images/enlarge3/image_4461e-Jupiter.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Jewel_of_the_Solar_System.jpg/1280px-Jewel_of_the_Solar_System.jpg", "https://upload.wikimedia.org/wikipedia/commons/3/3d/Uranus2.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Neptune_Full.jpg/275px-Neptune_Full.jpg", "http://annesastronomynews.com/wp-content/uploads/2012/02/Mercury-has-a-large-iron-core-which-generates-a-magnetic-field-and-is-heavily-cratered-with-regions-of-smooth-plains.-It-has-no-natural-satellites-and-no-substantial-atmosphere.jpg", "https://www.universetoday.com/wp-content/uploads/2008/10/Venus-e1489179310371.jpg"]; |
| 236 | +var planet = ["earth", "mars", "jupiter", "saturn", "uranus", "neptune", "mercury", "venus"]; |
0 commit comments