Skip to content

Huynhhuynh/owlcarousel2-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OwlCarousel 2 - Filter

Demo

Setup demo

git clone [email protected]:Huynhhuynh/owlcarousel2-filter.git
cd owlcarousel2-filter
npm install
npm start

Html

<nav class="owl-filter-bar">
    <a href="#" class="item" data-owl-filter="*">All</a>
    <a href="#" class="item" data-owl-filter=".red">Red</a>
    <a href="#" class="item" data-owl-filter=".blue">Blue</a>
</nav>

<div class="owl-carousel owl-theme">
    <div class="item red"><h4>1</h4></div>
    <div class="item red"><h4>2</h4></div>
    <div class="item blue"><h4>3</h4></div>
    <div class="item"><h4>4</h4></div>
    <div class="item"><h4>5</h4></div>
    <div class="item red"><h4>6</h4></div>
    <div class="item"><h4>7</h4></div>
    <div class="item"><h4>8</h4></div>
    <div class="item blue"><h4>9</h4></div>
    <div class="item"><h4>10</h4></div>
    <div class="item blue"><h4>11</h4></div>
    <div class="item"><h4>12</h4></div>
</div>

OwlCarousel 2 - Init

var owl = $('.owl-carousel').owlCarousel({
    loop:true,
    margin:10,
    nav:true,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
    }
})

OwlCarousel 2 - Filter

// owl.owlcarousel2_filter( '.blue' );

$( '.owl-filter-bar' ).on( 'click', '.item', function() {

    var $item = $(this);
    var filter = $item.data( 'owl-filter' )

    $item.addClass( 'current' ).siblings().removeClass( 'current' );

    owl.owlcarousel2_filter( filter );

} )
1.1
- Fix issue responsive not work

First released

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published