yonat / MultiSlider

UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.
MIT License
494 stars 113 forks source link

Issue when placing MultiSlider in tableview cell #19

Closed WedgeSparda closed 5 years ago

WedgeSparda commented 5 years ago

Hi.

I have an issue with this slider. I'm using several MultiSliders in a tableview but when I try to scroll it, If my pan gesture starts on one of the MultiSliders, the gesture is captured by the slider and scroll doesn't work until I start panning from outside the sliders.

Is there any possibility to improve the slider to propagate the pan to superview if we needed?

Thanks.

yonat commented 5 years ago

Setting cancelsTouchesInView will probably solve it. If it works for you, feel free to submit a PR. If not, please write a minimal app the reproduces this problem, so I can check it.

WedgeSparda commented 5 years ago

I downloaded the source code and modified the setupPanGesture method like this:

    private func setupPanGesture() {
        addConstrainedSubview(panGestureView)
        for edge: NSLayoutConstraint.Attribute in [.top, .bottom, .left, .right] {
            constrain(panGestureView, at: edge, diff: -edge.inwardSign * margin)
        }
        let panGesture = UIPanGestureRecognizer(target: self, action: #selector(didDrag(_:)))
        panGesture.cancelsTouchesInView = false
        panGestureView.addGestureRecognizer(panGesture)
    }

But didn't work :(

So I created this test project so you can see what happens. As you can see, if scroll drag starts on one of the labels, it works fine, but if starts on one of the multisliders, then scroll doesn't happen.

Hope you can point me in the right direction.

Thanks.

BTW: Great job with this library.

yonat commented 5 years ago

Thanks for test project, it helped me solve this!