mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 05:23:17 +00:00
Merge pull request #5052 from pixelfed/staging
Update profile embed, fix height bug
This commit is contained in:
commit
ae60c99679
1 changed files with 29 additions and 17 deletions
|
@ -76,21 +76,33 @@
|
|||
.then(res => res.json())
|
||||
.then(res => {
|
||||
let parent = document.querySelector('.embed-row');
|
||||
|
||||
res.filter(res => res.pf_type == 'photo' && !res.sensitive && res.visibility === 'public')
|
||||
res.filter(post => post.pf_type == 'photo' && !post.sensitive && post.visibility === 'public')
|
||||
.slice(0, 9)
|
||||
.forEach(post => {
|
||||
.forEach((post, idx) => {
|
||||
let mediaUrl = post.media_attachments[0].preview_url ? post.media_attachments[0].preview_url : post.media_attachments[0].url;
|
||||
let el = document.createElement('template')
|
||||
el.innerHTML = `<div class="col-4 mt-2 px-0"><a class="card info-overlay card-md-border-0 px-1 shadow-none" href="${post.url}" target="_blank"><div class="square"><div class="square-content" style="background-image: url('${mediaUrl}')"></div></div></a></div>`;
|
||||
parent.append(el.content);
|
||||
let html = `<div class="col-4 mt-2 px-0"><a class="card info-overlay card-md-border-0 px-1 shadow-none" href="${post.url}" target="_blank"><div class="square"><div class="square-content" style="background-image: url('${mediaUrl}')"></div></div></a></div>`;
|
||||
let el = document.createElement('div');
|
||||
el.innerHTML = html;
|
||||
parent.appendChild(el.firstChild);
|
||||
});
|
||||
})
|
||||
}).then(() => {
|
||||
window.addEventListener("message",e=>{const t=e.data||{};window.parent&&"setHeight"===t.type&&window.parent.postMessage({type:"setHeight",id:t.id,height:document.getElementsByTagName("html")[0].scrollHeight},"*")});
|
||||
window.addEventListener("message", e => {
|
||||
const t = e.data || {};
|
||||
if (window.parent && t.type === 'setHeight') {
|
||||
updateHeight(t.id)
|
||||
}
|
||||
});
|
||||
|
||||
function updateHeight(id) {
|
||||
setTimeout(() => {
|
||||
window.addEventListener("message",e=>{const t=e.data||{};window.parent&&"setHeight"===t.type&&window.parent.postMessage({type:"setHeight",id:t.id,height:document.getElementsByTagName("html")[0].scrollHeight},"*")});
|
||||
}, 5000);
|
||||
})
|
||||
window.parent.postMessage({
|
||||
type: 'setHeight',
|
||||
id: id,
|
||||
height: document.documentElement.scrollHeight
|
||||
}, "*");
|
||||
}, 2500)
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue