ساخت منوی جذاب تمام صفحه با المنتور

16 خرداد 1402

یکی از مهم ترین بخش های سایت، منوی اون سایته! چون ارزشمندترین لینک ها و صفحات تو منوی سایت قرار میگیره. پس اگه ما بتونیم این منو رو به شکل خاص و جذاب طراحی کنیم، خیلی میتونه به جذب مخاطب کمک کنه. تو این پست قراره که با المنتور و css یک منوی تمام صفحه با قابلیت هاور تصویری سفارشی رو باهم بسازیم 🙂

کدهای بخش اصلی منوی تمام صفحه (image-menu):

selector{
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease-in-out;
    --h: var(--min-height);
}
selector.showing{
    opacity: 1;
    pointer-events: auto;
}
selector .elementor-widget-icon-list ul li{
    opacity: 0;
    transform: translateY(30px) scaleY(1.1) skewY(10deg);
}
selector.showing .elementor-widget-icon-list ul li{
    opacity: 1;
    transform: none;
    transition: all 0.5s ease-in-out calc(0.2s + var(--index,1)*0.1s);
}
selector .menu-left,
selector .menu-close{
    opacity: 0;
}
selector.showing .menu-left,
selector.showing .menu-close{
    opacity: 1;
    transition: all 0.5s ease-in-out 0.3s;
}

.menu-open,
.menu-close{
    cursor: pointer;
}

کدهای جاوا اسکریپت:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
var $ = jQuery
$(document).ready(function(){

function hoveDefault(){
    $('.menu-right .elementor-icon-list-text').eq(0).trigger('mouseover')
}

function openMenu(){
    $('.image-menu').addClass('showing')
}

function closemenu(){
    $('.image-menu').removeClass('showing')
    setTimeout(hoveDefault, 500)
}

$('.image-menu').find('.elementor-widget-icon-list ul li').each(function(){
    var index = $(this).index()+1
    $(this).css('--index', index)
})

$('.menu-open').on('click', openMenu)
$('.menu-close').on('click', closemenu)


/* If Link is #id then Close Menu */

$('.menu-right a').on('click', function(e){
    var link = $(this).attr('href')
    if(link){
        if(link == '#'){
            e.preventDefault()
        }
        if( link.length > 1 && link.startsWith('#') ){
            closemenu()
        }    
    }
    
})


/* Image and Color Change on Menu Item Hover */

$('.menu-right .elementor-icon-list-text').hover(function(e){
    
var $this = $(this),
    index = $this.closest('.elementor-icon-list-item').index(),
    currentImage = $('.menu-left .elementor-widget-spacer').eq(index),
    color = currentImage.find('.elementor-widget-container').css('background-color')
    
$this.closest('.image-menu').css('background-color', color)

if(!currentImage.length) return

$this.closest('.elementor-icon-list-items').find('.elementor-icon-list-text').removeClass('active')
if(e.originalEvent){ $this.addClass('active') }

currentImage.siblings('.elementor-widget-spacer').removeClass('active')
currentImage.addClass('active')

}, function(){})

hoveDefault()

})


/* Adjust alignment of Left side Menu */

$(window).on('load resize', function(){
    
    $('.menu-right').each(function(){
        
        var containerHeight = $(this).height(),
        menuHeight = $(this).find('.elementor-widget-icon-list').outerHeight()
        
        if( menuHeight > containerHeight ){
            $(this).addClass('overflow')
        }else{
            $(this).removeClass('overflow')
        }
    })
})

</script>

کدهای بخش چپ منوی تمام صفحه (menu-left):

selector .elementor-widget-spacer{
    opacity: 0;
    transition: all 0.4s ease-in-out;
}
selector .elementor-widget-spacer:nth-child(1),
selector .elementor-widget-spacer.active{
    opacity: 1;
}
.menu-close .elementor-widget-divider{
    width: 100% !important;
    flex-grow: 0;
}

@media(max-width:767px){
selector{
    position: absolute;
    height: 100%;
    z-index: 0;
}   
}

کدهای بخش راست منوی تمام صفحه (menu-right):

selector{
    height: var(--h);
}
selector.overflow::-webkit-scrollbar {
    display: none;
}
selector.overflow{
    justify-content: flex-start;
    overflow-y: scroll;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
selector .elementor-widget-html{
    display: none;
}

کدهای مربوط به لیست آیکن:

selector{
    --hover-color: #ffffff;
    --mobile-color: #000000;
    --mobile-background: #ffffff;
}
selector .elementor-icon-list-text{
    transition: all 0.3s ease-in-out;
}
selector .elementor-icon-list-text.active{
    color: var(--hover-color, #fff);
}
selector a:focus{
    outline: none;
}

@media (max-width: 767px){
selector .elementor-icon-list-text{
    background: var(--mobile-background, #fff);
    padding: 8px 10px;
}
selector .elementor-icon-list-text,
selector .elementor-icon-list-text.active{
    color: var(--mobile-color, #000) !important;
}
}
اشتراک گذاری:
نویسنده این مطلب :
نیما حاجی زاده

نیما حاجی زاده

هرگز اون روز رو فراموش نمی کنم، روزی که متحیر از قدرت بی نظیر المنتور بودم. انقدر از این افزونه صفحه ساز خوشم اومد که تصمیم گرفتم به عنوان آچار فرانسه کارم قرارش بدم!