Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-frontend
·
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
xuqi
10 years ago
Commit
e9d068986decee3ae62ab6031f371734552d9dad
1 parent
0d96ccf8
修正逛页面箭头歪掉的问题
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
51 deletions
mobile/public/js/saunter.js
mobile/public/js/saunter.js
View file @
e9d0689
...
...
@@ -38,7 +38,8 @@ exports.initAndroid = function() {
atContainer
,
thumbContainer
,
prodList
,
arrowPosition
;
thumbWidth
,
arrPos
;
//样式初始化
$
(
'#wrapper'
).
removeClass
(
'no-android'
);
...
...
@@ -113,28 +114,12 @@ exports.initAndroid = function() {
thumbContainer
=
atContainer
.
find
(
'.thumb-container'
);
prodList
=
atContainer
.
find
(
'.prod-list'
);
arrowPosition
=
function
(
element
,
index
)
{
//640为设计图尺寸,也就是font-size为40下的1rem,所以数值都参照640定
var
container
=
element
,
item
=
container
.
find
(
'li'
),
len
=
5
,
//获取一共多少li
midNum
=
Math
.
ceil
(
len
/
2
),
//获取中间li的index+1
documentFont
=
parseInt
(
$
(
"html"
).
css
(
"fontSize"
)),
//获取html的font-size
itemMarginRight
=
parseInt
(
item
.
css
(
'marginRight'
))
/
documentFont
*
40
,
//获取li的margin-right在640下数值
itemWidth
=
item
.
width
()
/
documentFont
*
40
,
//获取li的widtht在640下数值
surPlusValue
=
(
parseInt
(
container
.
css
(
'padding-left'
))
/
documentFont
*
40
-
itemMarginRight
)
/
2
,
//获取container的padding-left与itemMarginRight相减后除以2在640下数值
backgroundLeft
;
//container背景图片左偏移的位置
/**
* 320为640分辨率下中间值
* index-midNum为偏移中间li的数值
* (index - midNum) * (itemWidth + itemMarginRight)当前li偏移中间li的距离
* - surPlusValue 减去container的padding与li的margin-right差值的一半
* 除以40,由640下的px变为rem
*/
backgroundLeft
=
-
(
320
-
(
index
-
midNum
)
*
(
itemWidth
+
itemMarginRight
)
-
surPlusValue
)
/
40
+
'rem'
;
container
.
css
({
"backgroundPosition"
:
backgroundLeft
+
" bottom"
thumbWidth
=
thumbContainer
.
find
(
'li'
).
width
();
arrPos
=
function
(
$cur
)
{
var
left
=
$cur
.
offset
().
left
,
bgPos
=
-
winW
+
left
+
(
thumbWidth
/
2
)
+
'px'
;
thumbContainer
.
css
({
'backgroundPosition'
:
bgPos
+
' bottom'
});
};
...
...
@@ -147,7 +132,8 @@ exports.initAndroid = function() {
index
=
curItem
.
index
();
thumbContainer
.
find
(
'.thumb'
).
removeClass
(
'focus'
);
curItem
.
addClass
(
'focus'
);
arrowPosition
(
thumbContainer
,
index
+
1
);
arrPos
(
curItem
);
prodList
.
find
(
'.prod'
)
.
addClass
(
'hide'
)
...
...
@@ -196,7 +182,7 @@ exports.initOther = function() {
var
isInit
=
true
,
scrollToEl
=
document
.
querySelector
(
'#wrapper .article-type-three'
),
thumbs
,
arr
owPosition
;
arr
Pos
;
//头部作者信息样式计算(在描述信息过长时换行显示, 去除intro的padding-top)
var
$linkC
=
$
(
'#link-container'
),
...
...
@@ -289,34 +275,19 @@ exports.initOther = function() {
/**
* 计算小箭头位置函数
* @param
index(类型为number,调用函数li的index)
* @param
$cur 当前点击thumb
*/
thumbWidth
=
thumbContainer
.
find
(
'li'
).
width
();
arrowPosition
=
function
(
element
,
index
)
{
//640为设计图尺寸,也就是font-size为40下的1rem,所以数值都参照640定
var
container
=
element
,
item
=
container
.
find
(
'li'
),
len
=
5
,
//获取一共多少li
midNum
=
Math
.
ceil
(
len
/
2
),
//获取中间li的index+1
documentFont
=
parseInt
(
$
(
"html"
).
css
(
"fontSize"
)),
//获取html的font-size
itemMarginRight
=
parseInt
(
item
.
css
(
'marginRight'
))
/
documentFont
*
40
,
//获取li的margin-right在640下数值
itemWidth
=
thumbWidth
/
documentFont
*
40
,
//获取li的width在640下数值
surPlusValue
=
(
parseInt
(
container
.
css
(
'padding-left'
))
/
documentFont
*
40
-
itemMarginRight
)
/
2
,
//获取container的padding-left与itemMarginRight相减后除以2在640下数值
backgroundLeft
;
//container背景图片左偏移的位置
/**
* 320为640分辨率下中间值
* index-midNum为偏移中间li的数值
* (index - midNum) * (itemWidth + itemMarginRight)当前li偏移中间li的距离
* - surPlusValue 减去container的padding与li的margin-right差值的一半
* 除以40,由640下的px变为rem
*/
backgroundLeft
=
-
(
320
-
(
index
-
midNum
)
*
(
itemWidth
+
itemMarginRight
)
-
surPlusValue
)
/
40
+
'rem'
;
container
.
css
({
"backgroundPosition"
:
backgroundLeft
+
" bottom"
arrPos
=
function
(
$cur
)
{
var
left
=
$cur
.
offset
().
left
,
bgPos
=
-
winW
+
left
+
(
thumbWidth
/
2
)
+
'px'
;
thumbContainer
.
css
({
'backgroundPosition'
:
bgPos
+
' bottom'
});
fixedThumbContainer
.
css
({
'backgroundPosition'
:
bgPos
+
' bottom'
});
};
/**
* 分类的点击事件句柄
*/
...
...
@@ -337,8 +308,7 @@ exports.initOther = function() {
that
.
addClass
(
'focus'
);
other
.
addClass
(
'focus'
);
arrowPosition
(
thumbContainer
,
index
+
1
);
arrowPosition
(
fixedThumbContainer
,
index
+
1
);
arrPos
(
that
);
prodList
.
find
(
'.prod'
)
.
addClass
(
'hide'
)
...
...
Please
register
or
login
to post a comment