refactoring

This commit is contained in:
Burak Civan 2022-10-18 16:29:28 +03:00
parent f5f69139d5
commit 967ea50877
4 changed files with 39 additions and 38 deletions

View File

@ -362,24 +362,25 @@ if (navigator.userAgent.search("Firefox") >= 0) {
document.querySelectorAll('[data-truncate]').forEach((truncate) => { document.querySelectorAll('[data-truncate]').forEach((truncate) => {
let truncateText = truncate.innerText.split(" ").join(""); let truncateText = truncate.innerText.split(" ").join("");
if (truncate.offsetWidth > truncate.parentElement.clientWidth || truncate.offsetWidth > truncate.parentElement.parentElement.clientWidth) {
truncate.addEventListener('mouseover', function () { truncate.addEventListener('mouseover', function () {
if (truncateText.length > 30) { truncate.parentElement.style.animationPlayState = 'running';
truncate.style.animationPlayState = 'running'; truncate.parentElement.classList.add('animate-marquee');
truncate.classList.add('animate-marquee');
if (truncate.classList.contains('truncate')) { // if (truncate.parentElement.classList.contains('truncate')) {
truncate.classList.remove('truncate'); // truncate.parentElement.classList.remove('truncate');
} // }
}
}); });
truncate.addEventListener('mouseout', function () { truncate.addEventListener('mouseout', function () {
if (truncateText.length > 30) { truncate.parentElement.style.animationPlayState = 'paused';
truncate.style.animationPlayState = 'paused'; truncate.parentElement.classList.remove('animate-marquee');
truncate.classList.add('truncate'); truncate.parentElement.classList.add('truncate');
truncate.classList.remove('animate-marquee');
}
}); });
truncate.classList.add('truncate');
truncate.parentElement.classList.add('truncate');
}
}); });
//disable/enable icons ejected from data-truncate //disable/enable icons ejected from data-truncate

View File

@ -84,7 +84,7 @@
</x-table.td> </x-table.td>
<x-table.td class="w-6/12 sm:w-4/12"> <x-table.td class="w-6/12 sm:w-4/12">
<x-slot name="first" class="flex items-center font-bold" override="class"> <x-slot name="first" class="font-bold" override="class">
{{ $item->name }} {{ $item->name }}
@if (! $item->enabled) @if (! $item->enabled)

View File

@ -8,9 +8,11 @@
} }
@endphp @endphp
<div {{ $first_attributes }}> <div {{ $first_attributes }}>
<x-marguee-text> <div>
<span data-truncate>
{!! $first !!} {!! $first !!}
</x-marguee-text> </span>
</div>
</div> </div>
@endif @endif
@ -23,13 +25,17 @@
} }
@endphp @endphp
<div {{ $second_attributes }}> <div {{ $second_attributes }}>
<x-marguee-text> <div>
<span data-truncate>
{!! $second !!} {!! $second !!}
</x-marguee-text> </span>
</div>
</div> </div>
@endif @endif
<x-marguee-text> <div>
<span data-truncate>
{{ $slot }} {{ $slot }}
</x-marguee-text> </span>
</div>
</td> </td>

View File

@ -8,9 +8,7 @@
} }
@endphp @endphp
<div {{ $first_attributes }}> <div {{ $first_attributes }}>
<x-marguee-text>
{!! $first !!} {!! $first !!}
</x-marguee-text>
</div> </div>
@endif @endif
@ -23,13 +21,9 @@
} }
@endphp @endphp
<div {{ $second_attributes }}> <div {{ $second_attributes }}>
<x-marguee-text>
{!! $second !!} {!! $second !!}
</x-marguee-text>
</div> </div>
@endif @endif
<x-marguee-text>
{{ $slot }} {{ $slot }}
</x-marguee-text>
</th> </th>