gola estoy armando esta página
http://verano.cabaniasvillage.com/
y lo que hace el menú de arriba es hacer un scrollto dependiendo de que menú se clique
tambien me modifica la url
y lo hago con este script
Código HTML:
NavigationManager = {
currentPageType : null,
navigationAllowed : true,
paths: false,
isSamePage: false,
samePage: ['ellugar', 'nuestrocomplejo', 'clubhouse', 'servicios', 'fotos', 'ubicacion', 'contacto', 'reservas'],
init: function() {
NavigationManager.addListeners();
},
addListeners: function() {
$('.state').on('click', function (event) {
var
$this = $(this),
url = $this.attr('href'),
// title = ($this.attr('title') || ''),
title = $this.attr('title');
data = null;
//title = (title != '')? title + ' | Cabañas Village' : 'Cabañas Village | NEUQUEN.';
//title = (title != '')? title ;
if($this.hasClass('nav-link')){
$('.nav-link.on').removeClass('on');
}
$this.addClass('on');
if(!NavigationManager.navigationAllowed) {
return false;
}
History.pushState(data, title, url);
event.preventDefault();
return false;
});
$(window).on('statechange', NavigationManager.handleStateChange);
},
handleStateChange: function(event) {
var
State = History.getState(),
url = State.url,
relativeUrl = url.replace(HistoryRootURL, '')
NavigationManager.navigationAllowed = false;
NavigationManager.handlePageChange('', relativeUrl);
console.log('la url es ' +relativeUrl);
},
analizePath: function($path){
//$path = ($path.substr(1)).toLowerCase();
$paths = $path.split( '/' );
return $paths;
},
handlePageChange: function(data, url) {
analizePath = true;
if(typeof url == 'undefined') {
url = window.location.href.replace(HistoryRootURL, '');
analizePath = false;
}
if(analizePath){
console.log('1');
NavigationManager.paths = NavigationManager.analizePath(url);
console.log('el NavigationManager.paths es ' + NavigationManager.paths);
NavigationManager.currentPageType = (NavigationManager.paths)[0].toLowerCase();
} else {
console.log('2');
NavigationManager.currentPageType = $state;
console.log(NavigationManager.currentPageType);
}
NavigationManager.trackGA();
//console.log(NavigationManager.currentPageType);
curPage = NavigationManager.currentPageType;
//console.log(NavigationManager.currentPageType);
$shut = false;
//switch(NavigationManager.currentPageType){
//default:
if($.inArray(NavigationManager.currentPageType, NavigationManager.samePage) >= 0){
NavigationManager.trackGA();
NavigationManager.isSamePage = NavigationManager.currentPageType;
$goTo = $('#'+NavigationManager.isSamePage);
if($goTo.length > 0){
$.scrollTo($goTo, 800, {easing:'swing'} );
}
//if(Project.initializated){
//Project.shut();
//}
NavigationManager.pageReady();
return false;
}
//break;
/*case 'projects':
$shut = Project.initializated == true ? false : false;
$loadProject = analizePath == false ? $projectActive : (NavigationManager.paths)[1];
if(Project.initializated){
Project.move($loadProject);
} else {
Project.set($loadProject);
}
break;
}*/
// if($shut){
// Project.shut();
// }
NavigationManager.pageReady();
return false;
},
trackGA: function(){
if(typeof _gaq != 'undefined') {
_gaq.push(['_trackPageview']);
}
},
pageReady: function() {
NavigationManager.navigationAllowed = true;
}
};
var History, HistoryRootURL;
$(function() {
History = window.History,
HistoryRootURL = History.getRootUrl();
//Layout.setLoader(1);
Layout.setup();
NavigationManager.init();
setTimeout(function() {
NavigationManager.handlePageChange($('body'));
}, 700);
});
pero no se como hacer que si por ejemplo la url tenga
http://verano.cabaniasvillage.com/Fotos me lea la url y y me haga el scroolto
no se como sacarlo... si alguien sabe me va a sacar de un problema que no se como solucionar
muchas gracias