Toggle navigation
Toggle navigation
This project
Loading...
Sign in
mobile
/
YH_RNComponent
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
yoho-js001
8 years ago
Commit
1d0422e277c1a8727bd581b5d20ef66d37e052ce
1 parent
22742ca5
修复index不准的问题。 reviewed by 凯总。
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
14 deletions
js/blk/components/brand/Brand.js
js/blk/components/brand/IndexListView.js
js/blk/components/brand/Brand.js
View file @
1d0422e
...
...
@@ -53,7 +53,7 @@ export default class Brand extends Component {
if
(
item
)
{
if
(
!
item
.
y
)
{
this
.
needScrollSection
=
sectionID
;
item
.
y
=
Scroll
Y
(
sectionID
,
this
.
sectionData
);
item
.
y
=
Scroll
Count
(
sectionID
,
this
.
sectionData
);
this
.
props
.
setBrandData
&&
this
.
props
.
setBrandData
(
this
.
sectionDataKey
,
this
.
props
.
selectedChannelId
);
this
.
listView
&&
this
.
listView
.
scrollTo
({
x
:
0
,
y
:
item
.
y
,
animated
:
false
});
}
else
{
...
...
js/blk/components/brand/IndexListView.js
View file @
1d0422e
...
...
@@ -4,6 +4,7 @@ import React from 'react';
import
ReactNative
from
'react-native'
;
import
{
isEmptyObject
}
from
'../../utils/Utils'
;
import
Immutable
,
{
Map
}
from
'immutable'
;
import
*
as
_
from
'lodash'
;
const
{
View
,
...
...
@@ -19,6 +20,10 @@ export default class IndexListView extends React.Component {
constructor
(
props
)
{
super
(
props
);
this
.
onTouchMove
=
this
.
onTouchMove
.
bind
(
this
);
this
.
state
=
{
list
:[]
};
}
shouldComponentUpdate
(
nextProps
){
...
...
@@ -31,16 +36,26 @@ export default class IndexListView extends React.Component {
onTouchMove
(
e
)
{
let
{
dataSource
}
=
this
.
props
;
let
Y
=
e
.
nativeEvent
.
pageY
-
Math
.
ceil
((
viewHeight
-
dataSource
.
length
*
(
itemHeight
+
2
))
/
2
)
-
8
-
28
;
var
index
=
Math
.
ceil
(
Y
/
(
itemHeight
+
2
))
-
1
;
if
(
dataSource
.
length
-
index
<
4
)
{
return
;
}
let
sectionID
=
dataSource
[
index
];
if
(
!
sectionID
)
{
return
;
let
Y
=
e
.
nativeEvent
.
pageY
;
for
(
var
i
=
0
;
i
<
this
.
state
.
list
.
length
;
i
++
)
{
if
(
Y
>
this
.
state
.
list
[
i
].
y
&&
Y
<
this
.
state
.
list
[
i
].
y
+
12
)
{
let
name
=
this
.
state
.
list
[
i
].
name
;
if
(
name
==
'0'
)
{
name
=
'0-9'
;
}
console
.
log
(
name
);
this
.
props
.
onLetterPress
&&
this
.
props
.
onLetterPress
(
i
,
name
);
break
;
}
}
this
.
props
.
onLetterPress
&&
this
.
props
.
onLetterPress
(
index
,
sectionID
);
}
onLayout
(
name
,
e
)
{
let
{
y
}
=
e
.
nativeEvent
.
layout
;
let
Y
=
{
'name'
:
name
,
'y'
:
y
}
let
list
=
this
.
state
.
list
;
list
.
push
(
Y
);
this
.
setState
(
list
)
}
render
()
{
...
...
@@ -58,7 +73,9 @@ export default class IndexListView extends React.Component {
if
(
name
==
'0-9'
)
{
name
=
'0'
;
}
keyData
.
push
(
<
Text
key
=
{
i
}
style
=
{
styles
.
text
}
>
{
name
}
<
/Text>
)
;
keyData
.
push
(
<
View
key
=
{
i
}
style
=
{
styles
.
TV
}
onLayout
=
{
this
.
onLayout
.
bind
(
this
,
name
)}
><
Text
style
=
{
styles
.
text
}
>
{
name
}
<
/Text></
View
>
);
}
return
(
...
...
@@ -71,7 +88,7 @@ export default class IndexListView extends React.Component {
let
{
width
,
height
}
=
Dimensions
.
get
(
'window'
);
let
itemHeight
=
12
;
let
viewHeight
=
height
-
112
;
let
viewHeight
=
height
-
64
;
let
styles
=
StyleSheet
.
create
({
container
:
{
...
...
@@ -80,17 +97,24 @@ let styles = StyleSheet.create({
height
:
viewHeight
,
bottom
:
1
,
right
:
1
,
backgroundColor
:
'r
gba(255,255,255,0.2)
'
,
backgroundColor
:
'r
ed
'
,
alignItems
:
'center'
,
justifyContent
:
'center'
,
},
TV
:
{
width
:
12
,
height
:
12
,
backgroundColor
:
'transparent'
,
marginTop
:
2
,
justifyContent
:
'center'
,
},
text
:
{
justifyContent
:
'center'
,
textAlign
:
'center'
,
fontSize
:
11
,
color
:
'black'
,
backgroundColor
:
'transparent'
,
marginTop
:
2
,
fontWeight
:
'bold'
,
},
image
:
{
...
...
Please
register
or
login
to post a comment