const arr = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg'];
const getImg = async (url) => {
const response = await fetch(url);
const blob = await response.blob();
const reader = new FileReader();
return new Promise(resolve => {
reader.addEventListener('loadend', function() {
resolve({image: reader.result});
});
reader.readAsDataURL(blob);
});
}
document.querySelector('button').addEventListener('click', async () => {
const arrImg = await Promise.all(arr.map(
url => getImg(url)
));
console.log(arrImg);
});
Если ли смысл в 4k
form.addEventListener("submit", e => {
e.preventDefault();
// тут делай все свои дела, собирай данные и делай с ними что хочешь.
})
let currentScrollY = 0;
let targetScrollY = 0;
let t = 0;
document.body.addEventListener("click", () => {
targetScrollY = Math.floor(Math.random() * getScrollheight());
currentScrollY = getScrollTop();
t = 0;
});
function getScrollheight() {
return document.documentElement.scrollHeight || document.body.scrollHeight;
}
function getScrollTop() {
return document.documentElement.scrollTop || document.body.scrollTop;
}
function setScrollTop(to) {
document.documentElement.scrollTop = to;
document.body.scrollTop = to;
}
function ease(t) { return (--t)*t*t+1 }
function animate() {
if (t < 1) {
t += 0.01;
setScrollTop(
currentScrollY + (targetScrollY - currentScrollY) * ease(t)
);
}
requestAnimationFrame(animate);
}
animate();
Или остаются какие-то принципиальные моменты, которые не позволяют использовать его для серьезной разработки?