aerohub / hugrid

Hugrid (Hugo+grid) is a simple grid theme for Hugo. It's a kind of boilerplate to perform anyone or anything quickly. Portfolio, collection, bookmarks, contacts and so on.
MIT License
165 stars 79 forks source link

Sorting thumbnails #12

Closed Gnorme closed 7 years ago

Gnorme commented 7 years ago

I'm trying to add the ability to sort the thumbnails. After sorting them I had to change their offset for the preview to show in the correct location. However when I close the preview now, the expanded tag and styling doesn't hide like it normally does. What else needs to be changed?

$("#sort").on("click",function(){
    $(".og-grid li").sort(sort_li) // sort elements
                      .appendTo('.og-grid'); // append again to the list                  
    //reset where preview shows from
    $('li').each(function(i,obj){
        $(obj).data( {
            offsetTop : $(obj).offset().top,
            height : $(obj).height()
        } );
    })
    function sort_li(a, b){
        return ($(b).data('hero')) > ($(a).data('hero')) ? 1 : -1; 
    }
})
Gnorme commented 7 years ago

Figured it out. I had to add $items = $items.add($(obj))