Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
良好的行为成为习惯
uni-app
提交
523a75b3
U
uni-app
项目概览
良好的行为成为习惯
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
523a75b3
编写于
5月 16, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
style: 重命名部分工具类
上级
55bdf71c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
72 addition
and
72 deletion
+72
-72
src/core/view/components/movable-view/index.vue
src/core/view/components/movable-view/index.vue
+7
-7
src/core/view/components/movable-view/utils.js
src/core/view/components/movable-view/utils.js
+31
-31
src/core/view/mixins/scroller/Friction.js
src/core/view/mixins/scroller/Friction.js
+8
-8
src/core/view/mixins/scroller/Scroll.js
src/core/view/mixins/scroller/Scroll.js
+12
-12
src/core/view/mixins/scroller/Scroller.js
src/core/view/mixins/scroller/Scroller.js
+2
-2
src/core/view/mixins/scroller/Spring.js
src/core/view/mixins/scroller/Spring.js
+11
-11
src/core/view/mixins/scroller/index.js
src/core/view/mixins/scroller/index.js
+1
-1
未找到文件。
src/core/view/components/movable-view/index.vue
浏览文件 @
523a75b3
...
...
@@ -7,9 +7,9 @@
<
script
>
import
touchtrack
from
'
uni-mixins/touchtrack
'
import
{
N
,
I
,
O
Decline
,
Friction
,
STD
}
from
'
./utils
'
var
requesting
=
false
...
...
@@ -205,10 +205,10 @@ export default {
this
.
_scale
=
1
this
.
_oldScale
=
1
this
.
_STD
=
new
O
(
1
,
9
*
Math
.
pow
(
this
.
dampingNumber
,
2
)
/
40
,
this
.
dampingNumber
)
this
.
_friction
=
new
I
(
1
,
this
.
frictionNumber
)
this
.
_declineX
=
new
N
()
this
.
_declineY
=
new
N
()
this
.
_STD
=
new
STD
(
1
,
9
*
Math
.
pow
(
this
.
dampingNumber
,
2
)
/
40
,
this
.
dampingNumber
)
this
.
_friction
=
new
Friction
(
1
,
this
.
frictionNumber
)
this
.
_declineX
=
new
Decline
()
this
.
_declineY
=
new
Decline
()
this
.
__touchInfo
=
{
historyX
:
[
0
,
0
],
historyY
:
[
0
,
0
],
...
...
src/core/view/components/movable-view/utils.js
浏览文件 @
523a75b3
...
...
@@ -6,18 +6,18 @@ function t (t, n) {
return
e
(
t
,
0
,
n
)
}
export
function
N
()
{
}
N
.
prototype
.
x
=
function
(
e
)
{
export
function
Decline
()
{
}
Decline
.
prototype
.
x
=
function
(
e
)
{
return
Math
.
sqrt
(
e
)
}
export
function
I
(
e
,
t
)
{
export
function
Friction
(
e
,
t
)
{
this
.
_m
=
e
this
.
_f
=
1
e3
*
t
this
.
_startTime
=
0
this
.
_v
=
0
}
I
.
prototype
.
setV
=
function
(
x
,
y
)
{
Friction
.
prototype
.
setV
=
function
(
x
,
y
)
{
var
n
=
Math
.
pow
(
Math
.
pow
(
x
,
2
)
+
Math
.
pow
(
y
,
2
),
0.5
)
this
.
_x_v
=
x
this
.
_y_v
=
y
...
...
@@ -27,11 +27,11 @@ I.prototype.setV = function (x, y) {
this
.
_lastDt
=
null
this
.
_startTime
=
(
new
Date
()).
getTime
()
}
I
.
prototype
.
setS
=
function
(
x
,
y
)
{
Friction
.
prototype
.
setS
=
function
(
x
,
y
)
{
this
.
_x_s
=
x
this
.
_y_s
=
y
}
I
.
prototype
.
s
=
function
(
t
)
{
Friction
.
prototype
.
s
=
function
(
t
)
{
if
(
undefined
===
t
)
{
t
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
...
...
@@ -52,7 +52,7 @@ I.prototype.s = function (t) {
y
}
}
I
.
prototype
.
ds
=
function
(
t
)
{
Friction
.
prototype
.
ds
=
function
(
t
)
{
if
(
undefined
===
t
)
{
t
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
...
...
@@ -64,30 +64,30 @@ I.prototype.ds = function (t) {
dy
:
this
.
_y_v
+
this
.
_y_a
*
t
}
}
I
.
prototype
.
delta
=
function
()
{
Friction
.
prototype
.
delta
=
function
()
{
return
{
x
:
-
1.5
*
Math
.
pow
(
this
.
_x_v
,
2
)
/
this
.
_x_a
||
0
,
y
:
-
1.5
*
Math
.
pow
(
this
.
_y_v
,
2
)
/
this
.
_y_a
||
0
}
}
I
.
prototype
.
dt
=
function
()
{
Friction
.
prototype
.
dt
=
function
()
{
return
-
this
.
_x_v
/
this
.
_x_a
}
I
.
prototype
.
done
=
function
()
{
Friction
.
prototype
.
done
=
function
()
{
var
t
=
e
(
this
.
s
().
x
,
this
.
_endPositionX
)
||
e
(
this
.
s
().
y
,
this
.
_endPositionY
)
||
this
.
_lastDt
===
this
.
_t
this
.
_lastDt
=
null
return
t
}
I
.
prototype
.
setEnd
=
function
(
x
,
y
)
{
Friction
.
prototype
.
setEnd
=
function
(
x
,
y
)
{
this
.
_endPositionX
=
x
this
.
_endPositionY
=
y
}
I
.
prototype
.
reconfigure
=
function
(
m
,
f
)
{
Friction
.
prototype
.
reconfigure
=
function
(
m
,
f
)
{
this
.
_m
=
m
this
.
_f
=
1
e3
*
f
}
export
function
R
(
m
,
k
,
c
)
{
export
function
Spring
(
m
,
k
,
c
)
{
this
.
_m
=
m
this
.
_k
=
k
this
.
_c
=
c
...
...
@@ -95,7 +95,7 @@ export function R (m, k, c) {
this
.
_endPosition
=
0
this
.
_startTime
=
0
}
R
.
prototype
.
_solve
=
function
(
e
,
t
)
{
Spring
.
prototype
.
_solve
=
function
(
e
,
t
)
{
var
n
=
this
.
_c
var
i
=
this
.
_m
var
r
=
this
.
_k
...
...
@@ -170,19 +170,19 @@ R.prototype._solve = function (e, t) {
}
}
}
R
.
prototype
.
x
=
function
(
e
)
{
Spring
.
prototype
.
x
=
function
(
e
)
{
if
(
undefined
===
e
)
{
e
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
return
this
.
_solution
?
this
.
_endPosition
+
this
.
_solution
.
x
(
e
)
:
0
}
R
.
prototype
.
dx
=
function
(
e
)
{
Spring
.
prototype
.
dx
=
function
(
e
)
{
if
(
undefined
===
e
)
{
e
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
return
this
.
_solution
?
this
.
_solution
.
dx
(
e
)
:
0
}
R
.
prototype
.
setEnd
=
function
(
e
,
n
,
i
)
{
Spring
.
prototype
.
setEnd
=
function
(
e
,
n
,
i
)
{
if
(
!
i
)
{
i
=
(
new
Date
()).
getTime
()
}
...
...
@@ -209,7 +209,7 @@ R.prototype.setEnd = function (e, n, i) {
}
}
}
R
.
prototype
.
snap
=
function
(
e
)
{
Spring
.
prototype
.
snap
=
function
(
e
)
{
this
.
_startTime
=
(
new
Date
()).
getTime
()
this
.
_endPosition
=
e
this
.
_solution
=
{
...
...
@@ -221,13 +221,13 @@ R.prototype.snap = function (e) {
}
}
}
R
.
prototype
.
done
=
function
(
n
)
{
Spring
.
prototype
.
done
=
function
(
n
)
{
if
(
!
n
)
{
n
=
(
new
Date
()).
getTime
()
}
return
e
(
this
.
x
(),
this
.
_endPosition
,
0.1
)
&&
t
(
this
.
dx
(),
0.1
)
}
R
.
prototype
.
reconfigure
=
function
(
m
,
t
,
c
)
{
Spring
.
prototype
.
reconfigure
=
function
(
m
,
t
,
c
)
{
this
.
_m
=
m
this
.
_k
=
t
this
.
_c
=
c
...
...
@@ -236,13 +236,13 @@ R.prototype.reconfigure = function (m, t, c) {
this
.
_startTime
=
(
new
Date
()).
getTime
()
}
}
R
.
prototype
.
springConstant
=
function
()
{
Spring
.
prototype
.
springConstant
=
function
()
{
return
this
.
_k
}
R
.
prototype
.
damping
=
function
()
{
Spring
.
prototype
.
damping
=
function
()
{
return
this
.
_c
}
R
.
prototype
.
configuration
=
function
()
{
Spring
.
prototype
.
configuration
=
function
()
{
function
e
(
e
,
t
)
{
e
.
reconfigure
(
1
,
t
,
e
.
damping
())
}
...
...
@@ -265,20 +265,20 @@ R.prototype.configuration = function () {
}]
}
export
function
O
(
e
,
t
,
n
)
{
this
.
_springX
=
new
R
(
e
,
t
,
n
)
this
.
_springY
=
new
R
(
e
,
t
,
n
)
this
.
_springScale
=
new
R
(
e
,
t
,
n
)
export
function
STD
(
e
,
t
,
n
)
{
this
.
_springX
=
new
Spring
(
e
,
t
,
n
)
this
.
_springY
=
new
Spring
(
e
,
t
,
n
)
this
.
_springScale
=
new
Spring
(
e
,
t
,
n
)
this
.
_startTime
=
0
}
O
.
prototype
.
setEnd
=
function
(
e
,
t
,
n
,
i
)
{
STD
.
prototype
.
setEnd
=
function
(
e
,
t
,
n
,
i
)
{
var
r
=
(
new
Date
()).
getTime
()
this
.
_springX
.
setEnd
(
e
,
i
,
r
)
this
.
_springY
.
setEnd
(
t
,
i
,
r
)
this
.
_springScale
.
setEnd
(
n
,
i
,
r
)
this
.
_startTime
=
r
}
O
.
prototype
.
x
=
function
()
{
STD
.
prototype
.
x
=
function
()
{
var
e
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
return
{
x
:
this
.
_springX
.
x
(
e
),
...
...
@@ -286,11 +286,11 @@ O.prototype.x = function () {
scale
:
this
.
_springScale
.
x
(
e
)
}
}
O
.
prototype
.
done
=
function
()
{
STD
.
prototype
.
done
=
function
()
{
var
e
=
(
new
Date
()).
getTime
()
return
this
.
_springX
.
done
(
e
)
&&
this
.
_springY
.
done
(
e
)
&&
this
.
_springScale
.
done
(
e
)
}
O
.
prototype
.
reconfigure
=
function
(
e
,
t
,
n
)
{
STD
.
prototype
.
reconfigure
=
function
(
e
,
t
,
n
)
{
this
.
_springX
.
reconfigure
(
e
,
t
,
n
)
this
.
_springY
.
reconfigure
(
e
,
t
,
n
)
this
.
_springScale
.
reconfigure
(
e
,
t
,
n
)
...
...
src/core/view/mixins/scroller/
R
.js
→
src/core/view/mixins/scroller/
Friction
.js
浏览文件 @
523a75b3
export
function
R
(
e
)
{
export
function
Friction
(
e
)
{
this
.
_drag
=
e
this
.
_dragLog
=
Math
.
log
(
e
)
this
.
_x
=
0
...
...
@@ -6,15 +6,15 @@ export function R (e) {
this
.
_startTime
=
0
}
R
.
prototype
.
set
=
function
(
e
,
t
)
{
Friction
.
prototype
.
set
=
function
(
e
,
t
)
{
this
.
_x
=
e
this
.
_v
=
t
this
.
_startTime
=
(
new
Date
()).
getTime
()
}
R
.
prototype
.
setVelocityByEnd
=
function
(
e
)
{
Friction
.
prototype
.
setVelocityByEnd
=
function
(
e
)
{
this
.
_v
=
(
e
-
this
.
_x
)
*
this
.
_dragLog
/
(
Math
.
pow
(
this
.
_drag
,
100
)
-
1
)
}
R
.
prototype
.
x
=
function
(
e
)
{
Friction
.
prototype
.
x
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
...
...
@@ -23,7 +23,7 @@ R.prototype.x = function (e) {
this
.
_dt
=
e
return
this
.
_x
+
this
.
_v
*
t
/
this
.
_dragLog
-
this
.
_v
/
this
.
_dragLog
}
R
.
prototype
.
dx
=
function
(
e
)
{
Friction
.
prototype
.
dx
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
...
...
@@ -32,17 +32,17 @@ R.prototype.dx = function (e) {
this
.
_dt
=
e
return
this
.
_v
*
t
}
R
.
prototype
.
done
=
function
()
{
Friction
.
prototype
.
done
=
function
()
{
return
Math
.
abs
(
this
.
dx
())
<
3
}
R
.
prototype
.
reconfigure
=
function
(
e
)
{
Friction
.
prototype
.
reconfigure
=
function
(
e
)
{
var
t
=
this
.
x
()
var
n
=
this
.
dx
()
this
.
_drag
=
e
this
.
_dragLog
=
Math
.
log
(
e
)
this
.
set
(
t
,
n
)
}
R
.
prototype
.
configuration
=
function
()
{
Friction
.
prototype
.
configuration
=
function
()
{
var
e
=
this
return
[{
label
:
'
Friction
'
,
...
...
src/core/view/mixins/scroller/
L
.js
→
src/core/view/mixins/scroller/
Scroll
.js
浏览文件 @
523a75b3
import
{
R
}
from
'
./R
'
import
{
S
}
from
'
./S
'
import
{
Friction
}
from
'
./Friction
'
import
{
S
pring
}
from
'
./Spring
'
export
function
L
(
extent
)
{
export
function
Scroll
(
extent
)
{
this
.
_extent
=
extent
this
.
_friction
=
new
R
(
0.01
)
this
.
_spring
=
new
S
(
1
,
90
,
20
)
this
.
_friction
=
new
Friction
(
0.01
)
this
.
_spring
=
new
S
pring
(
1
,
90
,
20
)
this
.
_startTime
=
0
this
.
_springing
=
false
this
.
_springOffset
=
0
}
L
.
prototype
.
snap
=
function
(
e
,
t
)
{
Scroll
.
prototype
.
snap
=
function
(
e
,
t
)
{
this
.
_springOffset
=
0
this
.
_springing
=
true
this
.
_spring
.
snap
(
e
)
this
.
_spring
.
setEnd
(
t
)
}
L
.
prototype
.
set
=
function
(
e
,
t
)
{
Scroll
.
prototype
.
set
=
function
(
e
,
t
)
{
this
.
_friction
.
set
(
e
,
t
)
if
(
e
>
0
&&
t
>=
0
)
{
this
.
_springOffset
=
0
...
...
@@ -35,7 +35,7 @@ L.prototype.set = function (e, t) {
}
this
.
_startTime
=
(
new
Date
()).
getTime
()
}
L
.
prototype
.
x
=
function
(
e
)
{
Scroll
.
prototype
.
x
=
function
(
e
)
{
if
(
!
this
.
_startTime
)
{
return
0
}
...
...
@@ -59,20 +59,20 @@ L.prototype.x = function (e) {
}
return
t
}
L
.
prototype
.
dx
=
function
(
e
)
{
Scroll
.
prototype
.
dx
=
function
(
e
)
{
var
t
=
0
t
=
this
.
_lastTime
===
e
?
this
.
_lastDx
:
this
.
_springing
?
this
.
_spring
.
dx
(
e
)
:
this
.
_friction
.
dx
(
e
)
this
.
_lastTime
=
e
this
.
_lastDx
=
t
return
t
}
L
.
prototype
.
done
=
function
()
{
Scroll
.
prototype
.
done
=
function
()
{
return
this
.
_springing
?
this
.
_spring
.
done
()
:
this
.
_friction
.
done
()
}
L
.
prototype
.
setVelocityByEnd
=
function
(
e
)
{
Scroll
.
prototype
.
setVelocityByEnd
=
function
(
e
)
{
this
.
_friction
.
setVelocityByEnd
(
e
)
}
L
.
prototype
.
configuration
=
function
()
{
Scroll
.
prototype
.
configuration
=
function
()
{
var
e
=
this
.
_friction
.
configuration
()
e
.
push
.
apply
(
e
,
this
.
_spring
.
configuration
())
return
e
...
...
src/core/view/mixins/scroller/
C
.js
→
src/core/view/mixins/scroller/
Scroller
.js
浏览文件 @
523a75b3
import
{
L
}
from
'
./L
'
import
{
Scroll
}
from
'
./Scroll
'
function
i
(
scroll
,
t
,
n
)
{
function
i
(
t
,
scroll
,
r
,
o
)
{
...
...
@@ -53,7 +53,7 @@ export function Scroller (element, options) {
}
this
.
_position
=
0
this
.
_scroll
=
new
L
(
this
.
_extent
)
this
.
_scroll
=
new
Scroll
(
this
.
_extent
)
this
.
_onTransitionEnd
=
this
.
onTransitionEnd
.
bind
(
this
)
this
.
updatePosition
()
}
...
...
src/core/view/mixins/scroller/S.js
→
src/core/view/mixins/scroller/S
pring
.js
浏览文件 @
523a75b3
...
...
@@ -6,7 +6,7 @@ function a (e, t) {
return
o
(
e
,
0
,
t
)
}
export
function
S
(
e
,
t
,
n
)
{
export
function
S
pring
(
e
,
t
,
n
)
{
this
.
_m
=
e
this
.
_k
=
t
this
.
_c
=
n
...
...
@@ -15,7 +15,7 @@ export function S (e, t, n) {
this
.
_startTime
=
0
}
S
.
prototype
.
_solve
=
function
(
e
,
t
)
{
S
pring
.
prototype
.
_solve
=
function
(
e
,
t
)
{
var
n
=
this
.
_c
var
i
=
this
.
_m
var
r
=
this
.
_k
...
...
@@ -95,19 +95,19 @@ S.prototype._solve = function (e, t) {
}
}
}
S
.
prototype
.
x
=
function
(
e
)
{
S
pring
.
prototype
.
x
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
return
this
.
_solution
?
this
.
_endPosition
+
this
.
_solution
.
x
(
e
)
:
0
}
S
.
prototype
.
dx
=
function
(
e
)
{
S
pring
.
prototype
.
dx
=
function
(
e
)
{
if
(
e
===
undefined
)
{
e
=
((
new
Date
()).
getTime
()
-
this
.
_startTime
)
/
1
e3
}
return
this
.
_solution
?
this
.
_solution
.
dx
(
e
)
:
0
}
S
.
prototype
.
setEnd
=
function
(
e
,
t
,
n
)
{
S
pring
.
prototype
.
setEnd
=
function
(
e
,
t
,
n
)
{
if
(
!
n
)
{
n
=
(
new
Date
()).
getTime
()
}
...
...
@@ -134,7 +134,7 @@ S.prototype.setEnd = function (e, t, n) {
}
}
}
S
.
prototype
.
snap
=
function
(
e
)
{
S
pring
.
prototype
.
snap
=
function
(
e
)
{
this
.
_startTime
=
(
new
Date
()).
getTime
()
this
.
_endPosition
=
e
this
.
_solution
=
{
...
...
@@ -146,13 +146,13 @@ S.prototype.snap = function (e) {
}
}
}
S
.
prototype
.
done
=
function
(
e
)
{
S
pring
.
prototype
.
done
=
function
(
e
)
{
if
(
!
e
)
{
e
=
(
new
Date
()).
getTime
()
}
return
o
(
this
.
x
(),
this
.
_endPosition
,
0.4
)
&&
a
(
this
.
dx
(),
0.4
)
}
S
.
prototype
.
reconfigure
=
function
(
e
,
t
,
n
)
{
S
pring
.
prototype
.
reconfigure
=
function
(
e
,
t
,
n
)
{
this
.
_m
=
e
this
.
_k
=
t
this
.
_c
=
n
...
...
@@ -161,13 +161,13 @@ S.prototype.reconfigure = function (e, t, n) {
this
.
_startTime
=
(
new
Date
()).
getTime
()
}
}
S
.
prototype
.
springConstant
=
function
()
{
S
pring
.
prototype
.
springConstant
=
function
()
{
return
this
.
_k
}
S
.
prototype
.
damping
=
function
()
{
S
pring
.
prototype
.
damping
=
function
()
{
return
this
.
_c
}
S
.
prototype
.
configuration
=
function
()
{
S
pring
.
prototype
.
configuration
=
function
()
{
function
e
(
e
,
t
)
{
e
.
reconfigure
(
1
,
t
,
e
.
damping
())
}
...
...
src/core/view/mixins/scroller/index.js
浏览文件 @
523a75b3
import
{
Scroller
}
from
'
./
C
'
import
{
Scroller
}
from
'
./
Scroller
'
export
default
{
methods
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录