This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Класс для предотвращения скрола | |
.body-lock { | |
overflow-y: scroll; | |
position:fixed; | |
} | |
*/ | |
const openClosePopup = function (obj) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function trackScroll() { | |
let scrolled = window.pageYOffset; | |
let coords = document.documentElement.clientHeight; | |
if (scrolled > coords) { | |
goToTop.classList.add("to_top-show"); | |
} | |
if (scrolled < coords) { | |
goToTop.classList.remove("to_top-show"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
progressBar = document.querySelector('progress'); | |
output = document.querySelector('output'); | |
xhr.upload.addEventListener('progress', function (e) { | |
if (e.lengthComputable) { | |
var v = (e.loaded / e.total) * 100; | |
progressBar.value = v; | |
output.value = Math.round(v) + '%'; | |
progressBar.textContent = progressBar.value.toString(); // Если браузер не поддерживает элемент progress | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const range = document.querySelector('.range'); | |
const thumb = document.querySelector('.range__thumb'); | |
let isTouch = false; | |
let touch = 'pointerdown'; | |
let touchMove = 'pointermove'; | |
let touchUp = 'pointerup'; | |
if ('ontouchstart' in window) { | |
isTouch = true; | |
touch = 'touchstart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* html | |
<div class="form__input-wrap"> | |
<input name="name" data-validate="true" type="text" pattern="[A-z,А-я]{2,}" placeholder="Введите Ваше Имя" | |
aria-label="Введите Ваше Имя" required> | |
<span class="form__error form__error--name">Имя должно содержать минимум 2 буквы</span> | |
</div> | |
<div class="form__input-wrap"> | |
<input name="phone" data-validate="true" type="text" pattern="\+7\s\([0-9]{3}\)\s[0-9]{3}\s[0-9]{2}\s[0-9]{2}" | |
placeholder="Введите Ваш номер телефона" | |
aria-label="Введите Ваш номер телефона" required> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ua = window.navigator.userAgent.toLowerCase(); | |
const isIe = (/trident/gi).test(ua) || (/msie/gi).test(ua); | |
if (isIe) { | |
const makeSmoothScroll = function (link) { | |
link.addEventListener('click', function (e) { | |
e.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::after { | |
content: ''; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
border-top: none; | |
border-bottom: 15px solid red; | |
border-left: 7px solid transparent; | |
border-right: 7px solid transparent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for IE11 | |
const supportsTemplate = 'content' in document.createElement('template'); | |
// the function takes a template and returns a DOM element | |
const createElement = supportsTemplate | |
? function (html) { | |
const template = document.createElement('template'); | |
template.innerHTML = html; | |
return template.content.firstElementChild; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <progress id="elem" style="width: 5%;" onclick="anim.start()"></progress> | |
class Animation { | |
constructor({draw, duration}) { | |
this.draw = draw; | |
this.duration = duration; | |
} | |
animate(time) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <div id="calendar"></div> | |
function createCalendar(elem, year, month) { | |
let mon = month - 1; // месяцы в JS идут от 0 до 11, а не от 1 до 12 | |
let d = new Date(year, mon); | |
let table = '<table><tr><th>пн</th><th>вт</th><th>ср</th><th>чт</th><th>пт</th><th>сб</th><th>вс</th></tr><tr>'; | |
// пробелы для первого ряда |
OlderNewer