added autoplay video clips

master
A1Gard 1 month ago
parent 57169f8dcf
commit 148880a754

@ -0,0 +1,17 @@
<section class='AutoPlayClips'>
<div class="{{gfx()['container']}}">
<h1>
{{getSetting($data->area->name.'_'.$data->part.'_title')}}
</h1>
<div class="autoplay-clip-list">
@foreach(\App\Models\Clip::where('status',1)->get() as $clip)
<div class="autoplay-clip-item">
<a href="{{$clip->webUrl()}}">
<video src="{{$clip->fileUrl()}}" poster="{{$clip->imgUrl()}}" muted ></video>
</a>
{{-- <img src="{{$clip->imgUrl()}}" alt="">--}}
</div>
@endforeach
</div>
</div>
</section>

@ -0,0 +1,17 @@
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.autoplay-clip-item').forEach(function (el) {
el.addEventListener('mouseenter', function () {
try {
this.querySelector('video').play();
} catch {
}
});
el.addEventListener('mouseleave', function () {
try {
this.querySelector('video').pause();
} catch {
}
});
});
});

@ -0,0 +1,10 @@
{
"name": "AutoPlayClips",
"version": "1.0",
"author": "xStack",
"email": "xshop@xstack.ir",
"license": "GPL-3.0-or-later",
"url": "https:\/\/xstack.ir",
"author_url": "https:\/\/4xmen.ir",
"packages": []
}

@ -0,0 +1,29 @@
<?php
namespace Resources\Views\Segments;
use App\Models\Part;
use App\Models\Setting;
class AutoPlayClips
{
public static function onAdd(Part $part = null)
{
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_title';
$setting->value = "Clips list";
$setting->type = 'text';
$setting->size = 6;
$setting->title = $part->area->name . ' ' . $part->part;
$setting->save();
}
public static function onRemove(Part $part = null)
{
Setting::where('key',$part->area->name . '_' . $part->part.'_title')->first()?->delete();
}
public static function onMount(Part $part = null)
{
return $part;
}
}

@ -0,0 +1,27 @@
.AutoPlayClips {
padding: 2rem 0;
h1 {
font-size: 27px;
font-weight: 400;
}
.autoplay-clip-list {
display: flex;
column-gap: .5rem;
}
.autoplay-clip-item {
transition: 700ms;
flex: 1;
video,img {
width: 100%;
border-radius: var(--xshop-border-radius);
height: 300px;
object-fit: cover;
}
&:hover{
flex-grow: 2;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Loading…
Cancel
Save