FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-study-group-oop/js/controllers/pointer.js at main · python-la-paz/python-study-group-oop · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python-la-paz
/
python-study-group-oop
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-study-group-oop
/
js
/
controllers
/
pointer.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
126 lines (92 loc) · 2.78 KB
Breadcrumbs
python-study-group-oop
/
js
/
controllers
/
pointer.js
Copy path
File metadata and controls
126 lines (92 loc) · 2.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* Handles hiding of the pointer/cursor when inactive.
*/
export
default
class
Pointer
{
constructor
(
Reveal
)
{
this
.
Reveal
=
Reveal
;
// Throttles mouse wheel navigation
this
.
lastMouseWheelStep
=
0
;
// Is the mouse pointer currently hidden from view
this
.
cursorHidden
=
false
;
// Timeout used to determine when the cursor is inactive
this
.
cursorInactiveTimeout
=
0
;
this
.
onDocumentCursorActive
=
this
.
onDocumentCursorActive
.
bind
(
this
)
;
this
.
onDocumentMouseScroll
=
this
.
onDocumentMouseScroll
.
bind
(
this
)
;
}
/**
* Called when the reveal.js config is updated.
*/
configure
(
config
,
oldConfig
)
{
if
(
config
.
mouseWheel
)
{
document
.
addEventListener
(
'wheel'
,
this
.
onDocumentMouseScroll
,
false
)
;
}
else
{
document
.
removeEventListener
(
'wheel'
,
this
.
onDocumentMouseScroll
,
false
)
;
}
// Auto-hide the mouse pointer when its inactive
if
(
config
.
hideInactiveCursor
)
{
document
.
addEventListener
(
'mousemove'
,
this
.
onDocumentCursorActive
,
false
)
;
document
.
addEventListener
(
'mousedown'
,
this
.
onDocumentCursorActive
,
false
)
;
}
else
{
this
.
showCursor
(
)
;
document
.
removeEventListener
(
'mousemove'
,
this
.
onDocumentCursorActive
,
false
)
;
document
.
removeEventListener
(
'mousedown'
,
this
.
onDocumentCursorActive
,
false
)
;
}
}
/**
* Shows the mouse pointer after it has been hidden with
* #hideCursor.
*/
showCursor
(
)
{
if
(
this
.
cursorHidden
)
{
this
.
cursorHidden
=
false
;
this
.
Reveal
.
getRevealElement
(
)
.
style
.
cursor
=
''
;
}
}
/**
* Hides the mouse pointer when it's on top of the .reveal
* container.
*/
hideCursor
(
)
{
if
(
this
.
cursorHidden
===
false
)
{
this
.
cursorHidden
=
true
;
this
.
Reveal
.
getRevealElement
(
)
.
style
.
cursor
=
'none'
;
}
}
destroy
(
)
{
this
.
showCursor
(
)
;
document
.
removeEventListener
(
'wheel'
,
this
.
onDocumentMouseScroll
,
false
)
;
document
.
removeEventListener
(
'mousemove'
,
this
.
onDocumentCursorActive
,
false
)
;
document
.
removeEventListener
(
'mousedown'
,
this
.
onDocumentCursorActive
,
false
)
;
}
/**
* Called whenever there is mouse input at the document level
* to determine if the cursor is active or not.
*
*
@param
{
object
} event
*/
onDocumentCursorActive
(
event
)
{
this
.
showCursor
(
)
;
clearTimeout
(
this
.
cursorInactiveTimeout
)
;
this
.
cursorInactiveTimeout
=
setTimeout
(
this
.
hideCursor
.
bind
(
this
)
,
this
.
Reveal
.
getConfig
(
)
.
hideCursorTime
)
;
}
/**
* Handles mouse wheel scrolling, throttled to avoid skipping
* multiple slides.
*
*
@param
{
object
} event
*/
onDocumentMouseScroll
(
event
)
{
if
(
Date
.
now
(
)
-
this
.
lastMouseWheelStep
>
1000
)
{
this
.
lastMouseWheelStep
=
Date
.
now
(
)
;
let
delta
=
event
.
detail
||
-
event
.
wheelDelta
;
if
(
delta
>
0
)
{
this
.
Reveal
.
next
(
)
;
}
else
if
(
delta
<
0
)
{
this
.
Reveal
.
prev
(
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL