Skip to content

Commit

Permalink
Improve progress of Masonry and Swiper script
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Oct 19, 2024
1 parent a0e3d98 commit dee4ba1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
34 changes: 34 additions & 0 deletions assets/vendor/astroid/scss/utilities/_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
transition: all 300ms;
}

.as-loading {
&::before {
content: '';
position: absolute;
z-index: 1000;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: var(--bs-body-bg);
}
&::after {
content: '';
position: absolute;
z-index: 1000;
top: 50%;
left: 50%;
width: 60px;
height: 60px;
margin: -30px 0 0 -30px;
border-radius: 50%;
opacity: 0.4;
background: var(--bs-body-color) !important;
animation: loaderAnimation 0.7s linear infinite alternate forwards;
}
}

@keyframes loaderAnimation {
to {
opacity: 1;
transform: scale3d(0.5,0.5,1);
}
}

@-webkit-keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
Expand Down
6 changes: 4 additions & 2 deletions framework/library/astroid/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,8 @@ public function loadMasonry($selector = ''): void
self::$_masonry = true;
}
if (!empty($selector)) {
$wa->addInlineScript('jQuery(window).on("load", function(){$(\''.$selector.'\').masonry({itemSelector: \''.$selector.' > div\',percentPosition: true});});');
$this->loadImagesLoaded();
$wa->addInlineScript('jQuery(document).ready(function(){jQuery(\''.$selector.'\').addClass("as-loading");jQuery(\''.$selector.'\').imagesLoaded(function() { jQuery(\''.$selector.'\').masonry({itemSelector: \''.$selector.' > div\',percentPosition: true}); jQuery(\''.$selector.'\').removeClass("as-loading"); });});');
}
}

Expand All @@ -970,7 +971,8 @@ public function loadSwiper($obj = '', $config = ''): void
self::$_swiper = true;
}
if (!empty($obj) && !empty($config)) {
$wa->addInlineScript('jQuery(document).ready(function(){const swiper = new Swiper(\''.$obj.'\', {'.$config.'});});');
$this->loadImagesLoaded();
$wa->addInlineScript('jQuery(document).ready(function(){jQuery(\''.$obj.'\').addClass("as-loading");jQuery(\''.$obj.'\').imagesLoaded( function() {const swiper = new Swiper(\''.$obj.'\', {'.$config.'}); jQuery(\''.$obj.'\').removeClass("as-loading"); });});');
}
}

Expand Down
3 changes: 2 additions & 1 deletion framework/library/astroid/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;

Expand Down Expand Up @@ -103,7 +104,7 @@ public function __construct($type = '', $data = [], $template = null, $mode = ''
$plugin_folders = Folder::folders($plugin_elements_directory);
if (count($plugin_folders)) {
foreach ($plugin_folders as $plugin_folder) {
if (file_exists(Path::clean($plugin_elements_directory . '/' . $plugin_folder . '/elements/' . $this->type . '/' . $this->type . '.xml'))) {
if (PluginHelper::isEnabled('astroid', $plugin_folder) && file_exists(Path::clean($plugin_elements_directory . '/' . $plugin_folder . '/elements/' . $this->type . '/' . $this->type . '.xml'))) {
$this->xml_file = Path::clean($plugin_elements_directory . '/' . $plugin_folder . '/elements/' . $this->type . '/' . $this->type . '.xml');
$this->layout = Path::clean($plugin_elements_directory . '/' . $plugin_folder . '/elements/' . $this->type . '/' . $this->type . '.php');
}
Expand Down
2 changes: 1 addition & 1 deletion framework/library/astroid/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public static function getAllAstroidElements($mode = '', $template_id = null)
$plugin_folders = Folder::folders($plugin_elements_dir);
if (count($plugin_folders)) {
foreach ($plugin_folders as $plugin_folder) {
if (file_exists(Path::clean($plugin_elements_dir . '/' . $plugin_folder . '/elements/'))) {
if (PluginHelper::isEnabled('astroid', $plugin_folder) && file_exists(Path::clean($plugin_elements_dir . '/' . $plugin_folder . '/elements/'))) {
// Merging Plugin Elements
$elements = array_merge($elements, Folder::folders($plugin_elements_dir . '/' . $plugin_folder . '/elements/', '.', false, true));
}
Expand Down

0 comments on commit dee4ba1

Please sign in to comment.