Tiny-slider: Responsive option doesn't work

Created on 18 Jul 2018  路  7Comments  路  Source: ganlanyuan/tiny-slider

__Issue description__:
Responsive option works incorrectly

__Demo link/slider setting__:
https://jsfiddle.net/dra1n/w136t9Lk/

_Tiny-slider version_:
2.8.2

_Browser name && version_:
Any

_OS name && version_:
Any

Mainly because of this check inside getOption:

if (viewport >= bp) {
   if (item in responsive[bp]) { result = responsive[bp][item]; }
}

for of converts keys to string and "320" is greater than "1024".

bug

Most helpful comment

Thanks guys, should be fixed in this commit

All 7 comments

You demo works properly for me.

For any resolution between 320px and 1024px it should take settings from 320 option, so we should see 1 item (for example on 640px ). At least that was the old behavior.
Here is 2.8.1, works correctly https://jsfiddle.net/dra1n/g3v4c5fz/

It's not working for me, when we change 1024 to 999 in the fiddle above (using 2.8.2) it works fine, but any value 1000 or above does not work.

@opr Yes, that's because lexical order is used here to compare numbers. "999" is greater than "320", but "1000" is less than "320".

I tested it out and you have to parseInt bp variable.

if (viewport >= parseInt(bp)) {
 if (item in responsive[bp]) { result = responsive[bp][item]; }
}

Then it works properly.

Just for safety I personally parse viewport too.

if (parseInt(viewport)>= parseInt(bp)) {
 if (item in responsive[bp]) { result = responsive[bp][item]; }
}

Thanks guys, should be fixed in this commit

v2.8.3 was published, will close this

Was this page helpful?
0 / 5 - 0 ratings