Tiny-slider: Can i initialize with data attribute setting?

Created on 9 Feb 2018  路  5Comments  路  Source: ganlanyuan/tiny-slider

Hi, like slick carousel, it is possible to execute this with a Tiny slider

<div class="my-slider" data-tiny-slider='{"loop": false, "items": 3}'>
  <div></div>
  <div></div>
  <div></div>
</div>
var slider = tns({
    container: '.my-slider'
});

All 5 comments

Hey, it's not available right now.
But you can do it with:

var sliderContainer = document.querySelector('.my-slider'),
    opt = JSON.parse(sliderContainer.getAttribute('data-tiny-slider'));

opt.container = sliderContainer;

var slider = tns(opt);

It working, thank you !!!

What's the type of the value?
String or Boolean

Hi, I have a little confused here, the option to display Arrow key is controls, not arrowKeys 馃槃

Oh, yes.
controls is for prev/next buttons.
arrowKeys bind the prev/next button functions to arrow keys on the keyboard.

Was this page helpful?
0 / 5 - 0 ratings