Skip to content

Instantly share code, notes, and snippets.

@avishai84
Last active September 4, 2018 20:14
Show Gist options
  • Select an option

  • Save avishai84/d582a1f095279f43fc9ec3dd9cb3d84b to your computer and use it in GitHub Desktop.

Select an option

Save avishai84/d582a1f095279f43fc9ec3dd9cb3d84b to your computer and use it in GitHub Desktop.
facet-2018
function theNewFacetFn(cid){
this.cid=cid;
let pageIdHash = '#pageId=0';
let origPageLocHash = window.location.hash;
if(origPageLocHash.length > 0){
//check if hash already exist in URL
//To stay consistent, loop to find if style exist in array.
// remove it and put back the string at the end.
origPageLocHash = origPageLocHash.split('&');
var tempArr = [];
origPageLocHash.map(function(item){
if(item.indexOf('style=') > -1){
//don't style push to array
}else{
tempArr.push(item);
}
});
//join results of the new string
tempArr = tempArr.join('&');
origPageLocHash= '#style='+cid+'&'+tempArr;
}else{
origPageLocHash='#style='+cid+'&pageId=0';
}
location.hash =origPageLocHash;
var topPos = document.querySelector('.l--cat-page-photos').offsetTop;
jQuery("html, body").animate({
scrollTop : topPos - 150
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment