K
K
kirillleogky2020-05-12 21:18:27
JavaScript
kirillleogky, 2020-05-12 21:18:27

Why is there no preloader with DOMContentLoaded?

project is fuzzy-bread.surge.sh
my main js file is index.js

import '@babel/polyfill';
import 'weather-icons/css/weather-icons.min.css';
import addHTMLstructure from './addHtml';
import showLanguage from './showLang';
import {
  searchBy, search, feels, wind, humidity, latitude, longitude,
} from './wordsData';
import getUserLocation from './getLocation';
import setUpToDateLocationInfo from './setLocationInfo';
import addMap from './addMap';
import getForecast from './getForecast';
import setForecast from './setForecastInfo';
import setWeatherIcons from './setIcons';
import setDate from './setDate';
import setCurrTime from './setCurrTime';
import setImg from './setBackgroundImg';
import useGeocod from './useGeocoding';
import setSearchTime from './setSearchingTime';
import getTimeDifference from './getTimeDifference';
import setFahUnitFormat from './setFahrenheitUnitFormat';
import setCelUnitFormat from './setCelsiusUnitFormat';
import deletePreLoad from './delPreLoad';

require('./style.css');
require('./preLoaderStyle.css');

let currUnitsFormat = localStorage.getItem('units') || 'Celsius';
const currLanguage = 'en';
const currLangWords = {
  searchBy: `${searchBy[currLanguage]}`,
  search: `${search[currLanguage]}`,
  feels: `${feels[currLanguage]}`,
  wind: `${wind[currLanguage]}`,
  humidity: `${humidity[currLanguage]}`,
  latitude: `${latitude[currLanguage]}`,
  longitude: `${longitude[currLanguage]}`,
};
addHTMLstructure(currLangWords);
setDate(currLanguage);
.......................
// Set Time
window.setInterval(setCurrTime, 3000, getTime);

document.addEventListener('DOMContentLoaded', deletePreLoad);  ------- Почему это не работает??


Why do I put document.addEventListener('DOMContentLoaded', deletePreLoad) (deletePreLoad removes page load animation) and it doesn't work?

Is it because there is async in the code (for example, to get a photo)?

And how can I make the animation not disappear until the photo is loaded, but without setTimeout?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question