Completely hide categories with no emojis
parent
1a3f2525b9
commit
dba6d60a08
|
@ -56,12 +56,11 @@ export default class Category extends React.Component {
|
||||||
var { height: labelHeight } = this.label.getBoundingClientRect()
|
var { height: labelHeight } = this.label.getBoundingClientRect()
|
||||||
|
|
||||||
this.top = top - parentTop + this.parent.scrollTop
|
this.top = top - parentTop + this.parent.scrollTop
|
||||||
|
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
this.maxMargin = 0
|
this.maxMargin = 0
|
||||||
} else if (height > labelHeight) {
|
|
||||||
this.maxMargin = height - labelHeight
|
|
||||||
} else {
|
} else {
|
||||||
this.maxMargin = 1
|
this.maxMargin = height - labelHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,11 +80,8 @@ export default class Category extends React.Component {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
getEmojis() {
|
||||||
var { name, emojis, perLine, hasStickyPosition, emojiProps } = this.props,
|
var { name, emojis, perLine } = this.props
|
||||||
labelStyles = {},
|
|
||||||
labelSpanStyles = {},
|
|
||||||
containerStyles = {}
|
|
||||||
|
|
||||||
if (name == 'Recent') {
|
if (name == 'Recent') {
|
||||||
let frequentlyUsed = frequently.get(perLine * 4)
|
let frequentlyUsed = frequently.get(perLine * 4)
|
||||||
|
@ -97,11 +93,31 @@ export default class Category extends React.Component {
|
||||||
|
|
||||||
if (emojis) {
|
if (emojis) {
|
||||||
emojis = emojis.slice(0)
|
emojis = emojis.slice(0)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
return emojis
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDisplay(display) {
|
||||||
|
var emojis = this.getEmojis()
|
||||||
|
|
||||||
|
if (!display && !emojis) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.container.style.display = display
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
var { name, hasStickyPosition, emojiProps } = this.props,
|
||||||
|
emojis = this.getEmojis(),
|
||||||
|
labelStyles = {},
|
||||||
|
labelSpanStyles = {},
|
||||||
|
containerStyles = {}
|
||||||
|
|
||||||
|
if (!emojis) {
|
||||||
containerStyles = {
|
containerStyles = {
|
||||||
height: 1,
|
display: 'none',
|
||||||
overflow: 'hidden',
|
|
||||||
marginBottom: '-1px',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import '../vendor/raf-polyfill'
|
import '../vendor/raf-polyfill'
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
|
||||||
import data from '../../data'
|
import data from '../../data'
|
||||||
|
|
||||||
import {store, frequently} from '../utils'
|
import {store, frequently} from '../utils'
|
||||||
|
@ -90,13 +89,20 @@ export default class Picker extends React.Component {
|
||||||
var target = this.refs.scroll,
|
var target = this.refs.scroll,
|
||||||
scrollTop = target.scrollTop,
|
scrollTop = target.scrollTop,
|
||||||
scrollingDown = scrollTop > (this.scrollTop || 0),
|
scrollingDown = scrollTop > (this.scrollTop || 0),
|
||||||
activeCategory = null
|
activeCategory = null,
|
||||||
|
minTop = 0
|
||||||
|
|
||||||
for (let i = 0, l = CATEGORIES.length; i < l; i++) {
|
for (let i = 0, l = CATEGORIES.length; i < l; i++) {
|
||||||
let ii = scrollingDown ? (CATEGORIES.length - 1 - i) : i,
|
let ii = scrollingDown ? (CATEGORIES.length - 1 - i) : i,
|
||||||
category = CATEGORIES[ii],
|
category = CATEGORIES[ii],
|
||||||
component = this.refs[`category-${ii}`]
|
component = this.refs[`category-${ii}`]
|
||||||
|
|
||||||
|
if (!minTop || component.top < minTop) {
|
||||||
|
if (component.top > 0) {
|
||||||
|
minTop = component.top
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (component) {
|
if (component) {
|
||||||
let active = component.handleScroll(scrollTop)
|
let active = component.handleScroll(scrollTop)
|
||||||
if (active && !activeCategory) {
|
if (active && !activeCategory) {
|
||||||
|
@ -106,6 +112,10 @@ export default class Picker extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scrollTop < minTop) {
|
||||||
|
activeCategory = RECENT_CATEGORY
|
||||||
|
}
|
||||||
|
|
||||||
if (activeCategory) {
|
if (activeCategory) {
|
||||||
let { anchors } = this.refs,
|
let { anchors } = this.refs,
|
||||||
{ name: categoryName } = activeCategory
|
{ name: categoryName } = activeCategory
|
||||||
|
@ -125,10 +135,8 @@ export default class Picker extends React.Component {
|
||||||
let component = this.refs[`category-${i}`]
|
let component = this.refs[`category-${i}`]
|
||||||
|
|
||||||
if (component && component.props.name != 'Search') {
|
if (component && component.props.name != 'Search') {
|
||||||
let DOMNode = ReactDOM.findDOMNode(component),
|
let display = emojis ? 'none' : null
|
||||||
display = emojis ? 'none' : null
|
component.updateDisplay(display)
|
||||||
|
|
||||||
if (DOMNode) DOMNode.style.display = display
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue