index.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Animal.js Documentation</title>
  7. <style>
  8. :root {
  9. --sidebar-bg: #111;
  10. --main-bg: #111;
  11. --border-color: #222;
  12. --text-color: #888;
  13. --text-hover: #ccc;
  14. --active-color: #ff4b4b; /* Red/Orange for active item */
  15. --header-color: #666;
  16. --middle-col-bg: #161616;
  17. --tree-line-color: #333;
  18. --accent-color: #ff9f43;
  19. }
  20. body {
  21. margin: 0;
  22. padding: 0;
  23. height: 100vh;
  24. display: flex;
  25. background: var(--main-bg);
  26. color: var(--text-color);
  27. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  28. overflow: hidden;
  29. font-size: 14px;
  30. }
  31. /* 1. LEFT SIDEBAR - MAIN NAVIGATION */
  32. .sidebar-left {
  33. width: 260px;
  34. background: var(--sidebar-bg);
  35. display: flex;
  36. flex-direction: column;
  37. overflow-y: auto;
  38. flex-shrink: 0;
  39. padding-bottom: 40px;
  40. }
  41. .logo-area {
  42. padding: 24px 20px;
  43. font-size: 18px;
  44. font-weight: bold;
  45. color: #fff;
  46. display: flex;
  47. align-items: center;
  48. gap: 10px;
  49. margin-bottom: 10px;
  50. }
  51. .logo-circle {
  52. width: 10px;
  53. height: 10px;
  54. background: #fff;
  55. border-radius: 50%;
  56. }
  57. /* Tree Structure */
  58. .nav-tree {
  59. padding: 0 20px;
  60. }
  61. .tree-group {
  62. margin-bottom: 5px;
  63. }
  64. .tree-header {
  65. padding: 8px 0;
  66. color: var(--header-color);
  67. font-weight: 600;
  68. cursor: pointer;
  69. transition: color 0.2s;
  70. display: flex;
  71. align-items: center;
  72. justify-content: space-between;
  73. }
  74. .tree-header:hover {
  75. color: var(--text-hover);
  76. }
  77. .tree-header.active-header {
  78. color: #e69f3c; /* Highlight parent if needed, usually just children */
  79. }
  80. .tree-children {
  81. padding-left: 14px; /* Indent */
  82. border-left: 1px solid var(--tree-line-color);
  83. margin-left: 2px;
  84. display: none; /* Collapsed by default */
  85. flex-direction: column;
  86. }
  87. .tree-children.expanded {
  88. display: flex;
  89. }
  90. .nav-item {
  91. display: block;
  92. padding: 6px 0 6px 15px;
  93. color: var(--text-color);
  94. text-decoration: none;
  95. cursor: pointer;
  96. transition: all 0.2s;
  97. position: relative;
  98. }
  99. .nav-item:hover {
  100. color: var(--text-hover);
  101. }
  102. /* Active Item Style (Reference: Red text, maybe red border left overlaying the gray line?) */
  103. .nav-item.active {
  104. color: var(--active-color);
  105. }
  106. /* Optional: Active marker on the left line */
  107. .nav-item.active::before {
  108. content: '';
  109. position: absolute;
  110. left: -1px; /* Overlap the border */
  111. top: 0;
  112. bottom: 0;
  113. width: 2px;
  114. background: var(--active-color);
  115. }
  116. /* Flat menu section title */
  117. .nav-section-title {
  118. margin-top: 18px;
  119. padding: 10px 0 6px 0;
  120. color: #7a7a7a;
  121. font-size: 11px;
  122. font-weight: 800;
  123. letter-spacing: 1px;
  124. text-transform: uppercase;
  125. opacity: 0.9;
  126. }
  127. /* Search Box in sidebar */
  128. .sidebar-search {
  129. margin: 0 20px 20px 20px;
  130. background: #1a1a1a;
  131. border: 1px solid #333;
  132. border-radius: 4px;
  133. padding: 8px 12px;
  134. color: #fff;
  135. font-size: 13px;
  136. cursor: pointer;
  137. }
  138. .sidebar-search:hover {
  139. border-color: #555;
  140. }
  141. /* 2. MIDDLE SIDEBAR */
  142. .sidebar-middle {
  143. width: 320px;
  144. background: var(--middle-col-bg);
  145. display: flex;
  146. flex-direction: column;
  147. overflow: hidden;
  148. flex-shrink: 0;
  149. }
  150. #middle-frame {
  151. width: 100%;
  152. height: 100%;
  153. border: none;
  154. background: transparent;
  155. }
  156. /* 3. RIGHT CONTENT */
  157. .content-right {
  158. flex: 1;
  159. display: flex;
  160. flex-direction: column;
  161. background: #000;
  162. overflow: hidden;
  163. }
  164. #content-frame {
  165. flex: 1;
  166. border: none;
  167. width: 100%;
  168. height: 100%;
  169. }
  170. /* Connection line between middle and right columns */
  171. .column-connection-line {
  172. position: fixed;
  173. inset: 0;
  174. width: 100vw;
  175. height: 100vh;
  176. pointer-events: none;
  177. z-index: 20;
  178. opacity: 0.85;
  179. }
  180. .column-connection-path {
  181. stroke: var(--accent-color);
  182. stroke-width: 2;
  183. stroke-dasharray: 6 6;
  184. stroke-linecap: round;
  185. fill: none;
  186. opacity: 0.35;
  187. animation: dashFlow 1.1s linear infinite;
  188. filter: drop-shadow(0 0 2px rgba(255, 159, 67, 0.25));
  189. }
  190. @keyframes dashFlow {
  191. to { stroke-dashoffset: -12; }
  192. }
  193. </style>
  194. </head>
  195. <body>
  196. <!-- 1. Left Sidebar -->
  197. <div class="sidebar-left">
  198. <div class="logo-area">
  199. <div class="logo-circle"></div>
  200. Animal.js
  201. </div>
  202. <div class="sidebar-search" onclick="selectCategory('search.html', 'test_on_update.html', null)">
  203. Search
  204. </div>
  205. <div class="nav-tree" aria-label="主菜单(扁平化)">
  206. <div class="nav-section-title">Animal.js 动画</div>
  207. <div class="nav-item active" onclick="selectCategory('targets/list.html', 'targets/overview.html', this)">目标 Targets</div>
  208. <div class="nav-item" onclick="selectCategory('animatable_properties/list.html', 'animatable_properties/test_transforms.html', this)">可动画属性 Properties</div>
  209. <div class="nav-item" onclick="selectCategory('tween_value_types/list.html', 'tween_value_types/test_numerical.html', this)">补间值类型 Tween 值</div>
  210. <div class="nav-item" onclick="selectCategory('tween_parameters/list.html', 'tween_parameters/overview.html', this)">补间参数 Tween 参数</div>
  211. <div class="nav-item" onclick="selectCategory('svg/list.html', 'svg/overview.html', this)">SVG 动画</div>
  212. <div class="nav-item" onclick="selectCategory('list_callbacks.html', 'test_on_update.html', this)">回调 Callbacks</div>
  213. <div class="nav-item" onclick="selectCategory('examples/list.html', 'examples/controls.html', this)">示例 Examples</div>
  214. <div class="nav-section-title">Layer 弹窗</div>
  215. <div class="nav-item" onclick="selectCategory('layer/list.html', 'layer/overview.html', this)">Layer API / Tests</div>
  216. <div class="nav-item" onclick="selectCategory('examples/list.html', 'examples/layer.html', this)">交互示例(Layer + 动画)</div>
  217. <div class="nav-section-title">开发者</div>
  218. <div class="nav-item" onclick="selectCategory('search.html', 'module.html', this)">模块开发与测试指南</div>
  219. </div>
  220. </div>
  221. <!-- 2. Middle Sidebar -->
  222. <div class="sidebar-middle">
  223. <iframe id="middle-frame" src="targets/list.html"></iframe>
  224. </div>
  225. <!-- 3. Right Content -->
  226. <div class="content-right">
  227. <iframe id="content-frame" src="targets/test_css_selector.html"></iframe>
  228. </div>
  229. <!-- SVG overlay for the middle→right connection line -->
  230. <svg id="column-connection-line" class="column-connection-line" aria-hidden="true">
  231. <path id="column-connection-path" class="column-connection-path" d=""></path>
  232. </svg>
  233. <script>
  234. // Bump this when you want to force-refresh iframe pages
  235. const DOC_CACHE_VERSION = '2';
  236. function selectCategory(listUrl, defaultContentUrl, el) {
  237. // 1. Highlight Nav Item
  238. document.querySelectorAll('.nav-item').forEach(item => item.classList.remove('active'));
  239. if (el) el.classList.add('active');
  240. // 2. Load Middle Column (List)
  241. const middleFrame = document.getElementById('middle-frame');
  242. const listUrlV = withDocVersion(listUrl);
  243. if (middleFrame.getAttribute('src') !== listUrlV) {
  244. middleFrame.src = listUrlV;
  245. }
  246. // 3. Load Right Column (Default Content)
  247. loadContent(defaultContentUrl);
  248. }
  249. function withDocVersion(url) {
  250. const u = String(url || '');
  251. if (!u) return u;
  252. // keep explicit query params if present
  253. if (u.includes('?')) return u;
  254. return u + '?v=' + encodeURIComponent(DOC_CACHE_VERSION);
  255. }
  256. function loadContent(url) {
  257. const contentFrame = document.getElementById('content-frame');
  258. const urlV = withDocVersion(url);
  259. if (contentFrame.getAttribute('src') !== urlV) {
  260. contentFrame.src = urlV;
  261. }
  262. // Keep middle list selection in sync when possible
  263. try {
  264. setMiddleActive(url);
  265. } catch {}
  266. // Update connection line after navigation
  267. scheduleConnectionLineUpdate();
  268. }
  269. // Called by content iframe pages (and also internally after navigation)
  270. function setMiddleActive(contentUrl) {
  271. const middleFrame = document.getElementById('middle-frame');
  272. if (!middleFrame) return;
  273. const win = middleFrame.contentWindow;
  274. if (win && typeof win.setActiveByContentUrl === 'function') {
  275. win.setActiveByContentUrl(contentUrl);
  276. }
  277. // Update connection line when active item changes
  278. scheduleConnectionLineUpdate();
  279. }
  280. // =========================================================
  281. // Global Prev/Next(组内顺序 + 跨组跳转,由路由表统一驱动)
  282. // =========================================================
  283. const DOC_PAGES = [
  284. // Targets
  285. { group: 'Targets', title: 'Targets 概览', url: 'targets/overview.html' },
  286. { group: 'Targets', title: 'CSS Selector', url: 'targets/test_css_selector.html' },
  287. { group: 'Targets', title: 'DOM Elements', url: 'targets/test_dom_elements.html' },
  288. { group: 'Targets', title: 'JavaScript Objects', url: 'targets/test_js_objects.html' },
  289. { group: 'Targets', title: 'Array of targets', url: 'targets/test_array_targets.html' },
  290. // Animatable properties
  291. { group: 'Properties', title: 'Transforms', url: 'animatable_properties/test_transforms.html' },
  292. { group: 'Properties', title: 'CSS Properties', url: 'animatable_properties/test_css_props.html' },
  293. { group: 'Properties', title: 'CSS Variables', url: 'animatable_properties/test_css_vars.html' },
  294. { group: 'Properties', title: 'JS Properties', url: 'animatable_properties/test_js_props.html' },
  295. // Tween value types
  296. { group: 'Tween 值', title: 'Numerical', url: 'tween_value_types/test_numerical.html' },
  297. { group: 'Tween 值', title: 'Unit', url: 'tween_value_types/test_unit.html' },
  298. { group: 'Tween 值', title: 'Relative', url: 'tween_value_types/test_relative.html' },
  299. { group: 'Tween 值', title: 'Colors', url: 'tween_value_types/test_colors.html' },
  300. // Tween parameters
  301. { group: 'Tween 参数', title: 'Tween parameters 概览', url: 'tween_parameters/overview.html' },
  302. { group: 'Tween 参数', title: 'duration / delay', url: 'tween_parameters/test_duration_delay.html' },
  303. // SVG
  304. { group: 'SVG', title: 'SVG 概览', url: 'svg/overview.html' },
  305. { group: 'SVG', title: 'draw() 路径描边', url: 'svg/test_draw_path.html' },
  306. { group: 'SVG', title: 'Motion Path', url: 'svg/test_motion_path.html' },
  307. { group: 'SVG', title: 'SVG 属性动画', url: 'svg/test_svg_attributes.html' },
  308. { group: 'SVG', title: 'SVG transform', url: 'svg/test_svg_transforms.html' },
  309. { group: 'SVG', title: 'Morph(points)', url: 'svg/test_morph_points.html' },
  310. { group: 'SVG', title: 'Morph(path d)', url: 'svg/test_morph_path.html' },
  311. // Callbacks
  312. { group: 'Callbacks', title: 'onUpdate', url: 'test_on_update.html' },
  313. // Examples
  314. { group: 'Examples', title: 'Controls', url: 'examples/controls.html' },
  315. { group: 'Examples', title: 'Layer', url: 'examples/layer.html' },
  316. // Layer
  317. { group: 'Layer', title: 'Layer 概览', url: 'layer/overview.html' },
  318. { group: 'Layer', title: 'SVG Icon animation', url: 'layer/test_icons_svg_animation.html' },
  319. { group: 'Layer', title: 'Confirm flow', url: 'layer/test_confirm_flow.html' },
  320. { group: 'Layer', title: 'Selection.layer + dataset', url: 'layer/test_selection_layer_dataset.html' },
  321. { group: 'Layer', title: 'Static API / Builder API', url: 'layer/test_static_fire.html' },
  322. // Developer
  323. { group: 'Developer', title: '模块开发与测试指南', url: 'module.html' }
  324. ];
  325. function normalizeDocUrl(url) {
  326. const raw = String(url || '');
  327. const noHash = raw.split('#')[0];
  328. const noQuery = noHash.split('?')[0];
  329. return String(noQuery || '')
  330. .replace(/^[#/]+/, '')
  331. .replace(/^\.\//, '')
  332. .replace(/^\/+/, '');
  333. }
  334. function docFindIndex(currentUrl) {
  335. const u = normalizeDocUrl(currentUrl);
  336. if (!u) return -1;
  337. return DOC_PAGES.findIndex(p => u === p.url || u.endsWith(p.url));
  338. }
  339. function docGetPrevNext(currentUrl) {
  340. const idx = docFindIndex(currentUrl);
  341. if (idx < 0) return { idx: -1, prev: null, next: null, current: null };
  342. const prev = (idx > 0) ? DOC_PAGES[idx - 1] : null;
  343. const next = (idx < DOC_PAGES.length - 1) ? DOC_PAGES[idx + 1] : null;
  344. return { idx, prev, next, current: DOC_PAGES[idx] };
  345. }
  346. function docNavigatePrev(currentUrl) {
  347. const { prev } = docGetPrevNext(currentUrl);
  348. if (prev) loadContent(prev.url);
  349. }
  350. function docNavigateNext(currentUrl) {
  351. const { next } = docGetPrevNext(currentUrl);
  352. if (next) loadContent(next.url);
  353. }
  354. // Expose to iframes (same origin)
  355. window.docGetPrevNext = docGetPrevNext;
  356. window.docNavigatePrev = docNavigatePrev;
  357. window.docNavigateNext = docNavigateNext;
  358. // =============================
  359. // Middle ↔ Right connection line
  360. // =============================
  361. const connectionSvg = document.getElementById('column-connection-line');
  362. const connectionPath = document.getElementById('column-connection-path');
  363. let _connRaf = 0;
  364. function scheduleConnectionLineUpdate() {
  365. if (_connRaf) return;
  366. _connRaf = requestAnimationFrame(() => {
  367. _connRaf = 0;
  368. updateConnectionLine();
  369. });
  370. }
  371. function getActiveElementInFrame(frameEl) {
  372. try {
  373. const doc = frameEl?.contentDocument;
  374. if (!doc) return null;
  375. // Middle list pages use .card.active / .header-card.active; fall back to .active
  376. return (
  377. doc.querySelector('.card.active') ||
  378. doc.querySelector('.header-card.active') ||
  379. doc.querySelector('.nav-item.active') ||
  380. doc.querySelector('.active')
  381. );
  382. } catch {
  383. return null;
  384. }
  385. }
  386. function getAnchorElementInContentFrame(frameEl) {
  387. try {
  388. const doc = frameEl?.contentDocument;
  389. if (!doc) return null;
  390. // Prefer a *visible* code area anchor (in-viewport), then fall back
  391. const candidates = [
  392. '.box-container .box-header',
  393. '.code-view.active, .html-view.active, .css-view.active',
  394. '.box-container',
  395. 'h1',
  396. '.container',
  397. 'body'
  398. ];
  399. for (const sel of candidates) {
  400. const el = doc.querySelector(sel);
  401. if (!el) continue;
  402. // If it's visible in the iframe viewport, use it; else keep looking
  403. const r = el.getBoundingClientRect();
  404. const vh = frameEl?.clientHeight || 0;
  405. if (!vh) return el;
  406. const visibleTop = Math.max(0, r.top);
  407. const visibleBottom = Math.min(vh, r.bottom);
  408. if (visibleBottom - visibleTop > 8) return el;
  409. }
  410. return doc.body;
  411. } catch {
  412. return null;
  413. }
  414. }
  415. function clamp(n, min, max) {
  416. return Math.min(Math.max(n, min), max);
  417. }
  418. function getVisibleCenterInFrame(frameEl, elRect) {
  419. const w = frameEl?.clientWidth || 0;
  420. const h = frameEl?.clientHeight || 0;
  421. if (!w || !h) return null;
  422. const visibleLeft = Math.max(0, elRect.left);
  423. const visibleRight = Math.min(w, elRect.right);
  424. const visibleTop = Math.max(0, elRect.top);
  425. const visibleBottom = Math.min(h, elRect.bottom);
  426. if (visibleRight - visibleLeft <= 1 || visibleBottom - visibleTop <= 1) {
  427. return null;
  428. }
  429. return {
  430. x: (visibleLeft + visibleRight) / 2,
  431. y: (visibleTop + visibleBottom) / 2
  432. };
  433. }
  434. function updateConnectionLine() {
  435. if (!connectionSvg || !connectionPath) return;
  436. const middleFrame = document.getElementById('middle-frame');
  437. const contentFrame = document.getElementById('content-frame');
  438. if (!middleFrame || !contentFrame) return;
  439. const midRect = middleFrame.getBoundingClientRect();
  440. const rightRect = contentFrame.getBoundingClientRect();
  441. const active = getActiveElementInFrame(middleFrame);
  442. const anchor = getAnchorElementInContentFrame(contentFrame);
  443. if (!active || !anchor) {
  444. connectionPath.setAttribute('d', '');
  445. connectionSvg.style.opacity = '0';
  446. return;
  447. }
  448. const activeRect = active.getBoundingClientRect();
  449. const anchorRect = anchor.getBoundingClientRect();
  450. // Use the *visible* part of the element within its iframe viewport
  451. const activeCenter = getVisibleCenterInFrame(middleFrame, activeRect);
  452. const anchorCenter = getVisibleCenterInFrame(contentFrame, anchorRect);
  453. if (!activeCenter || !anchorCenter) {
  454. // If either side isn't visible in its iframe, hide the line (prevents weird drifting)
  455. connectionPath.setAttribute('d', '');
  456. connectionSvg.style.opacity = '0';
  457. return;
  458. }
  459. // Convert iframe-viewport coordinates to parent viewport coordinates
  460. const startX = midRect.left + clamp(activeRect.right, 0, middleFrame.clientWidth);
  461. const startY = midRect.top + activeCenter.y;
  462. // Point into the code area a bit (not exactly at left edge)
  463. const endX = rightRect.left + clamp(anchorRect.left + 18, 12, contentFrame.clientWidth - 12);
  464. const endY = rightRect.top + anchorCenter.y;
  465. // Draw an L-shaped polyline.
  466. // Keep the vertical segment aligned with the column divider (middle ↔ right).
  467. const dividerX = rightRect.left + 0.5; // half-pixel for crisper stroke alignment
  468. const x1 = Math.max(startX + 12, dividerX);
  469. const d = [
  470. `M ${startX} ${startY}`,
  471. `L ${x1} ${startY}`,
  472. `L ${x1} ${endY}`,
  473. `L ${endX} ${endY}`
  474. ].join(' ');
  475. connectionPath.setAttribute('d', d);
  476. connectionSvg.style.opacity = '0.85';
  477. }
  478. function attachFrameScrollListeners(frameEl) {
  479. if (!frameEl) return;
  480. const onScroll = () => {
  481. markFrameScrolling(frameEl);
  482. scheduleConnectionLineUpdate();
  483. };
  484. try {
  485. // Window scroll inside iframe
  486. frameEl.contentWindow?.addEventListener('scroll', onScroll, { passive: true });
  487. // Some pages scroll on document/body; capture to be safe
  488. frameEl.contentDocument?.addEventListener('scroll', onScroll, true);
  489. frameEl.contentDocument?.documentElement?.addEventListener?.('scroll', onScroll, { passive: true });
  490. frameEl.contentDocument?.body?.addEventListener?.('scroll', onScroll, { passive: true });
  491. } catch {}
  492. }
  493. const _scrollHideTimers = new WeakMap();
  494. function markFrameScrolling(frameEl) {
  495. try {
  496. const doc = frameEl?.contentDocument;
  497. if (!doc) return;
  498. doc.documentElement?.classList.add('scrolling');
  499. doc.body?.classList.add('scrolling');
  500. const prev = _scrollHideTimers.get(frameEl);
  501. if (prev) clearTimeout(prev);
  502. _scrollHideTimers.set(frameEl, setTimeout(() => {
  503. try {
  504. doc.documentElement?.classList.remove('scrolling');
  505. doc.body?.classList.remove('scrolling');
  506. } catch {}
  507. }, 500));
  508. } catch {}
  509. }
  510. // Always-on lightweight loop to keep the line aligned even
  511. // if iframe scroll events were missed due to timing.
  512. let _connLoopStarted = false;
  513. function startConnectionLineLoop() {
  514. if (_connLoopStarted) return;
  515. _connLoopStarted = true;
  516. const loop = () => {
  517. // Only bother when we have a path (avoids work when hidden)
  518. if (connectionPath?.getAttribute('d')) {
  519. scheduleConnectionLineUpdate();
  520. }
  521. requestAnimationFrame(loop);
  522. };
  523. requestAnimationFrame(loop);
  524. }
  525. // Make initial active state robust against iframe load ordering
  526. window.addEventListener('load', () => {
  527. const contentFrame = document.getElementById('content-frame');
  528. const src = contentFrame?.getAttribute('src');
  529. if (src) setMiddleActive(src);
  530. const middleFrame = document.getElementById('middle-frame');
  531. if (middleFrame) {
  532. middleFrame.addEventListener('load', () => {
  533. const current = document.getElementById('content-frame')?.getAttribute('src');
  534. if (current) setMiddleActive(current);
  535. attachFrameScrollListeners(middleFrame);
  536. scheduleConnectionLineUpdate();
  537. });
  538. }
  539. if (contentFrame) {
  540. contentFrame.addEventListener('load', () => {
  541. const current = contentFrame.getAttribute('src');
  542. if (current) setMiddleActive(current);
  543. attachFrameScrollListeners(contentFrame);
  544. scheduleConnectionLineUpdate();
  545. });
  546. }
  547. // If the iframes were already loaded before we attached 'load' listeners,
  548. // still attach scroll listeners immediately.
  549. attachFrameScrollListeners(middleFrame);
  550. attachFrameScrollListeners(contentFrame);
  551. window.addEventListener('resize', scheduleConnectionLineUpdate, { passive: true });
  552. scheduleConnectionLineUpdate();
  553. startConnectionLineLoop();
  554. });
  555. </script>
  556. </body>
  557. </html>