Open k-ivan opened 5 years ago
I have also an issue with the length:
"common.js:25759 Uncaught TypeError: Cannot read property 'length' of undefined".
My console tells me taht the problem comes from here in the slider js source file:
// make sure at least 1 slide if (options.container.children.length < 1) { if (supportConsoleWarn) { console.warn('No slides found in', options.container); } return; }
the same for me, after resizing window:
forEach.js:3 Uncaught TypeError: Cannot read property 'length' of null
at forEach (forEach.js:3)
at tiny-slider.js:1956
forEach @ forEach.js:3
(anonymous) @ tiny-slider.js:1956
setTimeout (async)
updateGallerySlidePositions @ tiny-slider.js:1955
resizeTasks @ tiny-slider.js:1444
(anonymous) @ tiny-slider.js:1212
requestAnimationFrame (async)
onResize @ tiny-slider.js:1212
This error occurs because the script is trying to create a slider out of an element that likely doesn't exist on your page. I am using this script for the first time and came across this too.
You need to do a check to see if the slider element exists first if you're running the script across your entire site
eg.
if ( $('.feature.slider').length > 0 ) {
var slider = tns({
//options here
});
}
I feel like this is something that should be handled by the script itself though, hopefully it will be updated in the future.
This error occurs because the script is trying to create a slider out of an element that likely doesn't exist on your page. I am using this script for the first time and came across this too.
You need to do a check to see if the slider element exists first if you're running the script across your entire site
eg.
if ( $('.feature.slider').length > 0 ) { var slider = tns({ //options here }); }
I feel like this is something that should be handled by the script itself though, hopefully it will be updated in the future.
Seconded. It'd be great if it could handle the slider not being present yet, or being empty.
if use react put tns in useEffect like that
useEffect(() => { tns({ container: '.slider-list', items: 1, slideBy: 'page', autoplay: true, }) }, [])
Hi, thanks for the plugin. Issue description: I encountered an error when destroing a plugin on a specific breakpoint. An error appears if the window is resized immediately after launch
destroy
method. Apparently, the variableslideItems
at this point has already been reset, and theforEach
is trying to use it.Demo link/slider setting: Example
Tiny-slider version: 2.9.1 Browser name && version: Google Chrome 71.0.3578.98 OS name && version: Windows 10