Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
K
kpp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandr Veselov
kpp
Commits
7189f749
Unverified
Commit
7189f749
authored
Jun 17, 2020
by
Nikolay Gromov
Committed by
GitHub
Jun 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил JS-определение пары css custom properties
parent
1bdcac0c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
head-script.js
src/js/head-script.js
+20
-0
No files found.
src/js/head-script.js
View file @
7189f749
// Браузер и ОС
document
.
documentElement
.
className
=
document
.
documentElement
.
className
.
replace
(
'no-js'
,
'js'
);
function
cth
(
c
){
document
.
documentElement
.
classList
.
add
(
c
)}
'ontouchstart'
in
window
?
cth
(
'touch'
):
cth
(
'no-touch'
);
...
...
@@ -9,3 +10,22 @@ if(!!window.chrome&&(!!window.chrome.webstore||!!window.chrome.runtime))cth('chr
if
(
~
navigator
.
appVersion
.
indexOf
(
"Win"
))
cth
(
'windows'
);
if
(
~
navigator
.
appVersion
.
indexOf
(
"Mac"
))
cth
(
'osx'
);
if
(
~
navigator
.
appVersion
.
indexOf
(
"Linux"
))
cth
(
'linux'
);
// Добавление 1vh (использование: height: 100vh; height: calc(var(--vh, 1vh) * 100);) для фикса 100vh на мобилках
let
vh
=
window
.
innerHeight
*
0.01
;
document
.
documentElement
.
style
.
setProperty
(
'--vh'
,
`
${
vh
}
px`
);
window
.
addEventListener
(
'resize'
,
()
=>
{
let
vh
=
window
.
innerHeight
*
0.01
;
document
.
documentElement
.
style
.
setProperty
(
'--vh'
,
`
${
vh
}
px`
);
});
// Добавление css-custom-scroll-size для борьбы с проблемами скроллируемых блоков
const
outer
=
document
.
createElement
(
'div'
);
const
inner
=
document
.
createElement
(
'div'
);
outer
.
style
.
overflow
=
'scroll'
;
outer
.
classList
.
add
(
'scrollbar'
);
document
.
body
.
appendChild
(
outer
);
outer
.
appendChild
(
inner
);
const
scrollbarSize
=
outer
.
offsetWidth
-
inner
.
offsetWidth
;
document
.
body
.
removeChild
(
outer
);
document
.
documentElement
.
style
.
setProperty
(
'--css-custom-scroll-size'
,
`
${
scrollbarSize
}
px`
);
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