Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
835e7645
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
835e7645
编写于
8月 22, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* more windows tests for the physical mouse wheel classifier;
* adopt the classifier;
上级
9c46f948
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
327 addition
and
27 deletion
+327
-27
src/vs/base/browser/ui/scrollbar/scrollableElement.ts
src/vs/base/browser/ui/scrollbar/scrollableElement.ts
+9
-24
src/vs/base/test/browser/ui/scrollbar/scrollableElement.test.ts
.../base/test/browser/ui/scrollbar/scrollableElement.test.ts
+318
-3
未找到文件。
src/vs/base/browser/ui/scrollbar/scrollableElement.ts
浏览文件 @
835e7645
...
...
@@ -23,8 +23,6 @@ import Event, { Emitter } from 'vs/base/common/event';
const
HIDE_TIMEOUT
=
500
;
const
SCROLL_WHEEL_SENSITIVITY
=
50
;
const
SCROLL_WHEEL_SMOOTH_SCROLL_ENABLED
=
true
;
const
SCROLL_WHEEL_SMOOTH_SCROLL_MS_TIME_TRESHOLD
=
4
;
const
SCROLL_WHEEL_SMOOTH_SCROLL_PX_SPACE_TRESHOLD
=
7
;
export
interface
IOverviewRulerLayoutInfo
{
parent
:
HTMLElement
;
...
...
@@ -47,6 +45,8 @@ class MouseWheelClassifierItem {
export
class
MouseWheelClassifier
{
public
static
INSTANCE
=
new
MouseWheelClassifier
();
private
readonly
_capacity
:
number
;
private
_memory
:
MouseWheelClassifierItem
[];
private
_front
:
number
;
...
...
@@ -59,8 +59,6 @@ export class MouseWheelClassifier {
this
.
_rear
=
-
1
;
}
// private isE
public
isPhysicalMouseWheel
():
boolean
{
if
(
this
.
_front
===
-
1
&&
this
.
_rear
===
-
1
)
{
// no elements
...
...
@@ -104,15 +102,7 @@ export class MouseWheelClassifier {
this
.
_front
=
(
this
.
_front
+
1
)
%
this
.
_capacity
;
}
this
.
_memory
[
this
.
_rear
]
=
item
;
// if ()
// if (this._front === this._rea)
}
// this._lastIndex = (this._lastIndex + 1) % this._capacity;
// if (this._firstIndex === this._lastIndex) {
// this._firstIndex = (this._firstIndex + 1) % this._capacity;
// }
// this._memory[this._lastIndex] = item;
}
/**
...
...
@@ -167,8 +157,6 @@ export abstract class AbstractScrollableElement extends Widget {
private
_mouseWheelToDispose
:
IDisposable
[];
private
_previousMouseWheelEventTime
:
number
=
0
;
private
_isDragging
:
boolean
;
private
_mouseIsOver
:
boolean
;
...
...
@@ -189,8 +177,6 @@ export abstract class AbstractScrollableElement extends Widget {
this
.
_onScroll
.
fire
(
e
);
}));
// this._scrollable = this._register(new DelegateScrollable(scrollable, () => this._onScroll()));
let
scrollbarHost
:
ScrollbarHost
=
{
onMouseWheel
:
(
mouseWheelEvent
:
StandardMouseWheelEvent
)
=>
this
.
_onMouseWheel
(
mouseWheelEvent
),
onDragStart
:
()
=>
this
.
_onDragStart
(),
...
...
@@ -334,7 +320,11 @@ export abstract class AbstractScrollableElement extends Widget {
}
private
_onMouseWheel
(
e
:
StandardMouseWheelEvent
):
void
{
const
currentMouseWheelEventTime
=
Date
.
now
();
const
classifier
=
MouseWheelClassifier
.
INSTANCE
;
if
(
SCROLL_WHEEL_SMOOTH_SCROLL_ENABLED
)
{
classifier
.
accept
(
Date
.
now
(),
e
.
deltaX
,
e
.
deltaY
);
}
// console.log(`${Date.now()}, ${e.deltaY}, ${e.deltaX}`);
...
...
@@ -380,14 +370,11 @@ export abstract class AbstractScrollableElement extends Widget {
desiredScrollPosition
=
this
.
_scrollable
.
validateScrollPosition
(
desiredScrollPosition
);
if
(
futureScrollPosition
.
scrollLeft
!==
desiredScrollPosition
.
scrollLeft
||
futureScrollPosition
.
scrollTop
!==
desiredScrollPosition
.
scrollTop
)
{
// TODO@smooth: [MUST] detect if the source of the `mousewheel` is intertial or not and use setScrollPositionSmooth
const
deltaT
=
currentMouseWheelEventTime
-
this
.
_previousMouseWheelEventTime
;
const
canPerformSmoothScroll
=
(
SCROLL_WHEEL_SMOOTH_SCROLL_ENABLED
&&
this
.
_options
.
mouseWheelSmoothScroll
// If either |∆x|, |∆y| or ∆t are too small then do not apply smooth scroll animation, because in that case the input source must be a touchpad or something similar.
&&
Math
.
max
(
Math
.
abs
(
deltaX
),
Math
.
abs
(
deltaY
))
*
SCROLL_WHEEL_SENSITIVITY
>
SCROLL_WHEEL_SMOOTH_SCROLL_PX_SPACE_TRESHOLD
&&
deltaT
>
SCROLL_WHEEL_SMOOTH_SCROLL_MS_TIME_TRESHOLD
&&
classifier
.
isPhysicalMouseWheel
()
);
if
(
canPerformSmoothScroll
)
{
...
...
@@ -403,8 +390,6 @@ export abstract class AbstractScrollableElement extends Widget {
e
.
preventDefault
();
e
.
stopPropagation
();
}
this
.
_previousMouseWheelEventTime
=
currentMouseWheelEventTime
;
}
private
_onDidScroll
(
e
:
ScrollEvent
):
void
{
...
...
src/vs/base/test/browser/ui/scrollbar/scrollableElement.test.ts
浏览文件 @
835e7645
...
...
@@ -11,7 +11,7 @@ export type IMouseWheelEvent = [number, number, number];
suite
(
'
MouseWheelClassifier
'
,
()
=>
{
test
(
'
Apple Magic Mouse
'
,
()
=>
{
test
(
'
OSX -
Apple Magic Mouse
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503409622410
,
-
0.025
,
0
],
[
1503409622435
,
-
0.175
,
0
],
...
...
@@ -58,7 +58,7 @@ suite('MouseWheelClassifier', () => {
}
});
test
(
'
Apple Touch Pad
'
,
()
=>
{
test
(
'
OSX -
Apple Touch Pad
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503409780792
,
0.025
,
0
],
[
1503409780808
,
0.175
,
-
0.025
],
...
...
@@ -147,7 +147,7 @@ suite('MouseWheelClassifier', () => {
}
});
test
(
'
Apple
Physical Mouse Wheel
'
,
()
=>
{
test
(
'
OSX - Razer
Physical Mouse Wheel
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503409880776
,
-
1
,
0
],
[
1503409880791
,
-
1
,
0
],
...
...
@@ -207,4 +207,319 @@ suite('MouseWheelClassifier', () => {
}
});
test
(
'
Windows - Microsoft Arc Touch
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503418316909
,
-
2
,
0
],
[
1503418316985
,
-
2
,
0
],
[
1503418316988
,
-
4
,
0
],
[
1503418317034
,
-
2
,
0
],
[
1503418317071
,
-
2
,
0
],
[
1503418317094
,
-
2
,
0
],
[
1503418317133
,
-
2
,
0
],
[
1503418317170
,
-
2
,
0
],
[
1503418317192
,
-
2
,
0
],
[
1503418317265
,
-
2
,
0
],
[
1503418317289
,
-
2
,
0
],
[
1503418317365
,
-
2
,
0
],
[
1503418317414
,
-
2
,
0
],
[
1503418317458
,
-
2
,
0
],
[
1503418317513
,
-
2
,
0
],
[
1503418317583
,
-
2
,
0
],
[
1503418317637
,
-
2
,
0
],
[
1503418317720
,
-
2
,
0
],
[
1503418317786
,
-
2
,
0
],
[
1503418317832
,
-
2
,
0
],
[
1503418317933
,
-
2
,
0
],
[
1503418318037
,
-
2
,
0
],
[
1503418318134
,
-
2
,
0
],
[
1503418318267
,
-
2
,
0
],
[
1503418318411
,
-
2
,
0
],
];
const
classifier
=
new
MouseWheelClassifier
();
for
(
let
i
=
0
,
len
=
testData
.
length
;
i
<
len
;
i
++
)
{
const
[
timestamp
,
deltaY
,
deltaX
]
=
testData
[
i
];
classifier
.
accept
(
timestamp
,
deltaX
,
deltaY
);
const
actual
=
classifier
.
isPhysicalMouseWheel
();
assert
.
equal
(
actual
,
true
);
}
});
test
(
'
Windows - SurfaceBook TouchPad
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503418499174
,
-
3.35
,
0
],
[
1503418499177
,
-
0.9333333333333333
,
0
],
[
1503418499222
,
-
2.091666666666667
,
0
],
[
1503418499238
,
-
1.5666666666666667
,
0
],
[
1503418499242
,
-
1.8
,
0
],
[
1503418499271
,
-
2.5166666666666666
,
0
],
[
1503418499283
,
-
0.7666666666666667
,
0
],
[
1503418499308
,
-
2.033333333333333
,
0
],
[
1503418499320
,
-
2.85
,
0
],
[
1503418499372
,
-
1.5333333333333334
,
0
],
[
1503418499373
,
-
2.8
,
0
],
[
1503418499411
,
-
1.6166666666666667
,
0
],
[
1503418499413
,
-
1.9166666666666667
,
0
],
[
1503418499443
,
-
0.9333333333333333
,
0
],
[
1503418499446
,
-
0.9833333333333333
,
0
],
[
1503418499458
,
-
0.7666666666666667
,
0
],
[
1503418499482
,
-
0.9666666666666667
,
0
],
[
1503418499485
,
-
0.36666666666666664
,
0
],
[
1503418499508
,
-
0.5833333333333334
,
0
],
[
1503418499532
,
-
0.48333333333333334
,
0
],
[
1503418499541
,
-
0.6333333333333333
,
0
],
[
1503418499571
,
-
0.18333333333333332
,
0
],
[
1503418499573
,
-
0.4
,
0
],
[
1503418499595
,
-
0.15
,
0
],
[
1503418499608
,
-
0.23333333333333334
,
0
],
[
1503418499625
,
-
0.18333333333333332
,
0
],
[
1503418499657
,
-
0.13333333333333333
,
0
],
[
1503418499674
,
-
0.15
,
0
],
[
1503418499676
,
-
0.03333333333333333
,
0
],
[
1503418499691
,
-
0.016666666666666666
,
0
],
];
const
classifier
=
new
MouseWheelClassifier
();
for
(
let
i
=
0
,
len
=
testData
.
length
;
i
<
len
;
i
++
)
{
const
[
timestamp
,
deltaY
,
deltaX
]
=
testData
[
i
];
classifier
.
accept
(
timestamp
,
deltaX
,
deltaY
);
const
actual
=
classifier
.
isPhysicalMouseWheel
();
assert
.
equal
(
actual
,
false
);
}
});
test
(
'
Windows - Razer physical wheel
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503418638271
,
-
2
,
0
],
[
1503418638317
,
-
2
,
0
],
[
1503418638336
,
-
2
,
0
],
[
1503418638350
,
-
2
,
0
],
[
1503418638360
,
-
2
,
0
],
[
1503418638366
,
-
2
,
0
],
[
1503418638407
,
-
2
,
0
],
[
1503418638694
,
-
2
,
0
],
[
1503418638742
,
-
2
,
0
],
[
1503418638744
,
-
2
,
0
],
[
1503418638746
,
-
2
,
0
],
[
1503418638780
,
-
2
,
0
],
[
1503418638782
,
-
2
,
0
],
[
1503418638810
,
-
2
,
0
],
[
1503418639127
,
-
2
,
0
],
[
1503418639168
,
-
2
,
0
],
[
1503418639194
,
-
2
,
0
],
[
1503418639197
,
-
4
,
0
],
[
1503418639244
,
-
2
,
0
],
[
1503418639248
,
-
2
,
0
],
[
1503418639586
,
-
2
,
0
],
[
1503418639653
,
-
2
,
0
],
[
1503418639667
,
-
4
,
0
],
[
1503418639677
,
-
2
,
0
],
[
1503418639681
,
-
2
,
0
],
[
1503418639728
,
-
2
,
0
],
[
1503418639997
,
-
2
,
0
],
[
1503418640034
,
-
2
,
0
],
[
1503418640039
,
-
2
,
0
],
[
1503418640065
,
-
2
,
0
],
[
1503418640080
,
-
2
,
0
],
[
1503418640097
,
-
2
,
0
],
[
1503418640141
,
-
2
,
0
],
[
1503418640413
,
-
2
,
0
],
[
1503418640456
,
-
2
,
0
],
[
1503418640490
,
-
2
,
0
],
[
1503418640492
,
-
4
,
0
],
[
1503418640494
,
-
2
,
0
],
[
1503418640546
,
-
2
,
0
],
[
1503418640781
,
-
2
,
0
],
[
1503418640823
,
-
2
,
0
],
[
1503418640824
,
-
2
,
0
],
[
1503418640829
,
-
2
,
0
],
[
1503418640864
,
-
2
,
0
],
[
1503418640874
,
-
2
,
0
],
[
1503418640876
,
-
2
,
0
],
[
1503418641168
,
-
2
,
0
],
[
1503418641203
,
-
2
,
0
],
[
1503418641224
,
-
2
,
0
],
[
1503418641240
,
-
2
,
0
],
[
1503418641254
,
-
4
,
0
],
[
1503418641270
,
-
2
,
0
],
[
1503418641546
,
-
2
,
0
],
[
1503418641612
,
-
2
,
0
],
[
1503418641625
,
-
6
,
0
],
[
1503418641634
,
-
2
,
0
],
[
1503418641680
,
-
2
,
0
],
[
1503418641961
,
-
2
,
0
],
[
1503418642004
,
-
2
,
0
],
[
1503418642016
,
-
4
,
0
],
[
1503418642044
,
-
2
,
0
],
[
1503418642065
,
-
2
,
0
],
[
1503418642083
,
-
2
,
0
],
[
1503418642349
,
-
2
,
0
],
[
1503418642378
,
-
2
,
0
],
[
1503418642390
,
-
2
,
0
],
[
1503418642408
,
-
2
,
0
],
[
1503418642413
,
-
2
,
0
],
[
1503418642448
,
-
2
,
0
],
[
1503418642468
,
-
2
,
0
],
[
1503418642746
,
-
2
,
0
],
[
1503418642800
,
-
2
,
0
],
[
1503418642814
,
-
4
,
0
],
[
1503418642816
,
-
2
,
0
],
[
1503418642857
,
-
2
,
0
],
];
const
classifier
=
new
MouseWheelClassifier
();
for
(
let
i
=
0
,
len
=
testData
.
length
;
i
<
len
;
i
++
)
{
const
[
timestamp
,
deltaY
,
deltaX
]
=
testData
[
i
];
classifier
.
accept
(
timestamp
,
deltaX
,
deltaY
);
const
actual
=
classifier
.
isPhysicalMouseWheel
();
assert
.
equal
(
actual
,
true
);
}
});
test
(
'
Windows - Logitech physical wheel
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503418872930
,
-
2
,
0
],
[
1503418872952
,
-
2
,
0
],
[
1503418872969
,
-
2
,
0
],
[
1503418873022
,
-
2
,
0
],
[
1503418873042
,
-
2
,
0
],
[
1503418873076
,
-
2
,
0
],
[
1503418873368
,
-
2
,
0
],
[
1503418873393
,
-
2
,
0
],
[
1503418873404
,
-
2
,
0
],
[
1503418873425
,
-
2
,
0
],
[
1503418873479
,
-
2
,
0
],
[
1503418873520
,
-
2
,
0
],
[
1503418873758
,
-
2
,
0
],
[
1503418873759
,
-
2
,
0
],
[
1503418873762
,
-
2
,
0
],
[
1503418873807
,
-
2
,
0
],
[
1503418873830
,
-
4
,
0
],
[
1503418873850
,
-
2
,
0
],
[
1503418874076
,
-
2
,
0
],
[
1503418874116
,
-
2
,
0
],
[
1503418874136
,
-
4
,
0
],
[
1503418874148
,
-
2
,
0
],
[
1503418874150
,
-
2
,
0
],
[
1503418874409
,
-
2
,
0
],
[
1503418874452
,
-
2
,
0
],
[
1503418874472
,
-
2
,
0
],
[
1503418874474
,
-
4
,
0
],
[
1503418874543
,
-
2
,
0
],
[
1503418874566
,
-
2
,
0
],
[
1503418874778
,
-
2
,
0
],
[
1503418874780
,
-
2
,
0
],
[
1503418874801
,
-
2
,
0
],
[
1503418874822
,
-
2
,
0
],
[
1503418874832
,
-
2
,
0
],
[
1503418874845
,
-
2
,
0
],
[
1503418875122
,
-
2
,
0
],
[
1503418875158
,
-
2
,
0
],
[
1503418875180
,
-
2
,
0
],
[
1503418875195
,
-
4
,
0
],
[
1503418875239
,
-
2
,
0
],
[
1503418875260
,
-
2
,
0
],
[
1503418875490
,
-
2
,
0
],
[
1503418875525
,
-
2
,
0
],
[
1503418875547
,
-
4
,
0
],
[
1503418875556
,
-
4
,
0
],
[
1503418875630
,
-
2
,
0
],
[
1503418875852
,
-
2
,
0
],
[
1503418875895
,
-
2
,
0
],
[
1503418875935
,
-
2
,
0
],
[
1503418875941
,
-
4
,
0
],
[
1503418876198
,
-
2
,
0
],
[
1503418876242
,
-
2
,
0
],
[
1503418876270
,
-
4
,
0
],
[
1503418876279
,
-
2
,
0
],
[
1503418876333
,
-
2
,
0
],
[
1503418876342
,
-
2
,
0
],
[
1503418876585
,
-
2
,
0
],
[
1503418876609
,
-
2
,
0
],
[
1503418876623
,
-
2
,
0
],
[
1503418876644
,
-
2
,
0
],
[
1503418876646
,
-
2
,
0
],
[
1503418876678
,
-
2
,
0
],
[
1503418877330
,
-
2
,
0
],
[
1503418877354
,
-
2
,
0
],
[
1503418877368
,
-
2
,
0
],
[
1503418877397
,
-
2
,
0
],
[
1503418877411
,
-
2
,
0
],
[
1503418877748
,
-
2
,
0
],
[
1503418877756
,
-
2
,
0
],
[
1503418877778
,
-
2
,
0
],
[
1503418877793
,
-
2
,
0
],
[
1503418877807
,
-
2
,
0
],
[
1503418878091
,
-
2
,
0
],
[
1503418878133
,
-
2
,
0
],
[
1503418878137
,
-
4
,
0
],
[
1503418878181
,
-
2
,
0
],
];
const
classifier
=
new
MouseWheelClassifier
();
for
(
let
i
=
0
,
len
=
testData
.
length
;
i
<
len
;
i
++
)
{
const
[
timestamp
,
deltaY
,
deltaX
]
=
testData
[
i
];
classifier
.
accept
(
timestamp
,
deltaX
,
deltaY
);
const
actual
=
classifier
.
isPhysicalMouseWheel
();
assert
.
equal
(
actual
,
true
);
}
});
test
(
'
Windows - Microsoft basic v2 physical wheel
'
,
()
=>
{
const
testData
:
IMouseWheelEvent
[]
=
[
[
1503418994564
,
-
2
,
0
],
[
1503418994643
,
-
2
,
0
],
[
1503418994676
,
-
2
,
0
],
[
1503418994691
,
-
2
,
0
],
[
1503418994727
,
-
2
,
0
],
[
1503418994799
,
-
2
,
0
],
[
1503418994850
,
-
2
,
0
],
[
1503418995259
,
-
2
,
0
],
[
1503418995321
,
-
2
,
0
],
[
1503418995328
,
-
2
,
0
],
[
1503418995343
,
-
2
,
0
],
[
1503418995402
,
-
2
,
0
],
[
1503418995454
,
-
2
,
0
],
[
1503418996052
,
-
2
,
0
],
[
1503418996095
,
-
2
,
0
],
[
1503418996107
,
-
2
,
0
],
[
1503418996120
,
-
2
,
0
],
[
1503418996146
,
-
2
,
0
],
[
1503418996471
,
-
2
,
0
],
[
1503418996530
,
-
2
,
0
],
[
1503418996549
,
-
2
,
0
],
[
1503418996561
,
-
2
,
0
],
[
1503418996571
,
-
2
,
0
],
[
1503418996636
,
-
2
,
0
],
[
1503418996936
,
-
2
,
0
],
[
1503418997002
,
-
2
,
0
],
[
1503418997006
,
-
2
,
0
],
[
1503418997043
,
-
2
,
0
],
[
1503418997045
,
-
2
,
0
],
[
1503418997092
,
-
2
,
0
],
[
1503418997357
,
-
2
,
0
],
[
1503418997394
,
-
2
,
0
],
[
1503418997410
,
-
2
,
0
],
[
1503418997426
,
-
2
,
0
],
[
1503418997442
,
-
2
,
0
],
[
1503418997486
,
-
2
,
0
],
[
1503418997757
,
-
2
,
0
],
[
1503418997807
,
-
2
,
0
],
[
1503418997813
,
-
2
,
0
],
[
1503418997850
,
-
2
,
0
],
];
const
classifier
=
new
MouseWheelClassifier
();
for
(
let
i
=
0
,
len
=
testData
.
length
;
i
<
len
;
i
++
)
{
const
[
timestamp
,
deltaY
,
deltaX
]
=
testData
[
i
];
classifier
.
accept
(
timestamp
,
deltaX
,
deltaY
);
const
actual
=
classifier
.
isPhysicalMouseWheel
();
assert
.
equal
(
actual
,
true
);
}
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录