"use strict";

var scrollEl = void 0;

var scrollToView = function scrollToView(el) {
    var yPos = el.offsetTop + 55 + el.clientHeight;
    console.log(yPos);
    window.scrollTo(0, yPos);
};

var getScrollId = function getScrollId() {
    var scrollElId = getUrlParameter("id");
    var scrollEls = getArrayOfElements("[data-news-id]");
    scrollEls.map(function (single) {
        if (single.attributes['data-news-id'].value == scrollElId) {
            scrollEl = single;
        }
    });
    if (scrollEl == undefined || scrollEl == null) {
        return;
    } else {
        scrollToView(scrollEl);
    }
};

var scrollNews = function scrollNews(selector) {
    var scrollItemsNum = getUrlParameter("results");
    var scrollEls = getArrayOfElements(selector);
    if (scrollItemsNum != null) {
        var scrollItemId = parseInt(scrollItemsNum) - 10;
        scrollEls[scrollItemId].scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
    }
};

scrollNews(".js-news-card");