Skip to content

Commit

Permalink
otimiza view.js dos blocos vertical e gorizontal
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagolamonte committed Sep 9, 2024
1 parent 337fa8e commit 47b8dad
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,44 @@ import slick from 'slick-carousel'
document.addEventListener("DOMContentLoaded", function() {
const horizontalSliders = document.querySelectorAll('[data-slider="horizontal-posts"]')

horizontalSliders.forEach(slider => {
const slides = slider.querySelector('.latest-horizontal-posts-block__slides')
const arrows = slider.querySelector('.latest-horizontal-posts-block__arrows')
const dots = slider.querySelector('.latest-horizontal-posts-block__dots')
const slidesToShow = slider.dataset.slidesToShow || 3
if (horizontalSliders.length > 0) {

// Mobile
const arrowsMobile = slider.querySelector('.medium-only .latest-horizontal-posts-block__arrows')
const dotsMobile = slider.querySelector('.medium-only .latest-horizontal-posts-block__dots')
const { default: slick } = import('slick-carousel');

let slidesToShowMobile = 1
if (slider.classList.contains('model-specials') || slider.classList.contains('model-most-read')) {
slidesToShowMobile = 2
} else if (slider.classList.contains('model-collection') || slider.classList.contains('model-albums')) {
slidesToShowMobile = 1.5
}
horizontalSliders.forEach(slider => {
const slides = slider.querySelector('.latest-horizontal-posts-block__slides')
const arrows = slider.querySelector('.latest-horizontal-posts-block__arrows')
const dots = slider.querySelector('.latest-horizontal-posts-block__dots')
const slidesToShow = slider.dataset.slidesToShow || 3

jQuery(slides).slick({
appendArrows: arrows,
appendDots: dots,
dots: true,
infinite: false,
slidesToShow: parseInt(slidesToShow),
responsive: [
{
breakpoint: 783,
settings: {
appendArrows: arrowsMobile,
appendDots: dotsMobile,
slidesToShow: slidesToShowMobile,
}
}
]
})
})
// Mobile
const arrowsMobile = slider.querySelector('.medium-only .latest-horizontal-posts-block__arrows')
const dotsMobile = slider.querySelector('.medium-only .latest-horizontal-posts-block__dots')

let slidesToShowMobile = 1
if (slider.classList.contains('model-specials') || slider.classList.contains('model-most-read')) {
slidesToShowMobile = 2
} else if (slider.classList.contains('model-collection') || slider.classList.contains('model-albums')) {
slidesToShowMobile = 1.5
}

jQuery(slides).slick({
appendArrows: arrows,
appendDots: dots,
dots: true,
infinite: false,
slidesToShow: parseInt(slidesToShow),
responsive: [
{
breakpoint: 783,
settings: {
appendArrows: arrowsMobile,
appendDots: dotsMobile,
slidesToShow: slidesToShowMobile,
}
}
]
})
})
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import slick from 'slick-carousel'
document.addEventListener("DOMContentLoaded", function() {
const sliders = document.querySelectorAll('[data-slider="vertical-posts"]')

sliders.forEach(slider => {
const slides = slider.querySelector('.latest-vertical-posts-block__slides')
const arrows = slider.querySelector('.latest-vertical-posts-block__arrows')
const dots = slider.querySelector('.latest-vertical-posts-block__dots')
const { default: slick } = import('slick-carousel');

jQuery(slides).slick({
appendArrows: arrows,
appendDots: dots,
dots: true,
infinite: false,
slidesToShow: 1
})
})
})
if (sliders.length > 0) {
sliders.forEach(slider => {
const slides = slider.querySelector('.latest-vertical-posts-block__slides')
const arrows = slider.querySelector('.latest-vertical-posts-block__arrows')
const dots = slider.querySelector('.latest-vertical-posts-block__dots')

jQuery(slides).slick({
appendArrows: arrows,
appendDots: dots,
dots: true,
infinite: false,
slidesToShow: 1
})
})
}
})
2 changes: 1 addition & 1 deletion themes/midia-ninja-theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Theme URI: https://hacklab.com.br/
Author: Hacklab
Author URI: https://hacklab.com.br/
Description: Tema base para desenvolvimento de novos sites.
Version: 1.1.48
Version: 1.1.49
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready
Expand Down

0 comments on commit 47b8dad

Please sign in to comment.