Git Product home page Git Product logo

Comments (5)

felixdkatt avatar felixdkatt commented on August 10, 2024

I noticed this is exactly the same issue that was closed AFTER i wrote it. However sometimes you want the sliders to touch with no gap. to indicate a single value.
Say u wanted to display range of money but you also wanted to allow a single value.
Can I achieve this with a gap greater than 0?
example
you want to search for a product that is a range is $0 - $100
but then you want to do another search for a product thats exactly $50
with the same control.
Can you still do that with say a gap of 1. Without it saying $50 - $51?

from nhrangeslider.

felixdkatt avatar felixdkatt commented on August 10, 2024

I tried gapBetweenThumbs = 1.0 and it still displayed the same problem.
Are you using gesture touches to slide each button?
If so maybe you can check the tap or drag and make sure that the number of objects below the touch is always 1 if its greater than 1 then only drag the max not both ?
Hope that makes sense.

from nhrangeslider.

felixdkatt avatar felixdkatt commented on August 10, 2024

I think i see the issue.
In the code below it can set both to highlighted even though you really only want to move one of them.

Since they're both highlighted the continueTracking method will move both depending on the direction of the drag instead of just one.

You could do 2 checks.

  1. See if both are highlighted if so by default MAX should be highlighted unless #2
  2. if MAX is highlighted but is at its MAX value then highlight MIN thumb.

override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
previouslocation = touch.location(in: self)

    // set highlighted positions for lower and upper thumbs
    if lowerThumbLayer.frame.contains(previouslocation) {
        lowerThumbLayer.highlighted = true
    }
    
    if upperThumbLayer.frame.contains(previouslocation) {
        upperThumbLayer.highlighted = true
    }

///NEW
if upperThumbLayer.highlighted && lowerThumbLayer.highlighted{
if upperThumbLayer.maxPosition == maxValue {
upperThumbLayer.highlighted = false
}else{
lowerThumbLayer.highlighted = false
}
}
/////////
return lowerThumbLayer.highlighted || upperThumbLayer.highlighted
}

from nhrangeslider.

felixdkatt avatar felixdkatt commented on August 10, 2024

I tried it locally and verified this fixes the issue

override open func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
previouslocation = touch.location(in: self)

    // set highlighted positions for lower and upper thumbs
    if lowerThumbLayer.frame.contains(previouslocation) {
        lowerThumbLayer.highlighted = true
    }
    
    if upperThumbLayer.frame.contains(previouslocation) {
        upperThumbLayer.highlighted = true
    }
	
	if upperThumbLayer.highlighted && lowerThumbLayer.highlighted{
		if upperValue == maximumValue {
			upperThumbLayer.highlighted = false
		}else{
			lowerThumbLayer.highlighted = false
		}
	}
    
    return lowerThumbLayer.highlighted || upperThumbLayer.highlighted
}

from nhrangeslider.

felixdkatt avatar felixdkatt commented on August 10, 2024

Sorry I didn't do a pull request let me know if you'd like me to or if you just want to change it yourself.

from nhrangeslider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.