Skip to content
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
29 changes: 19 additions & 10 deletions dist/flickity.pkgd.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,9 +1296,13 @@ proto._create = function() {
this.x = 0;
this.velocity = 0;
this.originSide = this.options.rightToLeft ? 'right' : 'left';
// create viewport & slider
this.viewport = document.createElement('div');
this.viewport.className = 'flickity-viewport';

this.viewport = this.element.querySelector('.flickity-viewport');
if (!this.viewport) {
// create viewport & slider
this.viewport = document.createElement('div');
this.viewport.className = 'flickity-viewport';
}
this._createSlider();

if ( this.options.resize || this.options.watchCSS ) {
Expand Down Expand Up @@ -1336,11 +1340,13 @@ proto.activate = function() {
}

this.getSize();
// move initial cell elements so they can be loaded as cells
var cellElems = this._filterFindCellElements( this.element.children );
moveElements( cellElems, this.slider );
this.viewport.appendChild( this.slider );
this.element.appendChild( this.viewport );
if (!this.slider.childElementCount) {
// move initial cell elements so they can be loaded as cells
var cellElems = this._filterFindCellElements( this.element.children );
moveElements( cellElems, this.slider );
this.viewport.appendChild( this.slider );
this.element.appendChild( this.viewport );
}
// get cells from children
this.reloadCells();

Expand Down Expand Up @@ -1371,8 +1377,11 @@ proto.activate = function() {
// slider positions the cells
proto._createSlider = function() {
// slider element does all the positioning
var slider = document.createElement('div');
slider.className = 'flickity-slider';
var slider = this.viewport.querySelector('.flickity-slider');
if (!slider) {
slider = document.createElement('div');
slider.className = 'flickity-slider';
}
slider.style[ this.originSide ] = 0;
this.slider = slider;
};
Expand Down
Loading