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 COUNTRY_CODE = 7; | |
const onInputPhoneInput = ({target}) => { | |
const matrix = `+${COUNTRY_CODE} (___) ___-__-__`; | |
let counter = 0; | |
let val = target.value.replace(/\D/g, ''); | |
if (!val.length) { | |
val = `${COUNTRY_CODE}`; | |
} |
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); | |
const goToTarget = function (target) { // фолбэк для ie11 | |
const y = target.offsetTop; | |
const moveTo = function () { | |
if (window.pageYOffset < y) { | |
window.scrollBy(0, 60); | |
setTimeout(moveTo); |
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 focusableEls = `a[href]:not(:disabled), input:not(:disabled):not([type="hidden"]), | |
select:not(:disabled), textarea:not(:disabled), button:not(:disabled), [contenteditable], | |
[tabindex]:not([tabindex="-1"])`; | |
const isTouchSupported = () => ('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch); | |
const getHtmlElement = (selector, ctx = document) => { | |
const node = typeof selector === 'string' ? ctx.querySelector(selector) : selector; | |
if (node instanceof HTMLElement) { | |
return node; | |
} |
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 debounce(func, ms) { | |
let timeout; | |
return () => { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => { | |
func(); | |
}, ms); | |
}; | |
} |
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
input.addEventListener('keypress', function(e) { | |
if(/\D/.test(e.key)) { | |
e.preventDefault(); | |
} | |
const len = input.value.length; | |
if(len === 1 || len === 4) { | |
setTimeout(() => { | |
input.value += '/'; | |
}) |
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 easingOutQuint = (x, t, b, c, d) => c * ((t = t / d - 1) * t * t * t * t + 1) + b; | |
const makeScroll = (node, value, key = 'scrollTop') => { | |
let startTime = null; | |
const offset = node[key]; | |
const gap = value - offset; | |
const duration = 1000; | |
const step = (t) => { | |
if (!startTime) { |
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
import Template from './template.js'; | |
export default class Dbrange extends HTMLElement { | |
constructor() { | |
super(); | |
this.root = this.attachShadow({mode: 'open'}); | |
this.root.innerHTML = Template.render(); | |
this.dom = Template.mapDOM(this.root); | |
this.eventNames = { | |
pointerdown: 'pointerdown', |