I have this webpage where when you click a isotope block it fills the page and then filters out all the other block. When i click the block again it should go back to its original location. My current problem is the page doesn't move with the block (you would have to scroll through all the posts again)
I decided that after I re layout the isotope blocks on the grid I will tell the page to go to the appropriate id (don't like this though because i have to assign id to every block)
Right now the code works in Chrome but does not work in safari. I think what is happening is the linking is happening before the relayout and thus remains at the top of the page.
Here is my JQuery:
$(document).ready(function(){
var $container = $('.news').isotope({
itemSelector: '.news-block',
layoutMode: 'masonry',
getSortData: {
type: '[data-type]', // value of attribute
time:'[content]'
}/*
sortBy:'type',
sortAscending: true*/
});
$container.on( 'click', '.news-block', function() {
$(this).toggleClass('expand');
if ($(this).hasClass('expand')) {
$container.isotope({ filter: '.expand' });
$container.isotope('layout');
} else {
$container.isotope({ filter: '*' });
$container.isotope('layout');
window.location.href = '#'+$(this).attr("id");
}
});
});
Css for blocks (shows expansion in width):
.news-block {
width:30.6666666666%;
margin:1%;
padding:2%;
float:left;
box-sizing: border-box;
word-wrap: break-word;
background-color: white;
color:#888;
}
.news-block.expand {
width:96%;
}
I hope there is an easy solution. Tried to use the wait till layout complete in isotope but wouldnt work. Also tried a delay and that didnt work either. Any suggestions. (I am new to JQuery, html, and css)