 
      
    JavaScript
- 16 ответов
- 0 вопросов
    11
    Вклад в тег
    
      
      
    
  
  
pip install django  python -m venv myvenv myvenv\Scripts\activate  cd E:\Python\project_django\learning_log python manage.py runserver   python manage.py runserver 0.0.0.0:8001document.addEventListener('DOMContentLoaded', () => {
  const submenuItem = document.querySelectorAll(".header .menu-item-has-children");
  const menuBody = document.querySelector(".sub-menu");
  submenuItem.forEach((item) => {
    item.addEventListener('click', handlerItem);
    // слушаем клик вне меню
    document.addEventListener("click", function (e) {
      const target = e.target;
      const its_menu = target == menuBody || menuBody.contains(target);
      const its_btnMenu = target == menuBody;
      const menu_is_active = item.classList.contains("--show");
      if (!its_menu && !its_btnMenu && menu_is_active) {
        item.classList.toggle("--show");
      }
    });
    // слушаем скролл
    document.addEventListener("scroll", function () {
      //убираем класс если произошел скролл
      item.classList.remove("--show");
    });
  });
  function handlerItem(e) {
    if (e.target.classList.contains('sub-menu-link') || e.target.closest('.sub-menu-link')) {
      // если нажата ссылка в подменю, то предотвращаем действие по умолчанию только для нее
      return;
    }
    e.preventDefault();
    e.stopPropagation();
    this.classList.toggle("--show");
  }
});void Update()
{
    if (canExecute && (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space)) && !EventSystem.current.IsPointerOverGameObject(null, null) && !EventSystem.current.IsPointerOverGameObject(null, EventSystem.current.currentTouchEvent)) && !endGame)
    {
        canExecute = false;
        cooldownTimer = cooldownDuration;
        Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        directionKnife = mousePosition;
        mousePosition.z = 0f;
        GameObject knife = Instantiate(knifePrefab, mousePosition, Quaternion.identity);
        StartCoroutine(RotateKnife(knife));
    }
}