Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joseph Nuthalapati
pleroma-fe
Commits
b18fea85
Commit
b18fea85
authored
5 years ago
by
Eugenij
Browse files
Options
Downloads
Patches
Plain Diff
Debounce floating post button autohide
parent
ae1496cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/mobile_post_status_modal/mobile_post_status_modal.js
+23
-31
23 additions, 31 deletions
...ents/mobile_post_status_modal/mobile_post_status_modal.js
with
23 additions
and
31 deletions
src/components/mobile_post_status_modal/mobile_post_status_modal.js
+
23
−
31
View file @
b18fea85
import
PostStatusForm
from
'
../post_status_form/post_status_form.vue
'
import
{
throttle
,
debounce
}
from
'
lodash
'
import
{
debounce
}
from
'
lodash
'
const
MobilePostStatusModal
=
{
components
:
{
...
...
@@ -17,15 +17,13 @@ const MobilePostStatusModal = {
},
created
()
{
if
(
this
.
autohideFloatingPostButton
)
{
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScroll
)
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScrollDown
)
this
.
activateFloatingPostButtonAutohide
()
}
window
.
addEventListener
(
'
resize
'
,
this
.
handleOSK
)
},
destroyed
()
{
if
(
this
.
autohideFloatingPostButton
)
{
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScroll
)
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScrollDown
)
this
.
deactivateFloatingPostButtonAutohide
()
}
window
.
removeEventListener
(
'
resize
'
,
this
.
handleOSK
)
},
...
...
@@ -43,15 +41,21 @@ const MobilePostStatusModal = {
watch
:
{
autohideFloatingPostButton
:
function
(
isEnabled
)
{
if
(
isEnabled
)
{
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScroll
)
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScrollDown
)
this
.
activateFloatingPostButtonAutohide
()
}
else
{
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScroll
)
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScrollDown
)
this
.
deactivateFloatingPostButtonAutohide
()
}
}
},
methods
:
{
activateFloatingPostButtonAutohide
()
{
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScrollStart
)
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScrollEnd
)
},
deactivateFloatingPostButtonAutohide
()
{
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScrollStart
)
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScrollEnd
)
},
openPostForm
()
{
this
.
postFormOpen
=
true
this
.
hidden
=
true
...
...
@@ -85,31 +89,19 @@ const MobilePostStatusModal = {
this
.
inputActive
=
false
}
},
handleScroll
:
throttle
(
function
()
{
const
scrollAmount
=
window
.
scrollY
-
this
.
oldScrollPos
const
scrollingDown
=
scrollAmount
>
0
if
(
scrollingDown
!==
this
.
scrollingDown
)
{
this
.
amountScrolled
=
0
this
.
scrollingDown
=
scrollingDown
if
(
!
scrollingDown
)
{
this
.
hidden
=
false
}
}
else
if
(
scrollingDown
)
{
this
.
amountScrolled
+=
scrollAmount
if
(
this
.
amountScrolled
>
100
&&
!
this
.
hidden
)
{
this
.
hidden
=
true
}
handleScrollStart
:
debounce
(
function
()
{
if
(
window
.
scrollY
>
this
.
oldScrollPos
)
{
this
.
hidden
=
true
}
else
{
this
.
hidden
=
false
}
this
.
oldScrollPos
=
window
.
scrollY
},
100
,
{
leading
:
true
,
trailing
:
false
}),
handleScrollEnd
:
debounce
(
function
()
{
this
.
hidden
=
false
this
.
oldScrollPos
=
window
.
scrollY
this
.
scrollingDown
=
scrollingDown
},
100
),
handleScrollDown
:
debounce
(
function
()
{
if
(
this
.
scrollingDown
)
{
this
.
hidden
=
false
}
},
100
)
},
100
,
{
leading
:
false
,
trailing
:
true
})
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment