Skip to content

Commit

Permalink
fix(flicking): Fix wrong referencing of panel elements
Browse files Browse the repository at this point in the history
When container element is given,
corrected referencing panel elements properly.

Fix #438
Close #457
  • Loading branch information
netil authored Mar 3, 2017
1 parent ec15711 commit db6945a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/flicking.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ eg.module("flicking", ["jQuery", eg, window, document, eg.MovableCoord], functio
_setConfig: function($children, _prefix) {
var options = this.options;
var padding = options.previewPadding;
var $container = $children.filter("." + options.prefix + "-container:first");

if ($children.eq(0).hasClass(options.prefix + "-container")) {
this.$container = $children;
$children = $children.children();
if ($container.length) {
this.$container = $container;
$children = $container.children();
}

// config value
Expand Down
5 changes: 5 additions & 0 deletions test/unit/flicking.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ <h2 id="qunit-userAgent"></h2>
<p>Layer 2</p>
</div>
</div>
<div class="spot_cont_box">
<div class="item_source"></div>
<div class="item_source"></div>
<div class="item_source"></div>
</div>
</div>

Circular :
Expand Down
2 changes: 2 additions & 0 deletions test/unit/js/flicking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ QUnit.test("Check for the initialization", function(assert) {

// https://github.com/naver/egjs/issues/216
var $container = $("#mflick1-1 > :first-child").attr("id", "container");
var panelCount = $container.children().size();
var inst3 = this.create("#mflick1-1");

// Then
Expand All @@ -100,6 +101,7 @@ QUnit.test("Check for the initialization", function(assert) {
assert.equal(inst2._conf.panel.size, inst2._conf.panel.$list.outerHeight(), "The panel should maintain same height as wrapper element.");

assert.equal($container.attr("id"), inst3.$container.attr("id"), "The given DOM is used as container element?");
assert.equal(panelCount, inst3._conf.panel.$list.length, "The panels are taken properly referenced?");
});

QUnit.module("Setting options", hooks);
Expand Down

0 comments on commit db6945a

Please sign in to comment.