Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
89ec9a6d
Commit
89ec9a6d
authored
Sep 28, 2017
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
4cc3aa17
79412215
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
17 deletions
+34
-17
src/website.js
src/website.js
+34
-17
No files found.
src/website.js
View file @
89ec9a6d
(
function
()
{
document
.
addEventListener
(
"
DOMContentLoaded
"
,
function
(
event
)
{
function
scrollTo
(
element
,
to
,
duration
,
hash
)
{
if
(
duration
<=
0
)
return
;
var
difference
=
to
-
element
.
scrollTop
;
var
perTick
=
difference
/
duration
*
10
;
setTimeout
(
function
()
{
element
.
scrollTop
=
element
.
scrollTop
+
perTick
;
if
(
element
.
scrollTop
===
to
)
{
window
.
location
.
hash
=
hash
;
return
;
}
scrollTo
(
element
,
to
,
duration
-
10
,
hash
);
},
10
);
}
window
.
addEventListener
(
'
scroll
'
,
function
(
ev
)
{
var
navbar
=
document
.
querySelector
(
"
.navbar
"
);
var
fixed_top
=
document
.
querySelector
(
"
.navbar-fixed-top
"
);
var
rect
=
navbar
.
getBoundingClientRect
();
if
(
rect
.
top
+
document
.
body
.
scrollTop
>
50
)
{
if
(
rect
.
top
+
window
.
scrollY
>
50
)
{
fixed_top
.
classList
.
add
(
"
top-nav-collapse
"
);
}
else
{
fixed_top
.
classList
.
remove
(
"
top-nav-collapse
"
);
}
});
var
getDocumentHeight
=
function
()
{
return
Math
.
max
(
document
.
body
.
scrollHeight
,
document
.
documentElement
.
scrollHeight
,
document
.
body
.
offsetHeight
,
document
.
documentElement
.
offsetHeight
,
document
.
body
.
clientHeight
,
document
.
documentElement
.
clientHeight
);
};
Array
.
prototype
.
forEach
.
call
(
document
.
querySelectorAll
(
'
.page-scroll a
'
),
function
(
el
)
{
el
.
addEventListener
(
'
click
'
,
function
(
ev
)
{
ev
.
preventDefault
();
var
hash
=
this
.
getAttribute
(
"
href
"
)
var
goal
=
document
.
querySelector
(
hash
);
scrollTo
(
document
.
body
,
goal
.
offsetTop
,
600
,
hash
);
var
endLocation
=
document
.
querySelector
(
hash
).
offsetTop
;
var
startLocation
=
window
.
pageYOffset
;
var
distance
=
endLocation
-
startLocation
;
var
start
,
percentage
,
position
;
var
timeLapsed
=
0
;
function
scrollAnimation
(
timestamp
)
{
if
(
!
start
)
{
start
=
timestamp
;
}
timeLapsed
+=
timestamp
-
start
;
percentage
=
(
timeLapsed
/
parseInt
(
500
,
10
));
percentage
=
(
percentage
>
1
)
?
1
:
percentage
;
position
=
startLocation
+
(
distance
*
percentage
*
percentage
);
window
.
scrollTo
(
0
,
Math
.
floor
(
position
));
var
currentLocation
=
window
.
pageYOffset
;
if
(
position
==
endLocation
||
currentLocation
==
endLocation
||
((
startLocation
<
endLocation
&&
window
.
innerHeight
+
currentLocation
)
>=
getDocumentHeight
()))
{
window
.
location
.
hash
=
hash
;
return
;
}
window
.
requestAnimationFrame
(
scrollAnimation
);
start
=
timestamp
;
}
window
.
requestAnimationFrame
(
scrollAnimation
);
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment