|
@@ -14,8 +14,6 @@ export const SliderImage = ({images = [], className, ...props}) => {
|
|
if (divRef.current){
|
|
if (divRef.current){
|
|
const div = divRef.current
|
|
const div = divRef.current
|
|
|
|
|
|
- console.log(imgs)
|
|
|
|
-
|
|
|
|
const totalWidth = imgs.reduce((total, img) => total + (img?.getBoundingClientRect().width || 0),0)
|
|
const totalWidth = imgs.reduce((total, img) => total + (img?.getBoundingClientRect().width || 0),0)
|
|
div.style.width = totalWidth + 'px'
|
|
div.style.width = totalWidth + 'px'
|
|
}
|
|
}
|
|
@@ -32,7 +30,6 @@ export const SliderImage = ({images = [], className, ...props}) => {
|
|
autoscroll.current = true
|
|
autoscroll.current = true
|
|
const {scrollLeft} = el
|
|
const {scrollLeft} = el
|
|
const diff = (currentScrollPosition.current - scrollLeft) /5
|
|
const diff = (currentScrollPosition.current - scrollLeft) /5
|
|
- console.log()
|
|
|
|
if (Math.abs(diff) > 1){
|
|
if (Math.abs(diff) > 1){
|
|
el.scrollTo(scrollLeft + diff, 0)
|
|
el.scrollTo(scrollLeft + diff, 0)
|
|
setTimeout(step, 20)
|
|
setTimeout(step, 20)
|
|
@@ -82,7 +79,6 @@ export const SliderImage = ({images = [], className, ...props}) => {
|
|
newCurrent++
|
|
newCurrent++
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log(newCurrent, currentScrollPosition.current)
|
|
|
|
setCurrent(newCurrent)
|
|
setCurrent(newCurrent)
|
|
if (newCurrent === current) scrollToCurrent()
|
|
if (newCurrent === current) scrollToCurrent()
|
|
}, 200)
|
|
}, 200)
|