@Mercedes-Benz
2016-07-27T10:22:15.000000Z
字数 26281
阅读 572
用于Evernote里的笔记
var _state = null;
function change_my_url(_state, _title, _url){
History.pushState(_state, _title, _url);
}
History.Adapter.bind(window,'statechange',function(){
var _state = History.getState();
document.title = _state['title'] + ' | Velvet Hammer';
});
(function() {
var lastTime = 0;
var vendors = ['webkit', 'moz'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}());
var app = {
common : {
onready : function(){
var _body = $('body');
var dset;
dset = window.setTimeout(function(){
_body.addClass('ready');
window.clearTimeout(dset);
},400);
/* ----------
Composant :
_ Menu
---------- */
var _menu = $('.menu');
var menu = "";
var $this = "";
_menu.bind('click',function(){
$this = $(this);
menu = $this.attr('data-menu');
_body.toggleClass(menu+'-on');
if(!$('.page--'+menu).hasClass('on')){
$('.page--'+menu).addClass('on');
TweenLite.to($('.page--'+menu), 0.7, {css:{scale:1, opacity:1}, ease:Expo.easeOut});
TweenLite.to($('.page--'+menu+' ul li'), 0.4, {css:{y:'0%', opacity:1}, ease:Expo.easeOut});
}
else{
TweenLite.to($('.page--'+menu+' ul'), 0.4, {css:{opacity:0}, ease:Expo.easeOut, onComplete:function(){
TweenLite.to($('.page--'+menu), 0.7, {css:{scale:1.2, opacity:0}, ease:Expo.easeOut, onComplete:function(){
$('.page--'+menu).removeClass('on');
TweenLite.set($('.page--'+menu+' ul'), {css:{opacity:1}});
TweenLite.set($('.page--'+menu+' ul li'), {css:{y:'100%', opacity:0}});
}});
}});
}
});
jQuery.extend( jQuery.easing,
{
easeInOutQuad: function (x, t, b, c, d) {
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
}
});
function SVG(tag) {
return document.createElementNS('http://www.w3.org/2000/svg', tag);
}
function replaceCirclesWithPaths(parentElement) {
var circles = $(parentElement).find('circle');
$.each(circles, function() {
var cX = $(this).attr('cx');
var cY = $(this).attr('cy');
var r = $(this).attr('r');
var r2 = parseFloat(r * 2);
var convertedPath = 'M' + cX + ', ' + cY + ' m' + (-r) + ', 0 ' + 'a ' + r + ', ' + r + ' 0 1,0 ' + r2 + ',0 ' + 'a ' + r + ', ' + r + ' 0 1,0 ' + (-r2) + ',0 ';
$(SVG('path'))
.attr('d', convertedPath)
.attr('fill', $(this).attr('fill'))
.attr('stroke', $(this).attr('stroke'))
.attr('class', $(this).attr('class'))
.attr('stroke-width', $(this).attr('stroke-width'))
.insertAfter(this);
});
$(circles).remove();
}
function hideSVGPaths(parentElement) {
var paths = $(parentElement).find('path');
//for each PATH..
$.each( paths, function() {
//get the total length
var totalLength = this.getTotalLength();
//set PATHs to invisible
$(this).css({
'stroke-dashoffset': totalLength,
'stroke-dasharray': totalLength + ' ' + totalLength
});
});
}
function drawSVGPaths(_parentElement, _timeMin, _timeMax, _timeDelay) {
var paths = $(_parentElement).find('path');
//for each PATH..
$.each( paths, function(i) {
//get the total length
var totalLength = this.getTotalLength();
//set PATHs to invisible
$(this).css({
'stroke-dashoffset': totalLength,
'stroke-dasharray': totalLength + ' ' + totalLength
});
//animate
$(this).delay(_timeDelay*i).animate({
'stroke-dashoffset': 0
}, {
duration: Math.floor(Math.random() * _timeMax) + _timeMin
,easing: 'easeInOutQuad'
});
});
}
function replaceWithPaths(parentElement) {
replaceCirclesWithPaths(parentElement);
}
function startSVGAnimation(parentElement) {
drawSVGPaths(parentElement, 1000, 2000, 50);
}
replaceWithPaths($('#js-control'));
// startSVGAnimation($('#js-control'));
/* ----------
Composant :
_ SoundCloud
---------- */
SC.initialize({
client_id: '3a98eed17a0d81ea969770fef94e7f58',
redirect_uri: 'http://velvethammer.net/'
});
var playing=false;
// SC.get('/resolve', {
// url: 'https://soundcloud.com/velvethammer'
// }, function(user) {
// console.log(user);
// });
// users/velvethammer/tracks
SC.get("/users/4616395/playlists", {limit: 10}, function(playlist){
// console.log(playlist);
var selected = playlist[0];
$('#js-comment').html(selected.title);
var lenght = selected.tracks.length;
// console.log(playlist[0].tracks);
for(var key in selected.tracks.slice(0)){
//console.log(selected.tracks[key]);
//if(selected.tracks[key].permalink != null){
$('#js-soundcloud').append('<li><a id="' + selected.tracks[key].id + '" href="#">' + selected.tracks[key].title + '</a></li>');
//}
}
$('#js-playericon').click(function(){
event.preventDefault();
var $this = $(this);
if(playing==true){
$this.removeClass('playing');
playing=false;
}
else{
$('#js-soundcloud li:first-child a').trigger('click');
$this.addClass('playing');
playing=true;
}
});
$('#js-soundcloud li a').click(function(event) {
event.preventDefault();
var id = $(this).attr('id');
$('#js-soundcloud li').removeClass('current');
$(this).parent('li').addClass('current');
playing=true;
SC.stream("/tracks/"+ id , {autoPlay: false,ontimedcomments: function(comments){$('#js-comment').html(comments[0].body);}}, function(sound){
$('#stop').trigger('click');
sound.play({
whileplaying: function() {
$('#js-playericon').addClass('playing');
var path = document.querySelector('.circle');
var position = this.position;
var duration = this.duration;
var percent = position / duration;
var current = Math.floor(percent * 185);
path.setAttribute('stroke-dashoffset', current);
},
onfinish: function() {
$('#js-playericon').removeClass('playing');
playing=false;
var path = document.querySelector('.circle');
path.setAttribute('stroke-dashoffset', 0);
}
});
$('#js-playericon').click(function(){
//console.log(playing);
var $this = $(this);
if(playing==true){
$this.removeClass('playing');
playing=false;
}
else{
$this.addClass('playing');
playing=true;
}
sound.togglePause();
});
$('#stop').click(function(){
sound.stop();
$('#js-playericon').removeClass('playing');
$('#js-comment').html('');
playing=false;
});
});
});
});
}
},
page : {
onready : function(){
},
onload : function(){
var _body = $('body');
var _loader = $('.page--loader');
var _single = $('.page--single');
var _page_scroll = $('#page--scroll');
var _menu = $('.menu');
var _ff = $('#fixed-footer');
var set;
var set2;
var set3;
_body.addClass('loaded-on');
var destY = 0;
var y = window.pageYOffset;
var h = window.innerHeight;
var overviewSingle = document.getElementById("page--single");
var overviewSingleHeight;
var viewport = document.getElementById("scroll-viewport");
var viewportHeight;
var calcn = 0;
var mobile;
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
mobile = false;
} else{ mobile = true; }
// matrix3d
var deg2rad, rotateX, rotateY, rotateZ, scale;
deg2rad = 0;
rotateX = 0;
rotateY = 0;
rotateZ = 0;
scale = 1;
var rotationXMatrix, rotationYMatrix, rotationZMatrix, s, scaleMatrix, transformationMatrix, translationMatrix;
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]]);
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]]);
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]]);
s = scale;
scaleMatrix = $M([[s, 0, 0, 0], [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, 1]]);
// if we want to cancel / run rAF
var globalID;
var globalSingle;
function runa() {
globalSingle = requestAnimationFrame(runa);
// scrolltop & window.height
if(mobile==false){
y = $(window).scrollTop();
}
h = window.innerHeight;
sf = document.getElementById('js-single-footer').getBoundingClientRect().top;
if(mobile==false){
calcn += (y - calcn) * 0.1;
}
// footer / menu
if(sf<30){
_menu.addClass('js-light');
_page_scroll.addClass('js-fixed');
}
else if(sf>30){
_menu.removeClass('js-light');
_page_scroll.removeClass('js-fixed');
}
if(sf<(h-30)){
_ff.addClass('js-light');
}
else if(sf>(h-30)){
_ff.removeClass('js-light');
}
if(mobile==false){
// matrix3d transform
translationMatrix = $M([
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,-calcn,0,1]
]);
transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
s = "matrix3d(";
s += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
s += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
s += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
s += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
s += ")";
overviewSingle.style["transform"] = s;
overviewSingle.style["webkitTransform"] = s;
overviewSingle.style["mozTransform"] = s;
overviewSingle.style["msTransform"] = s;
}
}
new imagesLoaded(document.body, function(instance) {
TweenLite.set($('.single--artist'), {css:{scale:1.2, opacity: 0}});
set = window.setTimeout(function(){
_body.addClass('loaded');
set2 = window.setTimeout(function(){
_loader.removeClass('on');
_body.addClass('single');
_single.addClass('ready');
TweenLite.to($('.single--artist'), 1, {css:{scale:1, opacity:1}, ease:Expo.easeOut, onComplete:function(){
overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
_page_scroll.css('height', overviewSingleHeight);
globalSingle = requestAnimationFrame(runa);
if(mobile==false){
TweenLite.to($('.js-content'), 1, {css:{opacity:1}, ease:Expo.easeOut});
TweenLite.to($('.single-close'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
}
}});
$('.single-close').bind('click',function(){
window.location="/";
});
$(document).keyup(function(e) {
if(e.keyCode == 27 && document.body.classList.contains('single')){
window.location="/";
}
});
window.clearTimeout(set);
window.clearTimeout(set2);
},200);
},1300);
});
set3 = window.setTimeout(function(){
$('.bit-event-data').attr('style','');
window.clearTimeout(set3);
},300);
},
onresize : function(){
}
},
home : {
onready : function(){
var _body = $('body');
var _single = $('.page--single');
/* ----------
Composant :
_ Spanify Letters.
---------- */
var _band_t = document.getElementsByClassName("band--name");
var text = "";
var letter = "";
var letters = text.split('');
var spanified = [];
for(var n=0;n<_band_t.length;n++){
text = _band_t[n].innerHTML;
letters = text.split('');
spanified = [];
for(var i = 0; i < letters.length; i++) {
if(letters[i] === ' ') letters[i] = ' ';
letters[i] = '<span class="letter-mask"><span class="letter-inner">' + letters[i] + '</span></span>';
spanified.push(letters[i]);
}
_band_t[n].innerHTML = spanified.join('');
}
/* ----------
Composant :
_ Slider
---------- */
var c = 1;
var l = $('.bands-slide').length;
$('#item-1').addClass('slide-active');
TweenLite.to($('#item-1'), 0.8, {css:{scale:1, opacity:1}, ease:Power3.easeOut});
$('.slider-control.prev').bind('click', function(){
if(c!=1){
c--;
}
else {
c=l;
}
$('.bands-slide').removeClass('slide-active');
$('#item-'+c).addClass('slide-active');
TweenLite.to($('#item-'+c), 1.1, {css:{scale:1, opacity:1}, ease:Power3.easeOut, onComplete:function(){
TweenLite.set($('.bands-slide:not(#item-'+ c +')'), {css:{scale:1.2, opacity: 0}});
}});
});
$('.slider-control.next').bind('click', function(){
if(c!=l){
c++;
}
else{
c=1;
}
$('.bands-slide').removeClass('slide-active');
$('#item-'+c).addClass('slide-active');
TweenLite.to($('#item-'+c), 1.1, {css:{scale:1, opacity:1}, ease:Power3.easeOut, onComplete:function(){
TweenLite.set($('.bands-slide:not(#item-'+ c +')'), {css:{scale:1.1, opacity: 0}});
}});
});
},
onload : function(){
var _loader = $('.page--loader');
var _intro = $('.page--intro');
var _body = $('body');
var _svg_loader = $('#svg-loader');
var _svg_loader_img = $('#svg-loader-img');
var _logo = $('.js-band--logo');
var _page_single = $('#page--single');
var _bands_slider = $('.bands-slider');
var _page_scroll = $('#page--scroll');
var _menu = $('.menu');
var yOrigin = 0;
var destY = 0;
var smoothY = 0;
var intro = document.getElementById("intro-content");
var home_intro = $('.page--intro');
var _ff = $('#fixed-footer');
var y = $(window).scrollTop();
var h = window.innerHeight;
var viewport= document.getElementById("scroll-viewport");
var overview = document.getElementById("scroll-overview");
var overviewSingle = document.getElementById("page--single");
var viewportHeight = viewport.getBoundingClientRect().height;
// reset home intro so we get real height
home_intro.css('height', viewportHeight);
var overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
var overviewHeight = overview.getBoundingClientRect().height;
var calc = 0;
var calcn = 0;
var translationMatrix = "";
var o = "";
var set;
var set1;
var mobile;
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
mobile = false;
} else{ mobile = true; }
_body.addClass('loaded-on');
var bindto = document.querySelectorAll('.js-scrollto');
var _bindto = Array.prototype.slice.call(bindto, 0);
_bindto.forEach(function(_bind) {
_bind.addEventListener('click', function(){
var section = this.getAttribute('data-scroll');
var to = $('#js-scrollto-'+section).offset().top;
window.scrollTo(0, to);
});
});
new imagesLoaded(overview, function(instance) {
var overviewHeight = overview.getBoundingClientRect().height;
_page_scroll.css('height', overviewHeight);
set = window.setTimeout(function(){
_body.addClass('loaded');
_intro.removeClass('onload');
set1 = window.setTimeout(function(){
_loader.removeClass('on');
run();
window.clearTimeout(set);
window.clearTimeout(set1);
},200);
},1300);
});
// reset
_bands_slider.css('height', $('.band--img').height());
var nodes = [];
[].forEach.call(document.querySelectorAll('.js-el'), function(el,i) {
nodes[i] = {
el: el,
direction: el.getAttribute('data-direction'),
};
});
var loadert;
function load_single(_title,_url){
_body.addClass('single');
_page_single.addClass('ready');
yOrigin = $(window).scrollTop();
window.scrollTo(0, 0);
var gifLoader = new Image();
gifLoader.onload = function() {
_svg_loader_img.attr('src', gifLoader.src);
// timeline
var _tl_open = new TimelineLite({onComplete:function(){
_svg_loader.addClass('show');
_page_single.load(_url,{_title: _title},function(){
change_my_url(null, _title, _url);
if(mobile==false){
TweenLite.set($('.single--artist'), {css:{scale:1.2, opacity: 0}});
TweenLite.set($('.artist-name'), {css:{x:'-300%'}});
TweenLite.set($('.artist-close'), {css:{x:'300%'}});
}
// change rAF
new imagesLoaded(_page_single, function(instance) {
_svg_loader.removeClass('show');
TweenLite.to($('.single--artist'), 1, {css:{scale:1, opacity:1}, ease:Expo.easeOut, onComplete:function(){
_svg_loader_img.attr('src', '');
overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
_page_scroll.css('height', overviewSingleHeight);
if(mobile==false){
TweenLite.to($('.js-content'), 1, {css:{opacity:1}, delay: 0.8, ease:Expo.easeOut});
TweenLite.to($('.artist-name'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
TweenLite.to($('.artist-name span'), 1, {css:{y:'0%', opacity:1}, delay: 0.4, ease:Expo.easeOut});
TweenLite.to($('.artist-close'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
}
}});
cancelAnimationFrame(globalID);
globalSingle = requestAnimationFrame(runa);
$('.artist-close').bind('click',function(){
single_close();
});
$(document).keyup(function(e) {
if(e.keyCode == 27 && document.body.classList.contains('single')){
single_close();
}
});
});
});
}});
_tl_open.to($('.page--home'), 1, {css:{opacity:0}, ease:Expo.easeOut, force3D:true});
};
gifLoader.src = "/wp-content/themes/sa/images/loading.gif";
}
function single_close(){
var _title = "Home";
var _url = "/";
change_my_url(null, _title, _url);
window.scrollTo(0, yOrigin);
_body.removeClass('single');
TweenLite.set($('.page--home'), {css:{opacity: 0}});
// change rAF
cancelAnimationFrame(globalSingle);
globalID = requestAnimationFrame(run);
// timeline
var _tl_close = new TimelineLite({onComplete:function(){
_page_single.removeClass('ready');
//single
_page_single.html("");
TweenLite.to($('.page--home'), 0.6, {css:{opacity:1}, ease:Expo.easeOut, force3D:true, onComplete:function(){
overviewHeight = overview.getBoundingClientRect().height;
_page_scroll.css('height', overviewHeight);
if(mobile==false){
TweenLite.set($('.js-content'), {css:{opacity:0}});
TweenLite.set($('.artist-name'), {css:{x:'-300%'}});
TweenLite.set($('.artist-name span'), {css:{y:'-100%', opacity:0}});
TweenLite.set($('.artist-close'), {css:{x:'300%'}});
}
}});
}});
_tl_close.to($('.single--artist'), 1, {css:{opacity:0}, ease:Expo.easeOut, force3D:true});
};
$('.bands-slide').bind('click', function(){
var _title = $(this).attr('data-title');
var _url = $(this).attr('data-link');
load_single(_title,_url);
});
_logo.bind('click',function(){
var _titlel = $(this).attr('data-title');
var _urll = $(this).attr('data-link');
load_single(_titlel,_urll);
});
// matrix3d
var deg2rad, rotateX, rotateY, rotateZ, scale;
deg2rad = 0;
rotateX = 0;
rotateY = 0;
rotateZ = 0;
scale = 1;
var rotationXMatrix, rotationYMatrix, rotationZMatrix, s, scaleMatrix, transformationMatrix, translationMatrix;
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]]);
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]]);
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]]);
s = scale;
scaleMatrix = $M([[s, 0, 0, 0], [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, 1]]);
// if we want to cancel / run rAF
var globalID;
var globalSingle;
var sf;
var ease = 0.1;
function runa() {
globalSingle = requestAnimationFrame(runa);
// scrolltop & window.height
if(mobile==false){
y = window.pageYOffset;
}
h = window.innerHeight;
sf = document.getElementById('js-single-footer').getBoundingClientRect().top;
overviewHeight = overviewSingle.getBoundingClientRect().height;
if(mobile==false){
calcn += (y - calcn) * ease;
}
// footer / menu
if(sf<30){
_menu.addClass('js-light');
_page_scroll.addClass('js-fixed');
}
else if(sf>30){
_menu.removeClass('js-light');
_page_scroll.removeClass('js-fixed');
}
if(sf<(h-30)){
_ff.addClass('js-light');
}
else if(sf>(h-30)){
_ff.removeClass('js-light');
}
if(mobile==false){
// matrix3d transform
translationMatrix = $M([
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,-calcn,0,1]
]);
transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
s = "matrix3d(";
s += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
s += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
s += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
s += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
s += ")";
overviewSingle.style["transform"] = s;
overviewSingle.style["webkitTransform"] = s;
overviewSingle.style["mozTransform"] = s;
overviewSingle.style["msTransform"] = s;
}
}
var node;
var d;
var r;
var v;
var t;
var s;
var f;
//console.log('mobile = ' + mobile);
//console.log('ease = ' + ease);
var _js_footer = document.getElementById('js-footer');
function run() {
globalID = requestAnimationFrame(run); //globalID =
// scrolltop & window.height
if(mobile==false){
y = window.pageYOffset;
}
h = window.innerHeight;
f = _js_footer.getBoundingClientRect().top;
// home overview & viewport height
overviewHeight = overview.getBoundingClientRect().height;
viewportHeight = viewport.getBoundingClientRect().height;
if(mobile==false){
calc += (y - calc) * ease;
var t = 'translate3d(0, ' + - calc + 'px, 0)';
var s = overview.style;
s["transform"] = t;
s["webkitTransform"] = t;
s["mozTransform"] = t;
s["msTransform"] = t;
}
// footer / menu
if(f<30){
$('#js-burger').addClass('js-light');
_menu.addClass('js-light');
_page_scroll.addClass('js-fixed');
}
else if(f>30){
$('#js-burger').removeClass('js-light');
_menu.removeClass('js-light');
_page_scroll.removeClass('js-fixed');
}
if(f<(h-30)){
_ff.addClass('js-light');
}
else if(f>(h-30)){
_ff.removeClass('js-light');
}
if(mobile==false){
// intro opacity
o = h / 1.5;
opacity = (1 - y / o);
opacity = Math.max(0, Math.min(opacity, 1));
intro.style["opacity"] = opacity;
// parallax images
for(var i = 0; i < nodes.length; i++) {
node = nodes[i];
d = node.direction;
r = node.rotate;
v = -200;
v += (y - v) * ease;
smoothY += (v - smoothY) * ease;
translationMatrix = $M([
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,d + smoothY,0,1]
]);
transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
t = "matrix3d(";
t += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
t += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
t += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
t += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
t += ")";
s = node.el.style;
s["transform"] = t;
s["webkitTransform"] = t;
s["mozTransform"] = t;
s["msTransform"] = t;
}
}
};
},
onresize : function(){
var home_intro = $('.page--intro');
var page_scroll = $('#page--scroll');
var band_img = $('.band--img');
var bands_slider = $('.bands-slider');
var viewport= document.getElementById("scroll-viewport");
var viewportHeight = viewport.getBoundingClientRect().height;
home_intro.css('height', viewportHeight);
if(document.body.classList.contains('single')){
var overview = document.getElementById("page--single");
}
else{
var overview = document.getElementById("scroll-overview");
}
var overviewHeight = overview.getBoundingClientRect().height;
page_scroll.css('height', overviewHeight);
bands_slider.css('height', band_img.height());
}
},
single : {
onready : function(){
},
onload : function(){
var _body = $('body');
var _loader = $('.page--loader');
var _single = $('.page--single');
var _page_scroll = $('#page--scroll');
var _menu = $('.menu');
var _ff = $('#fixed-footer');
var set;
var set2;
_body.addClass('loaded-on');
var destY = 0;
var y = window.pageYOffset;
var h = window.innerHeight;
var overviewSingle = document.getElementById("page--single");
var overviewSingleHeight;
var viewport = document.getElementById("scroll-viewport");
var viewportHeight;
var calcn = 0;
// matrix3d
var deg2rad, rotateX, rotateY, rotateZ, scale;
deg2rad = 0;
rotateX = 0;
rotateY = 0;
rotateZ = 0;
scale = 1;
var rotationXMatrix, rotationYMatrix, rotationZMatrix, s, scaleMatrix, transformationMatrix, translationMatrix;
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]]);
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]]);
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]]);
s = scale;
scaleMatrix = $M([[s, 0, 0, 0], [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, 1]]);
// if we want to cancel / run rAF
var globalID;
var globalSingle;
var mobile;
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
mobile = false;
} else{ mobile = true; }
var ease;
if(mobile==true){
ease = 1;
}
else{
ease = 0.1;
}
function runa() {
globalSingle = requestAnimationFrame(runa);
// scrolltop & window.height
if(mobile==false){
y = window.pageYOffset
}
h = window.innerHeight;
sf = document.getElementById('js-single-footer').getBoundingClientRect().top;
if(mobile==false){
// easing
calcn += (y - calcn) * ease;
// matrix3d transform
translationMatrix = $M([
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,-calcn,0,1]
]);
transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix).x(scaleMatrix).x(translationMatrix);
s = "matrix3d(";
s += transformationMatrix.e(1, 1).toFixed(10) + "," + transformationMatrix.e(1, 2).toFixed(10) + "," + transformationMatrix.e(1, 3) + "," + transformationMatrix.e(1, 4).toFixed(10) + ",";
s += transformationMatrix.e(2, 1).toFixed(10) + "," + transformationMatrix.e(2, 2).toFixed(10) + "," + transformationMatrix.e(2, 3) + "," + transformationMatrix.e(2, 4).toFixed(10) + ",";
s += transformationMatrix.e(3, 1).toFixed(10) + "," + transformationMatrix.e(3, 2).toFixed(10) + "," + transformationMatrix.e(3, 3) + "," + transformationMatrix.e(3, 4).toFixed(10) + ",";
s += transformationMatrix.e(4, 1).toFixed(10) + "," + transformationMatrix.e(4, 2).toFixed(10) + "," + transformationMatrix.e(4, 3) + "," + transformationMatrix.e(4, 4).toFixed(10);
s += ")";
overviewSingle.style["transform"] = s;
overviewSingle.style["webkitTransform"] = s;
overviewSingle.style["mozTransform"] = s;
overviewSingle.style["msTransform"] = s;
}
// footer / menu
if(sf<30){
_menu.addClass('js-light');
_page_scroll.addClass('js-fixed');
}
else if(sf>30){
_menu.removeClass('js-light');
_page_scroll.removeClass('js-fixed');
}
if(sf<(h-30)){
_ff.addClass('js-light');
}
else if(sf>(h-30)){
_ff.removeClass('js-light');
}
}
new imagesLoaded(document.body, function(instance) {
TweenLite.set($('.single--artist'), {css:{scale:1.2, opacity: 0}});
set = window.setTimeout(function(){
_body.addClass('loaded');
set2 = window.setTimeout(function(){
_loader.removeClass('on');
_body.addClass('single');
_single.addClass('ready');
TweenLite.to($('.single--artist'), 1, {css:{scale:1, opacity:1}, ease:Expo.easeOut, onComplete:function(){
overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
_page_scroll.css('height', overviewSingleHeight);
globalSingle = requestAnimationFrame(runa);
if(mobile==false){
TweenLite.to($('.js-content'), 1, {css:{opacity:1}, delay: 0.8, ease:Expo.easeOut});
TweenLite.to($('.artist-name'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
TweenLite.to($('.artist-name span'), 1, {css:{y:'0%', opacity:1}, delay: 0.6, ease:Expo.easeOut});
TweenLite.to($('.artist-close'), 1, {css:{x:'0%'}, ease:Expo.easeOut});
}
}});
$('.artist-close').bind('click',function(){
window.location="/";
});
$(document).keyup(function(e) {
if(e.keyCode == 27 && document.body.classList.contains('single')){
window.location="/";
}
});
window.clearTimeout(set);
window.clearTimeout(set2);
},200);
},1300);
});
},
onresize : function(){
var page_scroll = $('#page--scroll');
var overviewSingle = document.getElementById("page--single");
var overviewSingleHeight = overviewSingle.getBoundingClientRect().height;
page_scroll.css('height', overviewSingleHeight);
}
},
error : {
onready : function(){
},
onload : function(){
},
onresize : function(){
}
}
};
var targetY = 0;
window.addEventListener('load', function() {
FastClick.attach(document.body);
}, false);
$(document).ready(function(){
app[document.body.id].onready();
app['common'].onready();
});
$(window).load(function(){
app[document.body.id].onload();
});
$(window).resize(function(){
app[document.body.id].onresize();
});