diff --git a/dist/flickity.pkgd.js b/dist/flickity.pkgd.js index c66ff617..c8f238ff 100644 --- a/dist/flickity.pkgd.js +++ b/dist/flickity.pkgd.js @@ -1286,9 +1286,9 @@ 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._createViewport(); this._createSlider(); if ( this.options.resize || this.options.watchCSS ) { @@ -1326,11 +1326,14 @@ 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 ); + // only move elements if we haven't defined our own viewport + if (!this.options.viewport && !this.options.slider) { + // 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(); @@ -1358,11 +1361,15 @@ proto.activate = function() { this.isInitActivated = true; }; +Flickity.prototype._createViewport = function() { + this.viewport = this.options.viewport || document.createElement('div'); + this.viewport.classList.add('flickity-viewport'); +}; + // slider positions the cells -proto._createSlider = function() { - // slider element does all the positioning - var slider = document.createElement('div'); - slider.className = 'flickity-slider'; +Flickity.prototype._createSlider = function() { + var slider = this.options.slider || document.createElement('div'); + slider.classList.add('flickity-slider'); slider.style[ this.originSide ] = 0; this.slider = slider; }; @@ -1953,9 +1960,11 @@ proto.deactivate = function() { cell.destroy(); }); this.unselectSelectedSlide(); - this.element.removeChild( this.viewport ); - // move child elements back into element - moveElements( this.slider.children, this.element ); + if (!this.options.viewport && !this.options.slider) { + this.element.removeChild( this.viewport ); + // move child elements back into element + moveElements( this.slider.children, this.element ); + } if ( this.options.accessibility ) { this.element.removeAttribute('tabIndex'); this.element.removeEventListener( 'keydown', this ); diff --git a/dist/flickity.pkgd.min.js b/dist/flickity.pkgd.min.js index 57d775a8..2dfeab63 100644 --- a/dist/flickity.pkgd.min.js +++ b/dist/flickity.pkgd.min.js @@ -9,5 +9,5 @@ * Copyright 2016 Metafizzy */ -!function(t,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,o,a){function h(t,e,n){var s,o="$()."+i+'("'+e+'")';return t.each(function(t,h){var l=a.data(h,i);if(!l)return void r(i+" not initialized. Cannot call methods, i.e. "+o);var c=l[e];if(!c||"_"==e.charAt(0))return void r(o+" is not a valid method");var d=c.apply(l,n);s=void 0===s?d:s}),void 0!==s?s:t}function l(t,e){t.each(function(t,n){var s=a.data(n,i);s?(s.option(e),s._init()):(s=new o(n,e),a.data(n,i,s))})}a=a||e||t.jQuery,a&&(o.prototype.option||(o.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=s.call(arguments,1);return h(this,t,e)}return l(this,t),this},n(a))}function n(t){!t||t&&t.bridget||(t.bridget=i)}var s=Array.prototype.slice,o=t.console,r="undefined"==typeof o?function(){}:function(t){o.error(t)};return n(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return n.indexOf(e)==-1&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||{};return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return n!=-1&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,s=i[n];e=e||[];for(var o=this._onceEvents&&this._onceEvents[t];s;){var r=o&&o[s];r&&(this.off(t,s),delete o[s]),s.apply(this,e),n+=r?0:1,s=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():t.getSize=e()}(window,function(){"use strict";function t(t){var e=parseFloat(t),i=t.indexOf("%")==-1&&!isNaN(e);return i&&e}function e(){}function i(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0;e