<canvas id="myChart" width="400" height="400"></canvas>
const request = useCallback(async (url, method = 'GET', body = null, headers ={}) => {
setLoading(true)
try{
if (body) {
body = JSON.stringify(body)
headers['Content-Type'] = 'application/json'
}
const response = await fetch(url, {method, body, headers})
const data = await response.json()
if (! response.ok){
throw new Error(data.message || 'Что-то пошло не так')
}
setLoading(false)
return data
}catch(e){
setLoading(false)
setError(e.message)
throw e
}
}, [])
const hanldeTextEditor = () => {
let commands = [[3, 'a'], [1, 'b']]
let text = ''
commands.forEach((command)=>{
for (let i = 0; i < command[0]; i++)
text = text + command[1];
console.log(text);
})
}
hanldeTextEditor()
toBlock = document.querySelector(hash).getBoundingClientRect().top
window.addEventListener('scroll', () =>{
if(document.documentElement.scrollTop > 1650){
}else{
}
let assortments = document.querySelectorAll('.product__item');
assortments.forEach(item =>{
let any = parseInt(item.getElementsByTagName("P")[0].getAttribute("data-filter"));
if(any < 2000){
item.classList.add('none');
}
});
let toBlock = document.querySelector('.section').getBoundingClientRect().top;
console.log(toBlock); (высота до до блока)
window.addEventListener('scroll', () => {
window.scrollTo({
top: toBlock,
behavior: "smooth"
});
})