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

Supporting nested sliders #3970

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
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ responsive | array | null | Array of objects [containing breakpoints and setting
rows | int | 1 | Setting this to more than 1 initializes grid mode. Use slidesPerRow to set how many slides should be in each row.
rtl | boolean | false | Change the slider's direction to become right-to-left
slide | string | '' | Slide element query
sliderContainer | string | '' | Query to locate the container of the slides. Defaults to the slider itself.
slidesPerRow | int | 1 | With grid mode initialized via the rows option, this sets how many slides are in each grid row.
slidesToScroll | int | 1 | # of slides to scroll at a time
slidesToShow | int | 1 | # of slides to show at a time
Expand Down
15 changes: 9 additions & 6 deletions slick/slick.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
rows: 1,
rtl: false,
slide: '',
sliderContainer: '',
slidesPerRow: 1,
slidesToShow: 1,
slidesToScroll: 1,
Expand Down Expand Up @@ -160,6 +161,8 @@
_.visibilityChange = 'webkitvisibilitychange';
}

_.$sliderContainer = _.options.sliderContainer ? $(element).find(_.options.sliderContainer) : $(element);

_.autoPlay = $.proxy(_.autoPlay, _);
_.autoPlayClear = $.proxy(_.autoPlayClear, _);
_.autoPlayIterator = $.proxy(_.autoPlayIterator, _);
Expand Down Expand Up @@ -507,7 +510,7 @@
var _ = this;

_.$slides =
_.$slider
_.$sliderContainer
.children( _.options.slide + ':not(.slick-cloned)')
.addClass('slick-slide');

Expand Down Expand Up @@ -557,7 +560,7 @@
var _ = this, a, b, c, newSlides, numOfSlides, originalSlides,slidesPerSection;

newSlides = document.createDocumentFragment();
originalSlides = _.$slider.children();
originalSlides = _.$sliderContainer.children();

if(_.options.rows > 0) {

Expand All @@ -581,8 +584,8 @@
newSlides.appendChild(slide);
}

_.$slider.empty().append(newSlides);
_.$slider.children().children().children()
_.$sliderContainer.empty().append(newSlides);
_.$sliderContainer.children().children().children()
.css({
'width':(100 / _.options.slidesPerRow) + '%',
'display': 'inline-block'
Expand Down Expand Up @@ -824,7 +827,7 @@
if(_.options.rows > 0) {
originalSlides = _.$slides.children().children();
originalSlides.removeAttr('style');
_.$slider.empty().append(originalSlides);
_.$sliderContainer.empty().append(originalSlides);
}

};
Expand Down Expand Up @@ -898,7 +901,7 @@

_.$list.detach();

_.$slider.append(_.$slides);
_.$sliderContainer.append(_.$slides);
}

_.cleanUpRows();
Expand Down