Premiers essais animation sortOrder

This commit is contained in:
Kongzibapt 2021-02-09 13:48:02 +01:00
parent 35daee4af9
commit a7464eca23
2 changed files with 40 additions and 12 deletions

View file

@ -24,6 +24,19 @@
font-size: 1.2vw;
cursor: pointer;
}
#sortOrder:hover {
animation: rotate180 2s forwards
}
.letter {
animation: rotate180 2s forwards;
}
@keyframes rotate180 {
0% {}
100% { transform: rotate3d(0,1,0, 180deg)}
}
#selectBlock{
background:#057B26;

View file

@ -6,7 +6,8 @@ class Sort extends Component {
constructor(props){
super(props)
this.state = {
unwound:false
unwound:false,
orderText: "a-z"
}
this.handleChangeSortType = this.handleChangeSortType.bind(this)
}
@ -17,8 +18,7 @@ class Sort extends Component {
}
componentDidMount() {
console.log("SORT MOUNTED")
this.setState({sortType: "name"}, () => {
this.setState({sortType: "name", orderText: "a-z"}, () => {
this.setOrderText()
})
}
@ -26,16 +26,26 @@ class Sort extends Component {
setOrderText() {
switch(this.state.sortType) {
case "name":
this.setState({
increasingText: "a->z",
decreasingText: "z->a"
})
if (this.props.lowToHigh) {
this.setState({
orderText: "a-z"
})
} else {
this.setState({
orderText: "z-a"
})
}
break;
case "price":
this.setState({
increasingText: "0->9",
decreasingText: "9->0"
})
if (this.props.lowToHigh) {
this.setState({
orderText: "0-9"
})
} else {
this.setState({
orderText: "9-0"
})
}
break;
default:
break;
@ -52,6 +62,9 @@ class Sort extends Component {
}
render() {
console.log(this.state.orderText)
console.log(this.state.orderText.split(""))
console.log(document.getElementById("sortOrder"))
return (
<div id="sortBox">
<div id="sortTxt">
@ -69,7 +82,9 @@ class Sort extends Component {
</div>
</div>
<p id="sortOrder" onClick={this.props.handleChangeSortOrder} hidden={this.props.orderIsHidden}>
{this.props.lowToHigh ? this.state.increasingText : this.state.decreasingText}
{this.state.orderText.split("").map((l) =>
<span className="letter">{l}</span>
)}
</p>
</div>
</div>