[关闭]
@Mercedes-Benz 2016-07-27T18:22:15.000000Z 字数 26281 阅读 544

Velvet Hammer | Music and Management Group APP.JS代码组织

用于Evernote里的笔记


  1. var _state = null;
  2. function change_my_url(_state, _title, _url){
  3. History.pushState(_state, _title, _url);
  4. }
  5. History.Adapter.bind(window,'statechange',function(){
  6. var _state = History.getState();
  7. document.title = _state['title'] + ' | Velvet Hammer';
  8. });
  9. (function() {
  10. var lastTime = 0;
  11. var vendors = ['webkit', 'moz'];
  12. for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
  13. window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
  14. window.cancelAnimationFrame =
  15. window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
  16. }
  17. if (!window.requestAnimationFrame)
  18. window.requestAnimationFrame = function(callback, element) {
  19. var currTime = new Date().getTime();
  20. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  21. var id = window.setTimeout(function() { callback(currTime + timeToCall); },
  22. timeToCall);
  23. lastTime = currTime + timeToCall;
  24. return id;
  25. };
  26. if (!window.cancelAnimationFrame)
  27. window.cancelAnimationFrame = function(id) {
  28. clearTimeout(id);
  29. };
  30. }());
  31. var app = {
  32. common : {
  33. onready : function(){
  34. var _body = $('body');
  35. var dset;
  36. dset = window.setTimeout(function(){
  37. _body.addClass('ready');
  38. window.clearTimeout(dset);
  39. },400);
  40. /* ----------
  41. Composant :
  42. _ Menu
  43. ---------- */
  44. var _menu = $('.menu');
  45. var menu = "";
  46. var $this = "";
  47. _menu.bind('click',function(){
  48. $this = $(this);
  49. menu = $this.attr('data-menu');
  50. _body.toggleClass(menu+'-on');
  51. if(!$('.page--'+menu).hasClass('on')){
  52. $('.page--'+menu).addClass('on');
  53. TweenLite.to($('.page--'+menu), 0.7, {css:{scale:1, opacity:1}, ease:Expo.easeOut});
  54. TweenLite.to($('.page--'+menu+' ul li'), 0.4, {css:{y:'0%', opacity:1}, ease:Expo.easeOut});
  55. }
  56. else{
  57. TweenLite.to($('.page--'+menu+' ul'), 0.4, {css:{opacity:0}, ease:Expo.easeOut, onComplete:function(){
  58. TweenLite.to($('.page--'+menu), 0.7, {css:{scale:1.2, opacity:0}, ease:Expo.easeOut, onComplete:function(){
  59. $('.page--'+menu).removeClass('on');
  60. TweenLite.set($('.page--'+menu+' ul'), {css:{opacity:1}});
  61. TweenLite.set($('.page--'+menu+' ul li'), {css:{y:'100%', opacity:0}});
  62. }});
  63. }});
  64. }
  65. });
  66. jQuery.extend( jQuery.easing,
  67. {
  68. easeInOutQuad: function (x, t, b, c, d) {
  69. if ((t/=d/2) < 1) return c/2*t*t + b;
  70. return -c/2 * ((--t)*(t-2) - 1) + b;
  71. }
  72. });
  73. function SVG(tag) {
  74. return document.createElementNS('http://www.w3.org/2000/svg', tag);
  75. }
  76. function replaceCirclesWithPaths(parentElement) {
  77. var circles = $(parentElement).find('circle');
  78. $.each(circles, function() {
  79. var cX = $(this).attr('cx');
  80. var cY = $(this).attr('cy');
  81. var r = $(this).attr('r');
  82. var r2 = parseFloat(r * 2);
  83. var convertedPath = 'M' + cX + ', ' + cY + ' m' + (-r) + ', 0 ' + 'a ' + r + ', ' + r + ' 0 1,0 ' + r2 + ',0 ' + 'a ' + r + ', ' + r + ' 0 1,0 ' + (-r2) + ',0 ';
  84. $(SVG('path'))
  85. .attr('d', convertedPath)
  86. .attr('fill', $(this).attr('fill'))
  87. .attr('stroke', $(this).attr('stroke'))
  88. .attr('class', $(this).attr('class'))
  89. .attr('stroke-width', $(this).attr('stroke-width'))
  90. .insertAfter(this);
  91. });
  92. $(circles).remove();
  93. }
  94. function hideSVGPaths(parentElement) {
  95. var paths = $(parentElement).find('path');
  96. //for each PATH..
  97. $.each( paths, function() {
  98. //get the total length
  99. var totalLength = this.getTotalLength();
  100. //set PATHs to invisible
  101. $(this).css({
  102. 'stroke-dashoffset': totalLength,
  103. 'stroke-dasharray': totalLength + ' ' + totalLength
  104. });
  105. });
  106. }
  107. function drawSVGPaths(_parentElement, _timeMin, _timeMax, _timeDelay) {
  108. var paths = $(_parentElement).find('path');
  109. //for each PATH..
  110. $.each( paths, function(i) {
  111. //get the total length
  112. var totalLength = this.getTotalLength();
  113. //set PATHs to invisible
  114. $(this).css({
  115. 'stroke-dashoffset': totalLength,
  116. 'stroke-dasharray': totalLength + ' ' + totalLength
  117. });
  118. //animate
  119. $(this).delay(_timeDelay*i).animate({
  120. 'stroke-dashoffset': 0
  121. }, {
  122. duration: Math.floor(Math.random() * _timeMax) + _timeMin
  123. ,easing: 'easeInOutQuad'
  124. });
  125. });
  126. }
  127. function replaceWithPaths(parentElement) {
  128. replaceCirclesWithPaths(parentElement);
  129. }
  130. function startSVGAnimation(parentElement) {
  131. drawSVGPaths(parentElement, 1000, 2000, 50);
  132. }
  133. replaceWithPaths($('#js-control'));
  134. // startSVGAnimation($('#js-control'));
  135. /* ----------
  136. Composant :
  137. _ SoundCloud
  138. ---------- */
  139. SC.initialize({
  140. client_id: '3a98eed17a0d81ea969770fef94e7f58',
  141. redirect_uri: 'http://velvethammer.net/'
  142. });
  143. var playing=false;
  144. // SC.get('/resolve', {
  145. // url: 'https://soundcloud.com/velvethammer'
  146. // }, function(user) {
  147. // console.log(user);
  148. // });
  149. // users/velvethammer/tracks
  150. SC.get("/users/4616395/playlists", {limit: 10}, function(playlist){
  151. // console.log(playlist);
  152. var selected = playlist[0];
  153. $('#js-comment').html(selected.title);
  154. var lenght = selected.tracks.length;
  155. // console.log(playlist[0].tracks);
  156. for(var key in selected.tracks.slice(0)){
  157. //console.log(selected.tracks[key]);
  158. //if(selected.tracks[key].permalink != null){
  159. $('#js-soundcloud').append('<li><a id="' + selected.tracks[key].id + '" href="#">' + selected.tracks[key].title + '</a></li>');
  160. //}
  161. }
  162. $('#js-playericon').click(function(){
  163. event.preventDefault();
  164. var $this = $(this);
  165. if(playing==true){
  166. $this.removeClass('playing');
  167. playing=false;
  168. }
  169. else{
  170. $('#js-soundcloud li:first-child a').trigger('click');
  171. $this.addClass('playing');
  172. playing=true;
  173. }
  174. });
  175. $('#js-soundcloud li a').click(function(event) {
  176. event.preventDefault();
  177. var id = $(this).attr('id');
  178. $('#js-soundcloud li').removeClass('current');
  179. $(this).parent('li').addClass('current');
  180. playing=true;
  181. SC.stream("/tracks/"+ id , {autoPlay: false,ontimedcomments: function(comments){$('#js-comment').html(comments[0].body);}}, function(sound){
  182. $('#stop').trigger('click');
  183. sound.play({
  184. whileplaying: function() {
  185. $('#js-playericon').addClass('playing');
  186. var path = document.querySelector('.circle');
  187. var position = this.position;
  188. var duration = this.duration;
  189. var percent = position / duration;
  190. var current = Math.floor(percent * 185);
  191. path.setAttribute('stroke-dashoffset', current);
  192. },
  193. onfinish: function() {
  194. $('#js-playericon').removeClass('playing');
  195. playing=false;
  196. var path = document.querySelector('.circle');
  197. path.setAttribute('stroke-dashoffset', 0);
  198. }
  199. });
  200. $('#js-playericon').click(function(){
  201. //console.log(playing);
  202. var $this = $(this);
  203. if(playing==true){
  204. $this.removeClass('playing');
  205. playing=false;
  206. }
  207. else{
  208. $this.addClass('playing');
  209. playing=true;
  210. }
  211. sound.togglePause();
  212. });
  213. $('#stop').click(function(){
  214. sound.stop();
  215. $('#js-playericon').removeClass('playing');
  216. $('#js-comment').html('');
  217. playing=false;
  218. });
  219. });
  220. });
  221. });
  222. }
  223. },
  224. page : {
  225. onready : function(){
  226. },
  227. onload : function(){
  228. var _body = $('body');
  229. var _loader = $('.page--loader');
  230. var _single = $('.page--single');
  231. var _page_scroll = $('#page--scroll');
  232. var _menu = $('.menu');
  233. var _ff = $('#fixed-footer');
  234. var set;
  235. var set2;
  236. var set3;
  237. _body.addClass('loaded-on');
  238. var destY = 0;
  239. var y = window.pageYOffset;
  240. var h = window.innerHeight;
  241. var overviewSingle = document.getElementById("page--single");
  242. var overviewSingleHeight;
  243. var viewport = document.getElementById("scroll-viewport");
  244. var viewportHeight;
  245. var calcn = 0;
  246. var mobile;
  247. if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
  248. mobile = false;
  249. } else{ mobile = true; }
  250. // matrix3d
  251. var deg2rad, rotateX, rotateY, rotateZ, scale;
  252. deg2rad = 0;
  253. rotateX = 0;
  254. rotateY = 0;
  255. rotateZ = 0;
  256. scale = 1;
  257. var rotationXMatrix, rotationYMatrix, rotationZMatrix, s, scaleMatrix, transformationMatrix, translationMatrix;
  258. rotationXMatrix = $M([[1, 0, 0, 0], [0, Math.cos(rotateX * deg2rad), Math.sin(-rotateX * deg2rad), 0], [0, Math.sin(rotateX * deg2rad), Math.cos(rotateX * deg2rad), 0], [0, 0, 0, 1]]);
  259. rotationYMatrix = $M([[Math.cos(rotateY * deg2rad), 0, Math.sin(rotateY * deg2rad), 0], [0, 1, 0, 0], [Math.sin(-rotateY * deg2rad), 0, Math.cos(rotateY * deg2rad), 0], [0, 0, 0, 1]]);
  260. rotationZMatrix = $M([[Math.cos(rotateZ * deg2rad), Math.sin(-rotateZ * deg2rad), 0, 0], [Math.sin(rotateZ * deg2rad), Math.cos(rotateZ * deg2rad), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]);
  261. s = scale;
  262. scaleMatrix = $M([[s, 0, 0, 0], [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, 1]]);
  263. // if we want to cancel / run rAF
  264. var globalID;
  265. var globalSingle;
  266. function runa() {
  267. globalSingle = requestAnimationFrame(runa);
  268. // scrolltop & window.height
  269. if(mobile==false){
  270. y = $(window).scrollTop();
  271. }
  272. h = window.innerHeight;
  273. sf = document.getElementById('js-single-footer').getBoundingClientRect().top;
  274. if(mobile==false){
  275. calcn += (y - calcn) * 0.1;
  276. }
  277. // footer / menu
  278. if(sf<30){
  279. _menu.addClass('js-light');
  280. _page_scroll.addClass('js-fixed');
  281. }
  282. else if(sf>30){
  283. _menu.removeClass('js-light');
  284. _page_scroll.removeClass('js-fixed');
  285. }
  286. if(sf<(h-30)){
  287. _ff.addClass('js-light');
  288. }
  289. else if(sf>(h-30)){
  290. _ff.removeClass('js-light');
  291. }
  292. if(mobile==false){
  293. // matrix3d transform
  294. translationMatrix = $M([
  295. [1,0,0,0],
  296. [0,1,0,0],
  297. [0,0,1,0],
  298. [0,-calcn,0,1]
  299. ]);
  300. transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
  301. s = "matrix3d(";
  302. s += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
  303. s += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
  304. s += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
  305. s += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
  306. s += ")";
  307. overviewSingle.style["transform"] = s;
  308. overviewSingle.style["webkitTransform"] = s;
  309. overviewSingle.style["mozTransform"] = s;
  310. overviewSingle.style["msTransform"] = s;
  311. }
  312. }
  313. new imagesLoaded(document.body, function(instance) {
  314. TweenLite.set($('.single--artist'), {css:{scale:1.2, opacity: 0}});
  315. set = window.setTimeout(function(){
  316. _body.addClass('loaded');
  317. set2 = window.setTimeout(function(){
  318. _loader.removeClass('on');
  319. _body.addClass('single');
  320. _single.addClass('ready');
  321. TweenLite.to($('.single--artist'), 1, {css:{scale:1, opacity:1}, ease:Expo.easeOut, onComplete:function(){
  322. overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
  323. _page_scroll.css('height', overviewSingleHeight);
  324. globalSingle = requestAnimationFrame(runa);
  325. if(mobile==false){
  326. TweenLite.to($('.js-content'), 1, {css:{opacity:1}, ease:Expo.easeOut});
  327. TweenLite.to($('.single-close'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
  328. }
  329. }});
  330. $('.single-close').bind('click',function(){
  331. window.location="/";
  332. });
  333. $(document).keyup(function(e) {
  334. if(e.keyCode == 27 && document.body.classList.contains('single')){
  335. window.location="/";
  336. }
  337. });
  338. window.clearTimeout(set);
  339. window.clearTimeout(set2);
  340. },200);
  341. },1300);
  342. });
  343. set3 = window.setTimeout(function(){
  344. $('.bit-event-data').attr('style','');
  345. window.clearTimeout(set3);
  346. },300);
  347. },
  348. onresize : function(){
  349. }
  350. },
  351. home : {
  352. onready : function(){
  353. var _body = $('body');
  354. var _single = $('.page--single');
  355. /* ----------
  356. Composant :
  357. _ Spanify Letters.
  358. ---------- */
  359. var _band_t = document.getElementsByClassName("band--name");
  360. var text = "";
  361. var letter = "";
  362. var letters = text.split('');
  363. var spanified = [];
  364. for(var n=0;n<_band_t.length;n++){
  365. text = _band_t[n].innerHTML;
  366. letters = text.split('');
  367. spanified = [];
  368. for(var i = 0; i < letters.length; i++) {
  369. if(letters[i] === ' ') letters[i] = '&nbsp';
  370. letters[i] = '<span class="letter-mask"><span class="letter-inner">' + letters[i] + '</span></span>';
  371. spanified.push(letters[i]);
  372. }
  373. _band_t[n].innerHTML = spanified.join('');
  374. }
  375. /* ----------
  376. Composant :
  377. _ Slider
  378. ---------- */
  379. var c = 1;
  380. var l = $('.bands-slide').length;
  381. $('#item-1').addClass('slide-active');
  382. TweenLite.to($('#item-1'), 0.8, {css:{scale:1, opacity:1}, ease:Power3.easeOut});
  383. $('.slider-control.prev').bind('click', function(){
  384. if(c!=1){
  385. c--;
  386. }
  387. else {
  388. c=l;
  389. }
  390. $('.bands-slide').removeClass('slide-active');
  391. $('#item-'+c).addClass('slide-active');
  392. TweenLite.to($('#item-'+c), 1.1, {css:{scale:1, opacity:1}, ease:Power3.easeOut, onComplete:function(){
  393. TweenLite.set($('.bands-slide:not(#item-'+ c +')'), {css:{scale:1.2, opacity: 0}});
  394. }});
  395. });
  396. $('.slider-control.next').bind('click', function(){
  397. if(c!=l){
  398. c++;
  399. }
  400. else{
  401. c=1;
  402. }
  403. $('.bands-slide').removeClass('slide-active');
  404. $('#item-'+c).addClass('slide-active');
  405. TweenLite.to($('#item-'+c), 1.1, {css:{scale:1, opacity:1}, ease:Power3.easeOut, onComplete:function(){
  406. TweenLite.set($('.bands-slide:not(#item-'+ c +')'), {css:{scale:1.1, opacity: 0}});
  407. }});
  408. });
  409. },
  410. onload : function(){
  411. var _loader = $('.page--loader');
  412. var _intro = $('.page--intro');
  413. var _body = $('body');
  414. var _svg_loader = $('#svg-loader');
  415. var _svg_loader_img = $('#svg-loader-img');
  416. var _logo = $('.js-band--logo');
  417. var _page_single = $('#page--single');
  418. var _bands_slider = $('.bands-slider');
  419. var _page_scroll = $('#page--scroll');
  420. var _menu = $('.menu');
  421. var yOrigin = 0;
  422. var destY = 0;
  423. var smoothY = 0;
  424. var intro = document.getElementById("intro-content");
  425. var home_intro = $('.page--intro');
  426. var _ff = $('#fixed-footer');
  427. var y = $(window).scrollTop();
  428. var h = window.innerHeight;
  429. var viewport= document.getElementById("scroll-viewport");
  430. var overview = document.getElementById("scroll-overview");
  431. var overviewSingle = document.getElementById("page--single");
  432. var viewportHeight = viewport.getBoundingClientRect().height;
  433. // reset home intro so we get real height
  434. home_intro.css('height', viewportHeight);
  435. var overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
  436. var overviewHeight = overview.getBoundingClientRect().height;
  437. var calc = 0;
  438. var calcn = 0;
  439. var translationMatrix = "";
  440. var o = "";
  441. var set;
  442. var set1;
  443. var mobile;
  444. if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
  445. mobile = false;
  446. } else{ mobile = true; }
  447. _body.addClass('loaded-on');
  448. var bindto = document.querySelectorAll('.js-scrollto');
  449. var _bindto = Array.prototype.slice.call(bindto, 0);
  450. _bindto.forEach(function(_bind) {
  451. _bind.addEventListener('click', function(){
  452. var section = this.getAttribute('data-scroll');
  453. var to = $('#js-scrollto-'+section).offset().top;
  454. window.scrollTo(0, to);
  455. });
  456. });
  457. new imagesLoaded(overview, function(instance) {
  458. var overviewHeight = overview.getBoundingClientRect().height;
  459. _page_scroll.css('height', overviewHeight);
  460. set = window.setTimeout(function(){
  461. _body.addClass('loaded');
  462. _intro.removeClass('onload');
  463. set1 = window.setTimeout(function(){
  464. _loader.removeClass('on');
  465. run();
  466. window.clearTimeout(set);
  467. window.clearTimeout(set1);
  468. },200);
  469. },1300);
  470. });
  471. // reset
  472. _bands_slider.css('height', $('.band--img').height());
  473. var nodes = [];
  474. [].forEach.call(document.querySelectorAll('.js-el'), function(el,i) {
  475. nodes[i] = {
  476. el: el,
  477. direction: el.getAttribute('data-direction'),
  478. };
  479. });
  480. var loadert;
  481. function load_single(_title,_url){
  482. _body.addClass('single');
  483. _page_single.addClass('ready');
  484. yOrigin = $(window).scrollTop();
  485. window.scrollTo(0, 0);
  486. var gifLoader = new Image();
  487. gifLoader.onload = function() {
  488. _svg_loader_img.attr('src', gifLoader.src);
  489. // timeline
  490. var _tl_open = new TimelineLite({onComplete:function(){
  491. _svg_loader.addClass('show');
  492. _page_single.load(_url,{_title: _title},function(){
  493. change_my_url(null, _title, _url);
  494. if(mobile==false){
  495. TweenLite.set($('.single--artist'), {css:{scale:1.2, opacity: 0}});
  496. TweenLite.set($('.artist-name'), {css:{x:'-300%'}});
  497. TweenLite.set($('.artist-close'), {css:{x:'300%'}});
  498. }
  499. // change rAF
  500. new imagesLoaded(_page_single, function(instance) {
  501. _svg_loader.removeClass('show');
  502. TweenLite.to($('.single--artist'), 1, {css:{scale:1, opacity:1}, ease:Expo.easeOut, onComplete:function(){
  503. _svg_loader_img.attr('src', '');
  504. overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
  505. _page_scroll.css('height', overviewSingleHeight);
  506. if(mobile==false){
  507. TweenLite.to($('.js-content'), 1, {css:{opacity:1}, delay: 0.8, ease:Expo.easeOut});
  508. TweenLite.to($('.artist-name'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
  509. TweenLite.to($('.artist-name span'), 1, {css:{y:'0%', opacity:1}, delay: 0.4, ease:Expo.easeOut});
  510. TweenLite.to($('.artist-close'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
  511. }
  512. }});
  513. cancelAnimationFrame(globalID);
  514. globalSingle = requestAnimationFrame(runa);
  515. $('.artist-close').bind('click',function(){
  516. single_close();
  517. });
  518. $(document).keyup(function(e) {
  519. if(e.keyCode == 27 && document.body.classList.contains('single')){
  520. single_close();
  521. }
  522. });
  523. });
  524. });
  525. }});
  526. _tl_open.to($('.page--home'), 1, {css:{opacity:0}, ease:Expo.easeOut, force3D:true});
  527. };
  528. gifLoader.src = "/wp-content/themes/sa/images/loading.gif";
  529. }
  530. function single_close(){
  531. var _title = "Home";
  532. var _url = "/";
  533. change_my_url(null, _title, _url);
  534. window.scrollTo(0, yOrigin);
  535. _body.removeClass('single');
  536. TweenLite.set($('.page--home'), {css:{opacity: 0}});
  537. // change rAF
  538. cancelAnimationFrame(globalSingle);
  539. globalID = requestAnimationFrame(run);
  540. // timeline
  541. var _tl_close = new TimelineLite({onComplete:function(){
  542. _page_single.removeClass('ready');
  543. //single
  544. _page_single.html("");
  545. TweenLite.to($('.page--home'), 0.6, {css:{opacity:1}, ease:Expo.easeOut, force3D:true, onComplete:function(){
  546. overviewHeight = overview.getBoundingClientRect().height;
  547. _page_scroll.css('height', overviewHeight);
  548. if(mobile==false){
  549. TweenLite.set($('.js-content'), {css:{opacity:0}});
  550. TweenLite.set($('.artist-name'), {css:{x:'-300%'}});
  551. TweenLite.set($('.artist-name span'), {css:{y:'-100%', opacity:0}});
  552. TweenLite.set($('.artist-close'), {css:{x:'300%'}});
  553. }
  554. }});
  555. }});
  556. _tl_close.to($('.single--artist'), 1, {css:{opacity:0}, ease:Expo.easeOut, force3D:true});
  557. };
  558. $('.bands-slide').bind('click', function(){
  559. var _title = $(this).attr('data-title');
  560. var _url = $(this).attr('data-link');
  561. load_single(_title,_url);
  562. });
  563. _logo.bind('click',function(){
  564. var _titlel = $(this).attr('data-title');
  565. var _urll = $(this).attr('data-link');
  566. load_single(_titlel,_urll);
  567. });
  568. // matrix3d
  569. var deg2rad, rotateX, rotateY, rotateZ, scale;
  570. deg2rad = 0;
  571. rotateX = 0;
  572. rotateY = 0;
  573. rotateZ = 0;
  574. scale = 1;
  575. var rotationXMatrix, rotationYMatrix, rotationZMatrix, s, scaleMatrix, transformationMatrix, translationMatrix;
  576. rotationXMatrix = $M([[1, 0, 0, 0], [0, Math.cos(rotateX * deg2rad), Math.sin(-rotateX * deg2rad), 0], [0, Math.sin(rotateX * deg2rad), Math.cos(rotateX * deg2rad), 0], [0, 0, 0, 1]]);
  577. rotationYMatrix = $M([[Math.cos(rotateY * deg2rad), 0, Math.sin(rotateY * deg2rad), 0], [0, 1, 0, 0], [Math.sin(-rotateY * deg2rad), 0, Math.cos(rotateY * deg2rad), 0], [0, 0, 0, 1]]);
  578. rotationZMatrix = $M([[Math.cos(rotateZ * deg2rad), Math.sin(-rotateZ * deg2rad), 0, 0], [Math.sin(rotateZ * deg2rad), Math.cos(rotateZ * deg2rad), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]);
  579. s = scale;
  580. scaleMatrix = $M([[s, 0, 0, 0], [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, 1]]);
  581. // if we want to cancel / run rAF
  582. var globalID;
  583. var globalSingle;
  584. var sf;
  585. var ease = 0.1;
  586. function runa() {
  587. globalSingle = requestAnimationFrame(runa);
  588. // scrolltop & window.height
  589. if(mobile==false){
  590. y = window.pageYOffset;
  591. }
  592. h = window.innerHeight;
  593. sf = document.getElementById('js-single-footer').getBoundingClientRect().top;
  594. overviewHeight = overviewSingle.getBoundingClientRect().height;
  595. if(mobile==false){
  596. calcn += (y - calcn) * ease;
  597. }
  598. // footer / menu
  599. if(sf<30){
  600. _menu.addClass('js-light');
  601. _page_scroll.addClass('js-fixed');
  602. }
  603. else if(sf>30){
  604. _menu.removeClass('js-light');
  605. _page_scroll.removeClass('js-fixed');
  606. }
  607. if(sf<(h-30)){
  608. _ff.addClass('js-light');
  609. }
  610. else if(sf>(h-30)){
  611. _ff.removeClass('js-light');
  612. }
  613. if(mobile==false){
  614. // matrix3d transform
  615. translationMatrix = $M([
  616. [1,0,0,0],
  617. [0,1,0,0],
  618. [0,0,1,0],
  619. [0,-calcn,0,1]
  620. ]);
  621. transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
  622. s = "matrix3d(";
  623. s += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
  624. s += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
  625. s += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
  626. s += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
  627. s += ")";
  628. overviewSingle.style["transform"] = s;
  629. overviewSingle.style["webkitTransform"] = s;
  630. overviewSingle.style["mozTransform"] = s;
  631. overviewSingle.style["msTransform"] = s;
  632. }
  633. }
  634. var node;
  635. var d;
  636. var r;
  637. var v;
  638. var t;
  639. var s;
  640. var f;
  641. //console.log('mobile = ' + mobile);
  642. //console.log('ease = ' + ease);
  643. var _js_footer = document.getElementById('js-footer');
  644. function run() {
  645. globalID = requestAnimationFrame(run); //globalID =
  646. // scrolltop & window.height
  647. if(mobile==false){
  648. y = window.pageYOffset;
  649. }
  650. h = window.innerHeight;
  651. f = _js_footer.getBoundingClientRect().top;
  652. // home overview & viewport height
  653. overviewHeight = overview.getBoundingClientRect().height;
  654. viewportHeight = viewport.getBoundingClientRect().height;
  655. if(mobile==false){
  656. calc += (y - calc) * ease;
  657. var t = 'translate3d(0, ' + - calc + 'px, 0)';
  658. var s = overview.style;
  659. s["transform"] = t;
  660. s["webkitTransform"] = t;
  661. s["mozTransform"] = t;
  662. s["msTransform"] = t;
  663. }
  664. // footer / menu
  665. if(f<30){
  666. $('#js-burger').addClass('js-light');
  667. _menu.addClass('js-light');
  668. _page_scroll.addClass('js-fixed');
  669. }
  670. else if(f>30){
  671. $('#js-burger').removeClass('js-light');
  672. _menu.removeClass('js-light');
  673. _page_scroll.removeClass('js-fixed');
  674. }
  675. if(f<(h-30)){
  676. _ff.addClass('js-light');
  677. }
  678. else if(f>(h-30)){
  679. _ff.removeClass('js-light');
  680. }
  681. if(mobile==false){
  682. // intro opacity
  683. o = h / 1.5;
  684. opacity = (1 - y / o);
  685. opacity = Math.max(0, Math.min(opacity, 1));
  686. intro.style["opacity"] = opacity;
  687. // parallax images
  688. for(var i = 0; i < nodes.length; i++) {
  689. node = nodes[i];
  690. d = node.direction;
  691. r = node.rotate;
  692. v = -200;
  693. v += (y - v) * ease;
  694. smoothY += (v - smoothY) * ease;
  695. translationMatrix = $M([
  696. [1,0,0,0],
  697. [0,1,0,0],
  698. [0,0,1,0],
  699. [0,d + smoothY,0,1]
  700. ]);
  701. transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
  702. t = "matrix3d(";
  703. t += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
  704. t += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
  705. t += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
  706. t += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
  707. t += ")";
  708. s = node.el.style;
  709. s["transform"] = t;
  710. s["webkitTransform"] = t;
  711. s["mozTransform"] = t;
  712. s["msTransform"] = t;
  713. }
  714. }
  715. };
  716. },
  717. onresize : function(){
  718. var home_intro = $('.page--intro');
  719. var page_scroll = $('#page--scroll');
  720. var band_img = $('.band--img');
  721. var bands_slider = $('.bands-slider');
  722. var viewport= document.getElementById("scroll-viewport");
  723. var viewportHeight = viewport.getBoundingClientRect().height;
  724. home_intro.css('height', viewportHeight);
  725. if(document.body.classList.contains('single')){
  726. var overview = document.getElementById("page--single");
  727. }
  728. else{
  729. var overview = document.getElementById("scroll-overview");
  730. }
  731. var overviewHeight = overview.getBoundingClientRect().height;
  732. page_scroll.css('height', overviewHeight);
  733. bands_slider.css('height', band_img.height());
  734. }
  735. },
  736. single : {
  737. onready : function(){
  738. },
  739. onload : function(){
  740. var _body = $('body');
  741. var _loader = $('.page--loader');
  742. var _single = $('.page--single');
  743. var _page_scroll = $('#page--scroll');
  744. var _menu = $('.menu');
  745. var _ff = $('#fixed-footer');
  746. var set;
  747. var set2;
  748. _body.addClass('loaded-on');
  749. var destY = 0;
  750. var y = window.pageYOffset;
  751. var h = window.innerHeight;
  752. var overviewSingle = document.getElementById("page--single");
  753. var overviewSingleHeight;
  754. var viewport = document.getElementById("scroll-viewport");
  755. var viewportHeight;
  756. var calcn = 0;
  757. // matrix3d
  758. var deg2rad, rotateX, rotateY, rotateZ, scale;
  759. deg2rad = 0;
  760. rotateX = 0;
  761. rotateY = 0;
  762. rotateZ = 0;
  763. scale = 1;
  764. var rotationXMatrix, rotationYMatrix, rotationZMatrix, s, scaleMatrix, transformationMatrix, translationMatrix;
  765. rotationXMatrix = $M([[1, 0, 0, 0], [0, Math.cos(rotateX * deg2rad), Math.sin(-rotateX * deg2rad), 0], [0, Math.sin(rotateX * deg2rad), Math.cos(rotateX * deg2rad), 0], [0, 0, 0, 1]]);
  766. rotationYMatrix = $M([[Math.cos(rotateY * deg2rad), 0, Math.sin(rotateY * deg2rad), 0], [0, 1, 0, 0], [Math.sin(-rotateY * deg2rad), 0, Math.cos(rotateY * deg2rad), 0], [0, 0, 0, 1]]);
  767. rotationZMatrix = $M([[Math.cos(rotateZ * deg2rad), Math.sin(-rotateZ * deg2rad), 0, 0], [Math.sin(rotateZ * deg2rad), Math.cos(rotateZ * deg2rad), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]);
  768. s = scale;
  769. scaleMatrix = $M([[s, 0, 0, 0], [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, 1]]);
  770. // if we want to cancel / run rAF
  771. var globalID;
  772. var globalSingle;
  773. var mobile;
  774. if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
  775. mobile = false;
  776. } else{ mobile = true; }
  777. var ease;
  778. if(mobile==true){
  779. ease = 1;
  780. }
  781. else{
  782. ease = 0.1;
  783. }
  784. function runa() {
  785. globalSingle = requestAnimationFrame(runa);
  786. // scrolltop & window.height
  787. if(mobile==false){
  788. y = window.pageYOffset
  789. }
  790. h = window.innerHeight;
  791. sf = document.getElementById('js-single-footer').getBoundingClientRect().top;
  792. if(mobile==false){
  793. // easing
  794. calcn += (y - calcn) * ease;
  795. // matrix3d transform
  796. translationMatrix = $M([
  797. [1,0,0,0],
  798. [0,1,0,0],
  799. [0,0,1,0],
  800. [0,-calcn,0,1]
  801. ]);
  802. transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
  803. s = "matrix3d(";
  804. s += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
  805. s += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
  806. s += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
  807. s += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
  808. s += ")";
  809. overviewSingle.style["transform"] = s;
  810. overviewSingle.style["webkitTransform"] = s;
  811. overviewSingle.style["mozTransform"] = s;
  812. overviewSingle.style["msTransform"] = s;
  813. }
  814. // footer / menu
  815. if(sf<30){
  816. _menu.addClass('js-light');
  817. _page_scroll.addClass('js-fixed');
  818. }
  819. else if(sf>30){
  820. _menu.removeClass('js-light');
  821. _page_scroll.removeClass('js-fixed');
  822. }
  823. if(sf<(h-30)){
  824. _ff.addClass('js-light');
  825. }
  826. else if(sf>(h-30)){
  827. _ff.removeClass('js-light');
  828. }
  829. }
  830. new imagesLoaded(document.body, function(instance) {
  831. TweenLite.set($('.single--artist'), {css:{scale:1.2, opacity: 0}});
  832. set = window.setTimeout(function(){
  833. _body.addClass('loaded');
  834. set2 = window.setTimeout(function(){
  835. _loader.removeClass('on');
  836. _body.addClass('single');
  837. _single.addClass('ready');
  838. TweenLite.to($('.single--artist'), 1, {css:{scale:1, opacity:1}, ease:Expo.easeOut, onComplete:function(){
  839. overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
  840. _page_scroll.css('height', overviewSingleHeight);
  841. globalSingle = requestAnimationFrame(runa);
  842. if(mobile==false){
  843. TweenLite.to($('.js-content'), 1, {css:{opacity:1}, delay: 0.8, ease:Expo.easeOut});
  844. TweenLite.to($('.artist-name'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
  845. TweenLite.to($('.artist-name span'), 1, {css:{y:'0%', opacity:1}, delay: 0.6, ease:Expo.easeOut});
  846. TweenLite.to($('.artist-close'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
  847. }
  848. }});
  849. $('.artist-close').bind('click',function(){
  850. window.location="/";
  851. });
  852. $(document).keyup(function(e) {
  853. if(e.keyCode == 27 && document.body.classList.contains('single')){
  854. window.location="/";
  855. }
  856. });
  857. window.clearTimeout(set);
  858. window.clearTimeout(set2);
  859. },200);
  860. },1300);
  861. });
  862. },
  863. onresize : function(){
  864. var page_scroll = $('#page--scroll');
  865. var overviewSingle = document.getElementById("page--single");
  866. var overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
  867. page_scroll.css('height', overviewSingleHeight);
  868. }
  869. },
  870. error : {
  871. onready : function(){
  872. },
  873. onload : function(){
  874. },
  875. onresize : function(){
  876. }
  877. }
  878. };
  879. var targetY = 0;
  880. window.addEventListener('load', function() {
  881. FastClick.attach(document.body);
  882. }, false);
  883. $(document).ready(function(){
  884. app[document.body.id].onready();
  885. app['common'].onready();
  886. });
  887. $(window).load(function(){
  888. app[document.body.id].onload();
  889. });
  890. $(window).resize(function(){
  891. app[document.body.id].onresize();
  892. });
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注