Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
smoothscroll
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
grifart libs
smoothscroll
Commits
9e7252d6
Commit
9e7252d6
authored
4 years ago
by
Daniel Kurowski
Browse files
Options
Downloads
Patches
Plain Diff
Extracted custom easing name into constant
parent
d63b0401
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!7
Improve structure
Pipeline
#26887
passed
4 years ago
Stage: install
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/scrollToTarget.ts
+2
-1
2 additions, 1 deletion
src/scrollToTarget.ts
src/setupVelocity.d.ts
+1
-0
1 addition, 0 deletions
src/setupVelocity.d.ts
src/setupVelocity.js
+3
-1
3 additions, 1 deletion
src/setupVelocity.js
with
6 additions
and
2 deletions
src/scrollToTarget.ts
+
2
−
1
View file @
9e7252d6
import
*
as
Velocity
from
'
velocity-animate
'
;
import
*
as
Velocity
from
'
velocity-animate
'
;
import
{
HashTarget
}
from
'
./HashTarget
'
;
import
{
HashTarget
}
from
'
./HashTarget
'
;
import
{
EASE_IN_SKIP_OUT_EASING
}
from
'
./setupVelocity
'
;
export
function
scrollToTarget
(
hashTarget
:
HashTarget
):
void
export
function
scrollToTarget
(
hashTarget
:
HashTarget
):
void
{
{
Velocity
.
animate
(
hashTarget
.
getElement
(),
'
scroll
'
,
{
Velocity
.
animate
(
hashTarget
.
getElement
(),
'
scroll
'
,
{
duration
:
1200
,
// todo: different depending on offset from page top?
duration
:
1200
,
// todo: different depending on offset from page top?
easing
:
'
ease-in-skip-out
'
,
easing
:
EASE_IN_SKIP_OUT_EASING
,
complete
:
()
=>
window
.
location
.
hash
=
hashTarget
.
getHash
(),
complete
:
()
=>
window
.
location
.
hash
=
hashTarget
.
getHash
(),
});
});
}
}
This diff is collapsed.
Click to expand it.
src/setupVelocity.d.ts
+
1
−
0
View file @
9e7252d6
import
*
as
Velocity
from
'
velocity-animate
'
;
import
*
as
Velocity
from
'
velocity-animate
'
;
declare
const
setupVelocity
:
(
velocity
:
typeof
Velocity
)
=>
void
;
declare
const
setupVelocity
:
(
velocity
:
typeof
Velocity
)
=>
void
;
export
declare
const
EASE_IN_SKIP_OUT_EASING
:
string
;
export
default
setupVelocity
;
export
default
setupVelocity
;
This diff is collapsed.
Click to expand it.
src/setupVelocity.js
+
3
−
1
View file @
9e7252d6
export
const
EASE_IN_SKIP_OUT_EASING
=
'
ease-in-skip-out
'
;
// e.g. (5, 5, 10, 500, 1000) => 500
// e.g. (5, 5, 10, 500, 1000) => 500
// e.g. (5, 0, 10, 500, 1000) => 750
// e.g. (5, 0, 10, 500, 1000) => 750
const
mapIntervalLinear
=
(
number
,
originalFrom
,
originalTo
,
newFrom
,
newTo
)
=>
{
const
mapIntervalLinear
=
(
number
,
originalFrom
,
originalTo
,
newFrom
,
newTo
)
=>
{
...
@@ -67,7 +69,7 @@ const computeHowMuchToSkip = (tweenDelta) => {
...
@@ -67,7 +69,7 @@ const computeHowMuchToSkip = (tweenDelta) => {
};
};
const
setupVelocity
=
(
velocity
)
=>
{
const
setupVelocity
=
(
velocity
)
=>
{
velocity
.
Easings
[
'
ease-in-skip-out
'
]
=
composeEasing
(
velocity
.
Easings
[
EASE_IN_SKIP_OUT_EASING
]
=
composeEasing
(
(
time
,
opts
,
tweenDelta
)
=>
mapIntervalLinear
(
(
time
,
opts
,
tweenDelta
)
=>
mapIntervalLinear
(
velocity
.
Easings
[
'
ease-in
'
](
time
,
opts
,
tweenDelta
),
velocity
.
Easings
[
'
ease-in
'
](
time
,
opts
,
tweenDelta
),
0
,
1
,
// from interval
0
,
1
,
// from interval
...
...
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