'use strict';

const anchorsList = document.querySelectorAll(`.js-link-list`);

const selector = document.querySelectorAll(`input[type="tel"]`);


const im = new Inputmask(`(+7|8) (999) 999-99-99`);


//маска телефона
im.mask(selector);

slowScroll(anchorsList);


function slowScroll(anchors) {
  for (let anchor of anchors) {
    anchor.addEventListener(`click`, (e) => {
      e.preventDefault();
      const blockID = anchor.getAttribute(`href`)
      document.querySelector(`${blockID}`).scrollIntoView({
        behavior: `smooth`,
        block: `start`
      })
    })
  }
};

//
// let scroll = 0;
// const defaultOffset = 400;
// const footerOffser =200;
// const mapAside = document.querySelector(`.js-aside`);
//
//
//
// //обработчик события скролл
// window.addEventListener(`scroll`, () => {
//     scrollheader();
// });
//
// //появлениe aside при скролле вниз
// function scrollheader() {
//     const scrollPosition = () => window.pageXOffset || document.documentElement.scrollTop;
//     const containHide = () => mapAside.classList.contains(`fixed`);
//
//          if (scrollPosition() > scroll
//          && scrollPosition() > defaultOffset ) {
//              mapAside.classList.add(`fixed`);
//
//          }
//
//          if (scrollPosition() < scroll && scrollPosition() < defaultOffset ) {
//              mapAside.classList.remove(`fixed`);
//
//          }
//
//
//     scroll = scrollPosition();
//
// }
