fixed the trending layout
This commit is contained in:
parent
0de27c0b1b
commit
553944423b
1 changed files with 11 additions and 17 deletions
|
@ -7,37 +7,31 @@
|
||||||
{{#unless this.nsfw}}
|
{{#unless this.nsfw}}
|
||||||
<a href="/{{this.name}}/{{this.claimId}}">
|
<a href="/{{this.name}}/{{this.claimId}}">
|
||||||
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
||||||
<video class="grid-item trending-video" controls>
|
<video class="grid-item trending-video" controls onloadeddata="resetLayout()">
|
||||||
<source src="/media/{{this.fileName}}">
|
<source src="/media/{{this.fileName}}" >
|
||||||
{{!--fallback--}}
|
{{!--fallback--}}
|
||||||
Your browser does not support the <code>video</code> element.
|
Your browser does not support the <code>video</code> element.
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
<img class="grid-item trending-image" src="/media/{{this.fileName}}" />
|
<img class="grid-item trending-image" src="/media/{{this.fileName}}" onload="resetLayout()"/>
|
||||||
{{/ifConditional}}
|
{{/ifConditional}}
|
||||||
</a>
|
</a>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var elem = document.querySelector('.grid');
|
var elem = document.querySelector('.grid');
|
||||||
var trendingImages = document.querySelectorAll('.trending-image');
|
|
||||||
var trendingVideos = document.querySelectorAll('.trending-video');
|
|
||||||
var msnry = new Masonry( elem, {
|
var msnry = new Masonry( elem, {
|
||||||
itemSelector: '.grid-item'
|
itemSelector: '.grid-item'
|
||||||
});
|
});
|
||||||
// after images are loaded, reset layout
|
|
||||||
for (var i = 0; i < trendingVideos.length; i++) {
|
function resetLayout() {
|
||||||
trendingImages[i].addEventListener('load', function(){
|
console.log('resetting layout');
|
||||||
msnry.layout();
|
msnry.layout();
|
||||||
})
|
|
||||||
}
|
|
||||||
// after videos are loaded, reset layout
|
|
||||||
for (var i = 0; i < trendingVideos.length; i++) {
|
|
||||||
trendingVideos[i].addEventListener('loadeddata', function(){
|
|
||||||
msnry.layout();
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue