Unselect categories when searching

release
Etienne Lemay 2017-05-27 13:36:41 -04:00
parent 1e87212374
commit 7d014966e6
1 changed files with 31 additions and 26 deletions

View File

@ -198,43 +198,48 @@ export default class Picker extends React.Component {
return
}
var target = this.refs.scroll,
scrollTop = target.scrollTop,
scrollingDown = scrollTop > (this.scrollTop || 0),
activeCategory = null,
minTop = 0
let activeCategory = null
for (let i = 0, l = this.categories.length; i < l; i++) {
let ii = scrollingDown ? (this.categories.length - 1 - i) : i,
category = this.categories[ii],
component = this.refs[`category-${ii}`]
if (SEARCH_CATEGORY.emojis) {
activeCategory = SEARCH_CATEGORY
} else {
var target = this.refs.scroll,
scrollTop = target.scrollTop,
scrollingDown = scrollTop > (this.scrollTop || 0),
minTop = 0
if (component) {
let active = component.handleScroll(scrollTop)
for (let i = 0, l = this.categories.length; i < l; i++) {
let ii = scrollingDown ? (this.categories.length - 1 - i) : i,
category = this.categories[ii],
component = this.refs[`category-${ii}`]
if (!minTop || component.top < minTop) {
if (component.top > 0) {
minTop = component.top
if (component) {
let active = component.handleScroll(scrollTop)
if (!minTop || component.top < minTop) {
if (component.top > 0) {
minTop = component.top
}
}
if (active && !activeCategory) {
activeCategory = category
}
}
}
if (scrollTop < minTop) {
for (let category of this.categories) {
if (category.anchor === false) { continue }
if (active && !activeCategory) {
activeCategory = category
break
}
} else if (scrollTop + this.clientHeight >= this.scrollHeight) {
activeCategory = this.categories[this.categories.length - 1]
}
}
if (scrollTop < minTop) {
for (let category of this.categories) {
if (category.anchor === false) { continue }
activeCategory = category
break
}
} else if (scrollTop + this.clientHeight >= this.scrollHeight) {
activeCategory = this.categories[this.categories.length - 1]
}
if (activeCategory) {
let { anchors } = this.refs,
{ name: categoryName } = activeCategory