var block = document.getElementById("MIXADV_10568"); var text = '
'; block.innerHTML = text; setTimeout(function slider() { let id_style = document.getElementById('MIXADV_10568'); //id_style.style.position = 'relative'; id_style.style.cssText= 'position: relative; margin: 0 auto; max-width: 414px;'; let block_10568 = document.querySelector("#MIXADV_10568"); block_10568.children[0].classList.add('head_10568'); let total = document.querySelector('#teaser_block_table_10568'); let navigation = document.createElement('div'); total.before(navigation); navigation.classList.add("navigation"); navigation.innerHTML += ''; navigation.style.cssText = 'position: absolute; top: 102px; right: 5px; z-index: 999;'; document.querySelector('.arrow_top').onclick = arrow_top; document.querySelector('.arrow_bottom').onclick = arrow_bottom; let slider_line = document.querySelector('#teaser_block_table_10568'); let no_click_top = document.querySelector('.arrow_top'); let no_click_bottom = document.querySelector('.arrow_bottom'); let head = document.querySelector('.head_10568'); let head_clone = head.cloneNode(true); console.log(head_clone); head.remove(); navigation.before(head_clone); function arrow_top() { stop_slider(); my_timer = setInterval(start_slider, 4000); no_click_top.style.cssText = 'pointer-events: none;'; no_click_bottom.style.cssText = 'pointer-events: none;'; let first = slider_line.firstElementChild; first.classList.add('hidden'); let clon_block = first.cloneNode(true); //клонирую первый блок setTimeout(function(){ first.remove(); //удаляю первый блок }, 400); setTimeout(function(){ slider_line.append(clon_block); //вставляю в конец }, 400); setTimeout(function(){ let last = slider_line.lastElementChild; last.classList.remove('hidden'); }, 500); setTimeout(function () { no_click_top.style.cssText = 'pointer-events: auto;'; no_click_bottom.style.cssText = 'pointer-events: auto;'; }, 500); } function arrow_bottom() { stop_slider(); my_timer = setInterval(start_slider, 4000); no_click_top.style.cssText = 'pointer-events: none;'; no_click_bottom.style.cssText = 'pointer-events: none;'; let last = slider_line.lastElementChild; last.classList.add('hidden'); let clon_block = last.cloneNode(true); //клонирую последний блок setTimeout(function(){ slider_line.prepend(clon_block); //вставляю в начало }, 400); setTimeout(function(){ last.remove(); //удаляю последний блок }, 400); setTimeout(function(){ let first = slider_line.firstElementChild; first.classList.remove('hidden'); }, 500); setTimeout(function () { no_click_top.style.cssText = 'pointer-events: auto;'; no_click_bottom.style.cssText = 'pointer-events: auto;'; }, 500); } let my_timer = setInterval(start_slider, 4000); function start_slider() { arrow_top(); } function stop_slider() { clearInterval(my_timer); } }, 1000);