Comments (5)
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.
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.
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.
- See if both are highlighted if so by default MAX should be highlighted unless #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.
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.
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)
- Problem adding NHRangeSliderView via Storyboard HOT 1
- Remove upper and lower labels on thumbs HOT 2
- Problem accessing upperValue and lowerValue HOT 1
- Change color on lower and upper value HOT 1
- How to display images inplace of Thumbs? HOT 1
- how i can stop slider on needed value?
- Can you add the @objc attribute / objective c support? HOT 1
- Swift 4 HOT 5
- upperLable position
- How change value on slider?
- crashing if minimumValue is < maximumValue
- How Can i adjust the track height ?
- not support swift 4.0
- Property cannot be marked @IBInspectable because its type cannot be represented in Objective-C
- how to increase the lowerLabel and upperLabel width ?
- How to change the upper value and lower value text Dynamically?
- How to get the different slider delegate in the same view controller? HOT 1
- Property cannot be marked @IBInspectable because its type cannot be represented in Objective-C
- NHSliderView/NHRangeSlider.framework/NHRangeSlider' for architecture x86_64
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nhrangeslider.