This commit is contained in:
杜恒 2021-01-20 16:14:48 +08:00
parent d9e7ec858d
commit b835bca92d
6 changed files with 74 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -502,6 +502,69 @@
text-align: center; text-align: center;
color: var(--routine); color: var(--routine);
} }
.item {
margin-bottom: 15px;
&:last-child {
margin-bottom: 0;
}
&:nth-child(1) .link .sort {
background: #ff183e;
}
&:nth-child(2).link .sort {
background: #ff5c38;
}
&:nth-child(3) .link .sort {
background: #ffb821;
}
.link {
position: relative;
display: block;
border-radius: 4px;
overflow: hidden;
&:hover .image {
transform: scale(1.2);
}
.sort {
position: absolute;
top: 5px;
right: -20px;
background: #7f7f8c;
color: #fff;
width: 65px;
text-align: center;
font-size: 12px;
transform: rotate(45deg);
font-weight: 500;
z-index: 1;
font-style: normal;
}
.image {
width: 100%;
height: 130px;
object-fit: cover;
transition: transform 0.35s;
}
.describe {
position: absolute;
z-index: 1;
left: 0;
right: 0;
bottom: 0;
padding: 10px;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.45));
font-size: 12px;
color: var(--seat);
h6 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #fff;
line-height: 24px;
font-size: 14px;
}
}
}
}
} }
} }
} }

View File

@ -0,0 +1 @@
class LazyLoad{constructor(t){this.imglist=Array.from($(t)),this.init()}canILoad(){let t=this.imglist;for(let i=t.length;i--;)this.getBound(t[i])&&this.loadImage(t[i],i)}getBound(t){let i=t.getBoundingClientRect(),n=window.innerHeight;return i.top<=n}loadImage(t,i){let n=t.getAttribute("data-original");t.src=n,this.imglist.splice(i,1)}bindEvent(){$(window).on("scroll",()=>this.imglist.length&&this.canILoad()),$(window).on("resize",()=>this.imglist.length&&this.canILoad())}init(){this.canILoad(),this.bindEvent()}}

View File

@ -67,6 +67,11 @@ function _getThumbnail($item)
echo $randomThumb; echo $randomThumb;
} }
function _getLazyload()
{
echo Helper::options()->JLazyload;
}
function _getAsideAuthorNav() function _getAsideAuthorNav()
{ {
if (Helper::options()->JAside_Author_Nav !== "off") { if (Helper::options()->JAside_Author_Nav !== "off") {

View File

@ -207,11 +207,9 @@ function themeConfig($form)
'JLazyload', 'JLazyload',
NULL, NULL,
"https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/img/lazyload.jpg", "https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/img/lazyload.jpg",
'自定义缩略图(非必填)', '自定义懒加载图(非必填)',
'介绍:用于修改主题默认缩略图 <br/> '介绍:用于修改主题默认懒加载图 <br/>
格式:图片地址,一行一个 <br /> 格式:图片地址'
注意:不填写时,则使用主题内置的默认缩略图
'
); );
$JLazyload->setAttribute('class', 'joe_content joe_image'); $JLazyload->setAttribute('class', 'joe_content joe_image');
$form->addInput($JLazyload); $form->addInput($JLazyload);

View File

@ -58,7 +58,7 @@
<li class="item"> <li class="item">
<a class="link" href="<?php $item->permalink() ?>" title="<?php $item->title() ?>"> <a class="link" href="<?php $item->permalink() ?>" title="<?php $item->title() ?>">
<i class="sort"><?php ?></i> <i class="sort"><?php ?></i>
<img class="image lazyload" data-original="<?php _getThumbnail($item); ?>" alt="<?php $item->title() ?>" /> <img class="image lazyload" src="<?php _getLazyload() ?>" data-original="<?php _getThumbnail($item); ?>" alt="<?php $item->title() ?>" />
<div class="describe"> <div class="describe">
<h6><?php $item->title() ?></h6> <h6><?php $item->title() ?></h6>
<span> 阅读 - <?php $item->date('m/d'); ?></span> <span> 阅读 - <?php $item->date('m/d'); ?></span>