Skip to content

Commit

Permalink
fix: 修复侧边栏的图片高度获取问题
Browse files Browse the repository at this point in the history
  • Loading branch information
youranreus committed Nov 26, 2021
1 parent 80af36b commit e9f6568
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
18 changes: 10 additions & 8 deletions components/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@
</div>

<div class="clear">
<div class="sliderbar-content" id="categoryList">
<div class="sliderbar-content" id="categoryList" style="<?php if ($this->options->profilePhoto == ''): ?>width: 100%;<?php endif; ?>">
<div class="category-content">
<?php $this->widget('Widget_Metas_Category_List')->parse('<li><a onclick="toggleSidebar()" href="{permalink}">{name}</a></li>'); ?>
</div>
</div>
<div class="sliderbar-content" id="sliderbar-photo" style="background-image:url(<?php echo $this->options->profilePhoto; ?>)">
<?php if ($this->options->profileVideo != ''): ?>
<video id="sliderbar-video" loop muted autoplay src="<?php echo $this->options->profileVideo; ?>" poster="<?php echo $this->options->profilePhoto; ?>"></video>
<?php endif; ?>
<div>
<p><?php echo $this->options->profilePhotoDes; ?></p>
<?php if ($this->options->profilePhoto != ''): ?>
<div class="sliderbar-content" id="sliderbar-photo" style="background-image:url(<?php echo $this->options->profilePhoto; ?>)">
<?php if ($this->options->profileVideo != ''): ?>
<video id="sliderbar-video" loop muted autoplay src="<?php echo $this->options->profileVideo; ?>" poster="<?php echo $this->options->profilePhoto; ?>"></video>
<?php endif; ?>
<div>
<p><?php echo $this->options->profilePhotoDes; ?></p>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
<div id="sliderbar-cover" onclick="toggleSidebar()"></div>
5 changes: 4 additions & 1 deletion static/js/G.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ window.onload = function () {
scrollRestoration: true
});

if (document.getElementById("sliderbar-video") !== undefined) {
if (document.getElementById("sliderbar-video") !== undefined && document.getElementById("sliderbar-video") !== null) {
let photo = document.getElementById("sliderbar-photo");
let video = document.getElementById("sliderbar-video");
photo.style.height = document.querySelector('#categoryList').offsetHeight + 'px';
Expand All @@ -453,6 +453,9 @@ window.onload = function () {
else
video.style.height = photo.offsetWidth + 'px';
}
else if (document.getElementById("sliderbar-photo")!== undefined && document.getElementById("sliderbar-photo") !== null){
document.getElementById("sliderbar-photo").style.height = document.querySelector('#categoryList').offsetHeight + 'px';
}
autoDarkMode();
toolbarInit();
pageInit();
Expand Down
Loading

0 comments on commit e9f6568

Please sign in to comment.