Skip to content
This repository was archived by the owner on May 7, 2022. It is now read-only.

Commit a35b634

Browse files
committed
动画切换优化
1 parent c4cc1ee commit a35b634

File tree

16 files changed

+54
-59
lines changed

16 files changed

+54
-59
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
<meta name="format-detection" content="telephone=no">
1010

1111
<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
12+
<link rel="stylesheet" href="./build/styles.css">
1213
</head>
1314
<body>
1415
<div id="root"></div>
1516
</body>
1617
<script>
1718
document.body.addEventListener('touchstart', function () { });
1819
</script>
20+
<script src="./build/manifest.js"></script>
21+
<script src="./build/vendor.js"></script>
1922
<script src="./build/app.js"></script>
2023
</html>

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"expect": "^1.12.0",
4343
"express": "^4.15.2",
4444
"extract-text-webpack-plugin": "^2.1.0",
45-
"fastclick": "^1.0.6",
4645
"file-loader": "^0.8.4",
4746
"http-proxy-middleware": "^0.17.4",
4847
"image-webpack-loader": "^3.1.0",
@@ -52,7 +51,6 @@
5251
"jest-runtime": "^19.0.2",
5352
"less": "^2.7.1",
5453
"less-loader": "^2.2.2",
55-
"nuka-carousel": "^2.0.1",
5654
"open": "0.0.5",
5755
"postcss-loader": "^0.7.0",
5856
"precss": "^1.4.0",
@@ -65,11 +63,12 @@
6563
"redux-thunk": "^2.2.0",
6664
"style-loader": "^0.13.0",
6765
"url-loader": "^0.5.6",
68-
"webpack": "^2.2.1",
66+
"webpack": "^2.5.1",
6967
"webpack-dev-middleware": "^1.2.0",
7068
"webpack-hot-middleware": "^2.17.1"
7169
},
7270
"dependencies": {
71+
"fastclick": "^1.0.6",
7372
"history": "^4.6.1",
7473
"prop-types": "^15.5.4",
7574
"react": "^15.5.4",

public/fenxi.png

15.3 KB
Loading

public/index.gif

-1.09 MB
Binary file not shown.

public/index.png

-63.6 KB
Binary file not shown.

public/store.gif

184 KB
Loading

src/app.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ a {
3333

3434
/*路由切换动画——改变透明度*/
3535
.normal-enter {
36-
opacity: 1;
36+
opacity: 0;
3737
z-index: 10000;
3838
}
3939

4040
.normal-enter.normal-enter-active {
4141
opacity: 1;
42-
transition: opacity 0.4s ease-in;
42+
transition: all 0.4s ease-in;
4343
}
4444

4545
.normal-leave {
@@ -54,7 +54,7 @@ a {
5454
.normal-leave.normal-leave-active {
5555
opacity: 1;
5656
transform: translateX(100%);
57-
transition: opacity 4s ease-out;
57+
transition: all .4s ease-out;
5858
}
5959

6060
/*路由切换动画——左移动*/

src/appContainer.js

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,27 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import { connect } from 'react-redux';
33
import './app.css'
44
import { Route, HashRouter as Router } from 'react-router-dom'
55
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup';
66

77
/* application components */
8-
// 首页组件不需要异步加载
98
import HomeContainer from './containers/Home/homeContainer';
10-
// bundle模型用来异步加载组件
11-
import Bundle from './bundle';
12-
// 导入search组件,需要在路径前面加上 bundle-loader?lazy!
139
import SearchContainer from './containers/Search/searchContainer';
14-
15-
import BookListContainer from './containers/BookList/bookListContainer'
16-
17-
// 异步加载search组件
18-
// const Search = () => (
19-
// <Bundle load={SearchContainer}>
20-
// {(Search) => <Search />}
21-
// </Bundle>
22-
// )
23-
24-
// const BookList = () => (
25-
// <Bundle load={BookListContainer}>
26-
// {(BookList) => <BookList />}
27-
// </Bundle>
28-
// )
10+
import BookListContainer from './containers/BookList/bookListContainer';
2911

3012
@connect (state => state)
3113
export default class AppContainer extends React.Component {
32-
33-
componentDidMount() {
34-
// preloads the rest
35-
// Search(() => {})
36-
}
3714

3815
render() {
39-
console.log('appContainer: ', this.props)
4016
return (
41-
<Router>
17+
<Router history={history}>
4218
<Route render={({ location }) => {
19+
console.log('location.pathname: ', location)
4320
let cls = 'normal'
4421
if (location.pathname === '/search') {
4522
cls = 'left'
23+
} else if (location.pathname.indexOf('bookList') > -1) {
24+
cls = 'left'
4625
}
4726
return(
4827
<CSSTransitionGroup

src/components/Home/bookList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class BookList extends React.Component {
2020
<Link to={`/bookList/${_id}`} data-id={_id} className="home-book-list">
2121
<div className="book-img">
2222
<span className="book-index">{index}</span>
23-
<img className="" src={imgUrl} />
23+
<img className="" src="" alt="图片" />
2424
</div>
2525
<div className="book-contain">
2626
<p className="book-title textOverflow-hidden">{title}</p>

src/components/Home/header.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export class Header extends React.Component {
1515
}
1616

1717
render() {
18-
const {title, imgUrl, linkTo, bgColor, match} = this.props
18+
const {title, imgUrl, linkTo, bgColor} = this.props
1919
//提供4个接口参数给container做设置,可以不传参。
2020
return (
2121
<header className='header' style={bgColor}>
2222
{title}
23-
<Link to={`${match.url + linkTo}`} className="a_link" >
23+
<Link to={linkTo} className="a_link">
2424
<img src={imgUrl} className="a_img" />
2525
</Link>
2626
</header>
@@ -33,6 +33,5 @@ Header.propTypes = {
3333
title: PropTypes.string.isRequired,
3434
imgUrl: PropTypes.string.isRequired,
3535
linkTo: PropTypes.string.isRequired,
36-
bgColor: PropTypes.object.isRequired,
37-
match: PropTypes.object.isRequired
36+
bgColor: PropTypes.object.isRequired
3837
}

0 commit comments

Comments
 (0)