|
@@ -14,15 +14,6 @@ export default ({images = [], className, onChange, onClick, ref, siblingOnly, cu
|
|
|
|
|
|
const widthSum = (total, img) => total + (img?.getBoundingClientRect().width || 0)
|
|
const widthSum = (total, img) => total + (img?.getBoundingClientRect().width || 0)
|
|
|
|
|
|
- useEffect(() => {
|
|
|
|
- if (divRef.current){
|
|
|
|
- const div = divRef.current
|
|
|
|
-
|
|
|
|
- const totalWidth = imgs.reduce(widthSum, 0)
|
|
|
|
- div.style.minWidth = totalWidth + 'px'
|
|
|
|
- }
|
|
|
|
- }, [divRef, imgs])
|
|
|
|
-
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (containerRef.current){
|
|
if (containerRef.current){
|
|
const scrollTo = imgs.slice(0,propCurrent).reduce(widthSum, 0)
|
|
const scrollTo = imgs.slice(0,propCurrent).reduce(widthSum, 0)
|
|
@@ -33,6 +24,16 @@ export default ({images = [], className, onChange, onClick, ref, siblingOnly, cu
|
|
}
|
|
}
|
|
},[propCurrent, imgs])
|
|
},[propCurrent, imgs])
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (divRef.current){
|
|
|
|
+ const div = divRef.current
|
|
|
|
+
|
|
|
|
+ const totalWidth = imgs.reduce(widthSum, 0)
|
|
|
|
+ div.style.minWidth = totalWidth + 'px'
|
|
|
|
+ }
|
|
|
|
+ }, [divRef, imgs])
|
|
|
|
+
|
|
|
|
+
|
|
console.log('CURRENT', current)
|
|
console.log('CURRENT', current)
|
|
|
|
|
|
const scrollToCurrent = () => {
|
|
const scrollToCurrent = () => {
|