Понял проблему! Нужно полностью переработать логику - **всегда показываем геологическую колонку по умолчанию**, а при каждом переключении принудительно пересоздаем DOM и переустанавливаем скролл. Вот **исправленные функции**: ## 1. Полностью переработанная функция `createWellStructureDrawing`: ```javascript function createWellStructureDrawing(structureData) { console.log('=== СОЗДАНИЕ КОЛОНКИ С ГАРАНТИРОВАННОЙ ПРОКРУТКОЙ ==='); const drawing = document.getElementById('wellStructureDrawing'); if (!drawing) { console.log('❌ Элемент wellStructureDrawing не найден!'); return; } drawing.innerHTML = ''; // ВСЕГДА НАЧИНАЕМ С ГЕОЛОГИЧЕСКОЙ КОЛОНКИ window.displayMode = 'geology'; const container = document.createElement('div'); container.style.cssText = ` display: flex; flex-direction: column; height: 100%; background: white; border-radius: 8px; border: 1px solid #ddd; overflow: hidden; min-width: 1400px; `; // ЗАГОЛОВОК const mainHeader = document.createElement('div'); mainHeader.style.cssText = ` padding: 10px 20px; background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%); color: white; border-bottom: 1px solid #1a252f; flex-shrink: 0; display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; `; const titleLeft = document.createElement('div'); titleLeft.style.cssText = 'display: flex; align-items: baseline; gap: 15px; flex-wrap: wrap;'; const modeName = document.createElement('span'); modeName.textContent = 'Геологическая колонка'; modeName.style.cssText = 'font-size: 16px; font-weight: 600;'; const depthInfo = document.createElement('span'); depthInfo.textContent = `Глубина: ${structureData.totalDepth.toFixed(1)} м`; depthInfo.style.cssText = 'font-size: 13px; opacity: 0.85; background: rgba(255,255,255,0.15); padding: 3px 8px; border-radius: 20px;'; const docTypeInfo = document.createElement('span'); const docTypeNames = { 'primary': 'Первичное', 'final': 'Итоговое', 'gis': 'ГИС' }; docTypeInfo.textContent = `${docTypeNames[structureData.documentationType] || structureData.documentationType} документация`; docTypeInfo.style.cssText = 'font-size: 13px; opacity: 0.85; background: rgba(255,255,255,0.15); padding: 3px 8px; border-radius: 20px;'; titleLeft.appendChild(modeName); titleLeft.appendChild(depthInfo); titleLeft.appendChild(docTypeInfo); const titleRight = document.createElement('div'); titleRight.style.cssText = 'display: flex; align-items: center; gap: 12px;'; const scaleLabel = document.createElement('span'); const cartographicScale = getCartographicScale(window.currentScale || 40); scaleLabel.textContent = `Масштаб: ${cartographicScale}`; scaleLabel.style.cssText = 'font-size: 12px; background: rgba(255,255,255,0.15); padding: 3px 8px; border-radius: 20px;'; const scaleButtons = createColumnScaleControls(); scaleButtons.style.cssText = 'display: flex; gap: 4px;'; titleRight.appendChild(scaleLabel); titleRight.appendChild(scaleButtons); mainHeader.appendChild(titleLeft); mainHeader.appendChild(titleRight); container.appendChild(mainHeader); // ОСНОВНОЙ КОНТЕНТ const contentContainer = document.createElement('div'); contentContainer.style.cssText = ` display: flex; flex: 1; min-height: 0; overflow: hidden; position: relative; `; // ЛЕВАЯ ПАНЕЛЬ const visualPanel = document.createElement('div'); visualPanel.style.cssText = ` width: 500px; min-width: 500px; display: flex; flex-direction: column; border-right: 1px solid #e0e0e0; background: #fafafa; flex-shrink: 0; overflow: hidden; `; // ПАНЕЛЬ УПРАВЛЕНИЯ const controlsPanel = document.createElement('div'); controlsPanel.style.cssText = ` padding: 6px 12px; background: #f0f2f5; border-bottom: 1px solid #d4d9e1; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; gap: 15px; `; const leftControls = document.createElement('div'); leftControls.style.cssText = 'display: flex; gap: 8px; align-items: center;'; if (structureData.hasDrillingData) { const modeToggle = createColumnModeToggle(); leftControls.appendChild(modeToggle); } const rightControls = document.createElement('div'); rightControls.style.cssText = 'display: flex; gap: 8px; align-items: center;'; const assaysToggle = createAssaysToggle(); assaysToggle.setAttribute('data-assays-toggle', 'true'); assaysToggle.id = 'assaysToggleContainer'; rightControls.appendChild(assaysToggle); controlsPanel.appendChild(leftControls); controlsPanel.appendChild(rightControls); visualPanel.appendChild(controlsPanel); // КОНТЕЙНЕР ДЛЯ ГРАФИКИ - КЛЮЧЕВОЙ МОМЕНТ! const graphicsScrollContainer = document.createElement('div'); graphicsScrollContainer.id = 'graphicsScrollContainer'; graphicsScrollContainer.style.cssText = ` flex: 1; overflow: auto !important; overflow-y: auto !important; height: 100%; min-height: 200px; position: relative; background: #fafafa; `; visualPanel.appendChild(graphicsScrollContainer); // ПРАВАЯ ПАНЕЛЬ const infoPanel = document.createElement('div'); infoPanel.style.cssText = ` flex: 1; min-width: 480px; display: flex; flex-direction: column; background: #f8f9fa; overflow: hidden; `; const infoHeader = document.createElement('div'); infoHeader.style.cssText = ` padding: 8px 16px; background: #e9ecef; color: #2c3e50; font-size: 13px; font-weight: 600; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #dee2e6; `; const headerLeft = document.createElement('div'); headerLeft.style.cssText = 'display: flex; align-items: center; gap: 10px;'; const infoTitle = document.createElement('span'); infoTitle.textContent = 'Интервалы документирования'; const countBadge = document.createElement('span'); countBadge.id = 'intervalsCount'; countBadge.style.cssText = `background: #e74c3c; color: white; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;`; headerLeft.appendChild(infoTitle); headerLeft.appendChild(countBadge); const headerRight = document.createElement('div'); headerRight.style.cssText = 'display: flex; align-items: center; gap: 8px;'; const docTypeSelector = createDocTypeSelector(structureData.documentationType); docTypeSelector.style.cssText = 'display: flex; gap: 4px;'; headerRight.appendChild(docTypeSelector); infoHeader.appendChild(headerLeft); infoHeader.appendChild(headerRight); infoPanel.appendChild(infoHeader); // ПАНЕЛЬ ОБЪЕДИНЕНИЯ const mergePanel = document.createElement('div'); mergePanel.style.cssText = ` padding: 6px 16px; background: ${mergeGeologyIntervals ? '#e8f4f8' : '#fff8e1'}; border-bottom: 1px solid ${mergeGeologyIntervals ? '#d1ecf1' : '#ffeaa7'}; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; `; const infoText = document.createElement('div'); infoText.style.cssText = `font-size: 11px; color: ${mergeGeologyIntervals ? '#6c757d' : '#e67e22'}; flex: 1;`; infoText.textContent = mergeGeologyIntervals ? '✓ Объединены последовательные интервалы с одинаковой литологией и стратиграфией' : '○ Отображаются все интервалы документирования отдельно'; const checkboxContainer = document.createElement('div'); checkboxContainer.style.cssText = `display: flex; align-items: center; gap: 6px; margin-left: 15px; cursor: pointer; flex-shrink: 0;`; const checkboxInput = document.createElement('input'); checkboxInput.type = 'checkbox'; checkboxInput.id = 'mergeIntervalsCheckbox'; checkboxInput.checked = mergeGeologyIntervals; checkboxInput.style.cssText = 'width: 14px; height: 14px; cursor: pointer; margin: 0;'; const checkboxLabel = document.createElement('label'); checkboxLabel.htmlFor = 'mergeIntervalsCheckbox'; checkboxLabel.style.cssText = 'font-size: 11px; color: #2c3e50; cursor: pointer; font-weight: 500; white-space: nowrap;'; checkboxLabel.textContent = 'Объединять'; checkboxContainer.appendChild(checkboxInput); checkboxContainer.appendChild(checkboxLabel); checkboxInput.addEventListener('change', function() { mergeGeologyIntervals = this.checked; redrawCurrentStructure(); }); mergePanel.appendChild(infoText); mergePanel.appendChild(checkboxContainer); infoPanel.appendChild(mergePanel); const cardsContainer = document.createElement('div'); cardsContainer.id = 'cardsContainer'; cardsContainer.style.cssText = `flex: 1; overflow-y: auto; padding: 12px; background: white;`; infoPanel.appendChild(cardsContainer); contentContainer.appendChild(visualPanel); contentContainer.appendChild(infoPanel); container.appendChild(contentContainer); drawing.appendChild(container); window.currentScale = window.currentScale || 40; window.displayMode = 'geology'; // ОТРИСОВЫВАЕМ ГЕОЛОГИЧЕСКУЮ КОЛОНКУ updateWellStructureByDocType(structureData.documentationType); // ГАРАНТИЯ ПРОКРУТКИ setTimeout(() => { const sc = document.getElementById('graphicsScrollContainer'); if (sc) { sc.style.overflow = 'auto'; sc.style.overflowY = 'auto'; console.log('✅ Прокрутка активирована, высота:', sc.clientHeight, 'контент:', sc.scrollHeight); } }, 200); console.log('✅ Колонка создана, режим: геология'); } ``` ## 2. Исправленная функция `createColumnModeToggle` (всегда начинаем с геологии): ```javascript function createColumnModeToggle() { const container = document.createElement('div'); container.style.cssText = `display: flex; gap: 3px; align-items: center;`; const geologyBtn = document.createElement('button'); geologyBtn.textContent = 'Геология'; geologyBtn.title = 'Геологическая колонка'; const structureBtn = document.createElement('button'); structureBtn.textContent = 'Конструкция'; structureBtn.title = 'Конструкция скважины'; const buttonStyle = ` padding: 4px 8px; border: 1px solid #3498db; border-radius: 4px; cursor: pointer; font-size: 11px; transition: all 0.3s; white-space: nowrap; min-width: 70px; font-weight: 500; `; function updateButtons() { const isGeology = (window.displayMode === 'geology'); geologyBtn.style.cssText = buttonStyle + `background: ${isGeology ? '#27ae60' : '#ecf0f1'}; color: ${isGeology ? 'white' : '#2c3e50'};`; structureBtn.style.cssText = buttonStyle + `background: ${!isGeology ? '#27ae60' : '#ecf0f1'}; color: ${!isGeology ? 'white' : '#2c3e50'};`; } geologyBtn.onclick = () => { if (window.displayMode !== 'geology') { window.displayMode = 'geology'; updateButtons(); // ПОКАЗЫВАЕМ ПЕРЕКЛЮЧАТЕЛЬ ПРОБ const assaysToggle = document.getElementById('assaysToggleContainer'); if (assaysToggle) assaysToggle.style.display = 'flex'; redrawCurrentStructure(); // ГАРАНТИЯ ПРОКРУТКИ ПОСЛЕ ПЕРЕКЛЮЧЕНИЯ setTimeout(() => { const sc = document.getElementById('graphicsScrollContainer'); if (sc) { sc.style.overflow = 'auto'; sc.style.overflowY = 'auto'; } }, 100); } }; structureBtn.onclick = () => { const structureData = generateWellStructureData(); if (!structureData || !structureData.hasDrillingData) { alert('Для этой скважины нет данных проходки'); return; } if (window.displayMode !== 'structure') { window.displayMode = 'structure'; updateButtons(); // СКРЫВАЕМ ПЕРЕКЛЮЧАТЕЛЬ ПРОБ const assaysToggle = document.getElementById('assaysToggleContainer'); if (assaysToggle) assaysToggle.style.display = 'none'; redrawCurrentStructure(); // ГАРАНТИЯ ПРОКРУТКИ ПОСЛЕ ПЕРЕКЛЮЧЕНИЯ setTimeout(() => { const sc = document.getElementById('graphicsScrollContainer'); if (sc) { sc.style.overflow = 'auto'; sc.style.overflowY = 'auto'; } }, 100); } }; updateButtons(); container.appendChild(geologyBtn); container.appendChild(structureBtn); return container; } ``` ## 3. Исправленная функция `redrawCurrentStructure`: ```javascript function redrawCurrentStructure() { const activeButton = document.querySelector('#wellStructureDrawing [data-doc-type].active'); const activeDocType = activeButton ? activeButton.getAttribute('data-doc-type') : 'primary'; // НЕ СОХРАНЯЕМ РЕЖИМ, ВСЕГДА ИСПОЛЬЗУЕМ ТЕКУЩИЙ const structureData = generateWellStructureData(activeDocType); if (structureData) { const hasRealDrillingData = structureData.hasDrillingData; // Если нет данных проходки, но режим конструкции - принудительно переключаем на геологию if (!hasRealDrillingData && window.displayMode === 'structure') { window.displayMode = 'geology'; // Обновляем кнопки const geologyBtn = document.querySelector('#wellStructureDrawing button[title="Геологическая колонка"], #wellStructureDrawing button:first-child'); const structureBtn = document.querySelector('#wellStructureDrawing button[title="Конструкция скважины"], #wellStructureDrawing button:last-child'); if (geologyBtn && structureBtn) { geologyBtn.style.background = '#27ae60'; geologyBtn.style.color = 'white'; structureBtn.style.background = '#ecf0f1'; structureBtn.style.color = '#2c3e50'; } } // ОТРИСОВЫВАЕМ const graphicsScrollContainer = document.getElementById('graphicsScrollContainer'); if (graphicsScrollContainer) { // ОЧИЩАЕМ И СБРАСЫВАЕМ СТИЛИ ПЕРЕД ОТРИСОВКОЙ graphicsScrollContainer.innerHTML = ''; graphicsScrollContainer.style.overflow = 'auto'; graphicsScrollContainer.style.overflowY = 'auto'; } if (window.displayMode === 'geology') { drawWellStructure(structureData, window.currentScale); } else { drawWellConstruction(structureData, window.currentScale); } updateGeologyCards(activeDocType); // ГАРАНТИЯ ПРОКРУТКИ ПОСЛЕ ОТРИСОВКИ setTimeout(() => { const sc = document.getElementById('graphicsScrollContainer'); if (sc) { sc.style.overflow = 'auto'; sc.style.overflowY = 'auto'; // Принудительно вызываем пересчет sc.scrollTop = sc.scrollTop; } }, 150); } else { const graphicsScrollContainer = document.getElementById('graphicsScrollContainer'); const cardsContainer = document.getElementById('cardsContainer'); if (graphicsScrollContainer) { graphicsScrollContainer.innerHTML = '