     }
     
     func scrollToIndex(targetIndex: Int) {
+        // 小动画
+        setAnimation()
+        collectionView?.layer.add(animation, forKey: nil)
+        
         if targetIndex >= totalItemsCount {
             if infiniteLoop {
                 let index = targetIndex % totalItemsCount

            }
            return
        }
        collectionView?.scrollToItem(at: NSIndexPath(item: targetIndex, section: 0) as IndexPath, at: .right, animated: true)
    }
    
    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        invalidateTimer()
    }
    

    }
    
    func setupTimer() {
        let timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(automaticScroll), userInfo: nil, repeats: true)
        RunLoop.main.add(timer, forMode: .commonModes)
        self.timer = timer
    }
