Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1067 - Add responsive options to carousel #1068

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/pat/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ parser.addArgument("slides-to-scroll", 1);
parser.addArgument("dots", "show");
parser.addArgument("append-dots", "");
parser.addArgument("infinite", false);
parser.addArgument("breakpoint1", "");
parser.addArgument("breakpoint2", "");
parser.addArgument("breakpoint1-slides-to-show", 1);
parser.addArgument("breakpoint2-slides-to-show", 1);

export default Base.extend({
name: "carousel",
Expand Down Expand Up @@ -49,6 +53,25 @@ export default Base.extend({
this.settings.appendDots = this.options.appendDots;
}

var responsive_options = [];
if (this.options['breakpoint1']) {
responsive_options.push({
breakpoint: this.options['breakpoint1'],
settings: {
slidesToShow: this.options['breakpoint1SlidesToShow']
}
});
}
if (this.options['breakpoint2']) {
responsive_options.push({
breakpoint: this.options['breakpoint2'],
settings: {
slidesToShow: this.options['breakpoint2SlidesToShow']
}
});
}
this.settings.responsive = responsive_options;

ImagesLoaded(this.el, () => this.setup());
},

Expand Down
22 changes: 22 additions & 0 deletions src/pat/carousel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,28 @@ <h2>Non-image content</h2>
src="http://farm3.staticflickr.com/2581/3881246563_187586ddc5_z_d.jpg"/>
</div>
</div>

<h3>Responsive carousel</h3>

<ul class="pat-carousel"
data-pat-carousel="slides-to-show: 2; breakpoint1: 1200; breakpoint2: 767; breakpoint1-slides-to-show: 1; breakpoint2-slides-to-show: 1">
<li id="li-list26">
<img
alt=""
src="http://farm8.staticflickr.com/7274/7591031938_76b64e13fa_z_d.jpg"/>
</li>
<li id="li-list27">
<img
alt=""
src="http://farm8.staticflickr.com/7123/7591044464_e593c023df_z_d.jpg"/>
</li>
<li id="li-list28">
<img
alt=""
src="http://farm3.staticflickr.com/2581/3881246563_187586ddc5_z_d.jpg"/>
</li>
</ul>

<footer>
All image are copyright 2012 by
<a href="http://www.wiggy.net/">Wichert Akkerman</a>.
Expand Down