Slick: putting slick in foundation tabs causing an init issue

Created on 18 Mar 2015  路  3Comments  路  Source: kenwheeler/slick

Trying to put two different instances of slick into foundation tabs. Seems that there is some sort of init issue when slick is not being displayed as the second instance loads all wonky until a slide action is taken. Have illustrated the issue in the fiddle below.

http://jsfiddle.net/nvfsbt1h/15/

Any help would be much appreciated!

Most helpful comment

In Foundation 6 listen to the tabs event change.zf.tabs (_Fires when the plugin has successfully changed tabs._)

$(".tabs").on("change.zf.tabs", function () {
    $(".slider").slick("setPosition");
});

All 3 comments

It's because javascript cannot properly calculate dimensions of hidden objects. To combat this, reset the dimensions on tab load:

$(".tabs").on("toggled", function (event, tab) {
    $(".slider").slick("setPosition");
});

http://jsfiddle.net/nvfsbt1h/16/

Thank you simeydotme, it works!!

In Foundation 6 listen to the tabs event change.zf.tabs (_Fires when the plugin has successfully changed tabs._)

$(".tabs").on("change.zf.tabs", function () {
    $(".slider").slick("setPosition");
});
Was this page helpful?
0 / 5 - 0 ratings