         pacmanLayer.setNeedsDisplay()
     }
     
-    fileprivate func update(dotLayer: CAShapeLayer, at index: Int) {
-        
-        guard progress >= 0 && progress <= CGFloat(pageCount - 1) else { return }
-        
-        let originRect = CGRect(x: 0, y: 0, width: dotDiameter, height: dotDiameter)
-        
-        let offset = abs(progress - CGFloat(index))
-        let x = offset > 1 ? 1 : offset
-        let insetDis = dotDiameter / 2 * (x * x - 2 * x + 1)
-        
-        let scaleRect = originRect.insetBy(dx: insetDis, dy: insetDis)
-        dotLayer.path = UIBezierPath(ovalIn: scaleRect).cgPath
-    }
-    
-    public func scroll(with scrollView: UIScrollView) {
-        
-        let total = scrollView.contentSize.width - scrollView.bounds.width
-        let offset = scrollView.contentOffset.x
-        
-        progress = offset / total * CGFloat(pageCount - 1)
-        
-        if lastContentOffsetX < scrollView.contentOffset.x {
-            pacmanLayer.direction = .right
-        } else if lastContentOffsetX > scrollView.contentOffset.x {
-            pacmanLayer.direction = .left
-        }
-        
-        let factor = min(1, max(0, abs(scrollView.contentOffset.x - lastContentOffsetX) / scrollView.frame.size.width))
-        
-        if case .changeWithDot = pacmanColorStyle, factor == 1 {
-            pacmanLayer.color = dotColors[Int(progress)]
-        }
-        
-        pacmanLayer.position.x = pacmanOriginX + pacmanDiameter / 2 + progress * (dotDiameter + dotInterval)
-        pacmanLayer.factor = factor
-        
-        for (index, layer) in dotLayers.enumerated() {
-            update(dotLayer: layer, at: index)
-        }
-    }
-    
     required public init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }

        setSubLayers()
    }
    
    fileprivate func setSubLayers() {
        
        let dotTotalWidth = dotDiameter * CGFloat(pageCount) + dotInterval * CGFloat(pageCount - 1)
        let dotOriginY = (frame.height - dotDiameter) / 2
        let dotOriginX = (frame.width - dotTotalWidth) / 2
        pacmanOriginX = dotOriginX + dotDiameter / 2 - pacmanDiameter / 2

        var dotFrame = CGRect(x: dotOriginX, y: dotOriginY, width: dotDiameter, height: dotDiameter)
        
        dotLayers = (0..<pageCount).map { index in

        case fixed(UIColor)
        case changeWithDot
    }

    public var dotColorStyle:    DotColorStyle    = .random(hue: .random, luminosity: .light)
    public var pacmanColorStyle: PacmanColorStyle = .changeWithDot
    
    public var pacmanDiameter:  CGFloat = 12
    public var dotDiameter:     CGFloat = 5
    public var dotInterval:     CGFloat = 0
    
    public var lastContentOffsetX: CGFloat = 0

    fileprivate var progress:      CGFloat = 0
    fileprivate var pacmanOriginX: CGFloat = 0
    
    fileprivate var dotLayers:   [CAShapeLayer] = []
    fileprivate var pacmanLayer: PacmanLayer!
    
    fileprivate var pageCount: Int!
    fileprivate var dotColors: [UIColor] = []
    
    public init(frame: CGRect, pageCount: Int) {
        super.init(frame: frame)
        
        self.pageCount = pageCount
