ngwr 16.4.0 → 16.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/back-top/styles/_index.scss +6 -0
- package/breadcrumbs/styles/_rules.scss +34 -0
- package/cascader/styles/_rules.scss +7 -0
- package/charts/bar-chart/styles/_index.scss +494 -305
- package/charts/boxplot-chart/styles/_index.scss +114 -48
- package/charts/bullet-chart/styles/_index.scss +113 -42
- package/charts/calendar-heatmap/styles/_index.scss +111 -20
- package/charts/candlestick-chart/styles/_index.scss +61 -26
- package/charts/chart-legend/styles/_index.scss +120 -10
- package/charts/core/styles/_index.scss +201 -5
- package/charts/donut-chart/styles/_index.scss +76 -21
- package/charts/funnel-chart/styles/_index.scss +66 -38
- package/charts/gauge/styles/_index.scss +12 -1
- package/charts/heatmap-chart/styles/_index.scss +90 -53
- package/charts/line-chart/styles/_index.scss +143 -139
- package/charts/meter-group/styles/_index.scss +87 -25
- package/charts/radar-chart/styles/_index.scss +82 -40
- package/charts/scatter-chart/styles/_index.scss +117 -44
- package/charts/sparkline/styles/_index.scss +7 -1
- package/charts/treemap-chart/styles/_index.scss +94 -42
- package/charts/waterfall-chart/styles/_index.scss +150 -87
- package/color-picker/styles/_index.scss +7 -3
- package/copy-value/styles/_index.scss +21 -2
- package/counter/styles/_index.scss +1 -8
- package/date-picker/styles/_index.scss +15 -9
- package/date-stamp/styles/_index.scss +2 -1
- package/dialog/styles/_index.scss +43 -0
- package/drawer/styles/_index.scss +5 -1
- package/editor/styles/_index.scss +1 -8
- package/event-calendar/styles/_index.scss +2 -6
- package/fesm2022/ngwr-affix.mjs +1 -1
- package/fesm2022/ngwr-affix.mjs.map +1 -1
- package/fesm2022/ngwr-anchor.mjs +9 -2
- package/fesm2022/ngwr-anchor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-aurora.mjs.map +1 -1
- package/fesm2022/ngwr-animations-blur-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-click-sparks.mjs.map +1 -1
- package/fesm2022/ngwr-animations-confetti.mjs.map +1 -1
- package/fesm2022/ngwr-animations-decode.mjs.map +1 -1
- package/fesm2022/ngwr-animations-destruct.mjs.map +1 -1
- package/fesm2022/ngwr-animations-dot-grid.mjs.map +1 -1
- package/fesm2022/ngwr-animations-falling-letters.mjs.map +1 -1
- package/fesm2022/ngwr-animations-flow-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-fluid-cursor.mjs.map +1 -1
- package/fesm2022/ngwr-animations-glitch.mjs.map +1 -1
- package/fesm2022/ngwr-animations-glow-border.mjs.map +1 -1
- package/fesm2022/ngwr-animations-gradient-flow.mjs.map +1 -1
- package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
- package/fesm2022/ngwr-animations-orbit.mjs.map +1 -1
- package/fesm2022/ngwr-animations-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-ripple-grid.mjs.map +1 -1
- package/fesm2022/ngwr-animations-rotate-reveal.mjs.map +1 -1
- package/fesm2022/ngwr-animations-shimmer.mjs.map +1 -1
- package/fesm2022/ngwr-animations-spotlight.mjs.map +1 -1
- package/fesm2022/ngwr-animations-thread-lines.mjs.map +1 -1
- package/fesm2022/ngwr-animations-tilt.mjs +20 -13
- package/fesm2022/ngwr-animations-tilt.mjs.map +1 -1
- package/fesm2022/ngwr-animations-typewriter.mjs.map +1 -1
- package/fesm2022/ngwr-breadcrumbs.mjs +40 -7
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-button.mjs +12 -3
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-carousel-testing.mjs +4 -1
- package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +27 -2
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +72 -8
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
- package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
- package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
- package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
- package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
- package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +311 -23
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
- package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge.mjs +98 -12
- package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
- package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
- package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
- package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
- package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +225 -31
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
- package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
- package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
- package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
- package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
- package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
- package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +3 -2
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +65 -5
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +51 -24
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
- package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value.mjs +38 -2
- package/fesm2022/ngwr-copy-value.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +105 -9
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +29 -11
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +9 -6
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +19 -3
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +35 -6
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +1 -0
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +20 -9
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +170 -3
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-graph.mjs +81 -13
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +20 -0
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +20 -0
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +20 -0
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +20 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +20 -0
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +20 -0
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +20 -0
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +20 -0
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +20 -0
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +20 -0
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +20 -0
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +20 -0
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +20 -0
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +20 -0
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +20 -0
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +20 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +20 -0
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +20 -0
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +20 -0
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +20 -0
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +20 -0
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +20 -0
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +82 -11
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +24 -1
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +2 -2
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +10 -2
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +20 -3
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +1 -1
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar-router.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar.mjs +2 -2
- package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
- package/fesm2022/ngwr-mention.mjs +8 -0
- package/fesm2022/ngwr-mention.mjs.map +1 -1
- package/fesm2022/ngwr-meta.mjs +9 -6
- package/fesm2022/ngwr-meta.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +21 -2
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-page-header.mjs +21 -0
- package/fesm2022/ngwr-page-header.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +2 -0
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +8 -1
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +43 -6
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +114 -15
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-qr.mjs +6 -2
- package/fesm2022/ngwr-qr.mjs.map +1 -1
- package/fesm2022/ngwr-radio.mjs +71 -5
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +12 -1
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +1 -3
- package/fesm2022/ngwr-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +20 -0
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +80 -9
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list.mjs +16 -4
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-storage.mjs +1 -1
- package/fesm2022/ngwr-storage.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +2 -2
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +43 -7
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +2 -2
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-toast.mjs +28 -0
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +16 -11
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +49 -16
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +20 -0
- package/fesm2022/ngwr-typography.mjs.map +1 -1
- package/fesm2022/ngwr-utils-router.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +46 -4
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-validators.mjs +33 -1
- package/fesm2022/ngwr-validators.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +16 -9
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/form/styles/_index.scss +37 -0
- package/graph/styles/_index.scss +1 -9
- package/i18n/ar.json +20 -0
- package/i18n/cs.json +20 -0
- package/i18n/de.json +20 -0
- package/i18n/en.json +20 -0
- package/i18n/es.json +20 -0
- package/i18n/fr.json +20 -0
- package/i18n/he.json +20 -0
- package/i18n/hi.json +20 -0
- package/i18n/id.json +20 -0
- package/i18n/it.json +20 -0
- package/i18n/ja.json +20 -0
- package/i18n/ko.json +20 -0
- package/i18n/nl.json +20 -0
- package/i18n/pl.json +20 -0
- package/i18n/pt.json +20 -0
- package/i18n/ru.json +20 -0
- package/i18n/sv.json +20 -0
- package/i18n/tr.json +20 -0
- package/i18n/uk.json +20 -0
- package/i18n/vi.json +20 -0
- package/i18n/zh-TW.json +20 -0
- package/i18n/zh.json +20 -0
- package/image-cropper/styles/_index.scss +1 -9
- package/input-number/styles/_index.scss +7 -0
- package/layout/styles/_index.scss +13 -1
- package/llms-full.txt +17 -17
- package/llms.txt +7 -3
- package/loading-bar/styles/_rules.scss +6 -0
- package/package.json +2 -2
- package/page-header/styles/_index.scss +18 -0
- package/popconfirm/styles/_index.scss +6 -0
- package/popover/styles/_index.scss +31 -13
- package/schematics/use/symbol-map.json +3 -0
- package/segmented/styles/_index.scss +7 -0
- package/select/styles/_index.scss +7 -0
- package/sidebar/styles/_index.scss +6 -0
- package/skills/ngwr/references/catalog.md +2 -2
- package/sortable-list/styles/_rules.scss +1 -9
- package/speed-dial/styles/_index.scss +6 -0
- package/stepper/styles/_index.scss +1 -9
- package/table/styles/_index.scss +49 -0
- package/theme/_index.scss +12 -1
- package/theme/styles/_colors.scss +11 -0
- package/theme/styles/_contrast.scss +6 -0
- package/theme/styles/_index.scss +1 -0
- package/theme/styles/_mixins.scss +45 -0
- package/theme/styles/_print.scss +17 -0
- package/toast/styles/_index.scss +7 -0
- package/tour/styles/_index.scss +14 -0
- package/tree/styles/_index.scss +1 -9
- package/types/ngwr-anchor.d.ts +3 -0
- package/types/ngwr-animations-aurora.d.ts +6 -0
- package/types/ngwr-animations-blur-reveal.d.ts +6 -0
- package/types/ngwr-animations-click-sparks.d.ts +6 -0
- package/types/ngwr-animations-confetti.d.ts +6 -0
- package/types/ngwr-animations-decode.d.ts +6 -0
- package/types/ngwr-animations-destruct.d.ts +6 -0
- package/types/ngwr-animations-dot-grid.d.ts +6 -0
- package/types/ngwr-animations-falling-letters.d.ts +6 -0
- package/types/ngwr-animations-flow-lines.d.ts +6 -0
- package/types/ngwr-animations-fluid-cursor.d.ts +6 -0
- package/types/ngwr-animations-glitch.d.ts +6 -0
- package/types/ngwr-animations-glow-border.d.ts +6 -0
- package/types/ngwr-animations-gradient-flow.d.ts +6 -0
- package/types/ngwr-animations-marquee.d.ts +6 -0
- package/types/ngwr-animations-orbit.d.ts +6 -0
- package/types/ngwr-animations-reveal.d.ts +6 -0
- package/types/ngwr-animations-ripple-grid.d.ts +6 -0
- package/types/ngwr-animations-rotate-reveal.d.ts +6 -0
- package/types/ngwr-animations-shimmer.d.ts +6 -0
- package/types/ngwr-animations-spotlight.d.ts +6 -0
- package/types/ngwr-animations-thread-lines.d.ts +6 -0
- package/types/ngwr-animations-tilt.d.ts +10 -0
- package/types/ngwr-animations-typewriter.d.ts +6 -0
- package/types/ngwr-breadcrumbs.d.ts +25 -0
- package/types/ngwr-button.d.ts +23 -3
- package/types/ngwr-carousel-testing.d.ts +6 -4
- package/types/ngwr-carousel.d.ts +16 -3
- package/types/ngwr-cascader-testing.d.ts +4 -3
- package/types/ngwr-cascader.d.ts +34 -3
- package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
- package/types/ngwr-charts-bar-chart.d.ts +220 -48
- package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
- package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
- package/types/ngwr-charts-bullet-chart.d.ts +72 -12
- package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
- package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
- package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
- package/types/ngwr-charts-chart-legend.d.ts +142 -5
- package/types/ngwr-charts-core.d.ts +275 -21
- package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
- package/types/ngwr-charts-donut-chart.d.ts +124 -16
- package/types/ngwr-charts-funnel-chart.d.ts +62 -6
- package/types/ngwr-charts-gauge-testing.d.ts +5 -1
- package/types/ngwr-charts-gauge.d.ts +72 -10
- package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
- package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
- package/types/ngwr-charts-line-chart.d.ts +215 -86
- package/types/ngwr-charts-meter-group.d.ts +98 -7
- package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
- package/types/ngwr-charts-radar-chart.d.ts +148 -28
- package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
- package/types/ngwr-charts-scatter-chart.d.ts +188 -18
- package/types/ngwr-charts-sparkline.d.ts +26 -4
- package/types/ngwr-charts-treemap-chart.d.ts +121 -23
- package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
- package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
- package/types/ngwr-checkbox.d.ts +1 -0
- package/types/ngwr-color-picker.d.ts +28 -0
- package/types/ngwr-context-menu-testing.d.ts +10 -9
- package/types/ngwr-context-menu.d.ts +18 -1
- package/types/ngwr-copy-value.d.ts +8 -0
- package/types/ngwr-date-picker.d.ts +53 -2
- package/types/ngwr-dialog.d.ts +64 -13
- package/types/ngwr-directives.d.ts +12 -4
- package/types/ngwr-drawer.d.ts +33 -2
- package/types/ngwr-dropdown-testing.d.ts +8 -5
- package/types/ngwr-dropdown.d.ts +29 -6
- package/types/ngwr-event-calendar.d.ts +4 -0
- package/types/ngwr-form.d.ts +85 -1
- package/types/ngwr-graph.d.ts +22 -6
- package/types/ngwr-i18n.d.ts +65 -5
- package/types/ngwr-input-number.d.ts +8 -0
- package/types/ngwr-input.d.ts +7 -0
- package/types/ngwr-layout.d.ts +1 -1
- package/types/ngwr-lightbox.d.ts +15 -0
- package/types/ngwr-loading-bar-router.d.ts +6 -0
- package/types/ngwr-overlay.d.ts +16 -1
- package/types/ngwr-page-header.d.ts +23 -1
- package/types/ngwr-popconfirm-testing.d.ts +11 -2
- package/types/ngwr-popconfirm.d.ts +29 -2
- package/types/ngwr-popover.d.ts +87 -13
- package/types/ngwr-radio.d.ts +47 -5
- package/types/ngwr-segmented.d.ts +7 -0
- package/types/ngwr-select.d.ts +57 -13
- package/types/ngwr-sortable-list.d.ts +20 -7
- package/types/ngwr-table.d.ts +59 -6
- package/types/ngwr-tabs-router.d.ts +6 -0
- package/types/ngwr-toast.d.ts +11 -0
- package/types/ngwr-tour.d.ts +21 -3
- package/types/ngwr-tree-testing.d.ts +1 -2
- package/types/ngwr-tree.d.ts +33 -2
- package/types/ngwr-typography.d.ts +7 -0
- package/types/ngwr-utils-router.d.ts +6 -0
- package/types/ngwr-utils.d.ts +56 -2
- package/types/ngwr-validators.d.ts +49 -1
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr-window.d.ts +14 -11
- package/typography/styles/_index.scss +4 -0
- package/window/styles/_index.scss +6 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-animations-decode.mjs","names":[],"sources":["../../../projects/lib/animations/decode/decode.ts","../../../projects/lib/animations/decode/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { BREAKING_SPACES, FOCUSABLE, VIEW_THRESHOLD, graphemes, optionalMs, staggerGap } from '../internal';\n\nimport type { WrDecodeShape, WrDecodeTrigger } from './types';\n\n/** How long a glyph stays before the next one, in ms: fast enough to read as noise, slow enough to read as glyphs. */\nconst DECODE_GLYPH_MS = 55;\n\n/** How long the whole text scrambles before the first slot locks, in ms. */\nconst DECODE_HOLD = 360;\n\n/** The gap between one slot locking and the next when `stagger` is not set, in ms. */\nconst DECODE_GAP = 36;\n\n/** How long a locked slot takes to ease from the tint to the text colour, in ms. */\nconst DECODE_SETTLE = 240;\n\nconst GLYPHS: Readonly<Record<WrDecodeShape, string>> = {\n upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',\n lower: 'abcdefghijklmnopqrstuvwxyz',\n digit: '0123456789',\n symbol: '#%&*+-=<>?!/\\\\~',\n};\n\n/** The shape of one grapheme: what its random stand-ins are drawn from. */\nfunction decodeShape(grapheme: string): WrDecodeShape {\n if (/^\\d$/.test(grapheme)) return 'digit';\n const upper = grapheme.toUpperCase();\n const lower = grapheme.toLowerCase();\n if (upper === lower) return 'symbol';\n return grapheme === upper ? 'upper' : 'lower';\n}\n\n/** A random glyph from `glyphs`, another than `current` when there is a choice, so every reroll is a visible change. */\nfunction pick(glyphs: readonly string[], current?: string): string {\n if (glyphs.length < 2) return glyphs[0] ?? '';\n let glyph: string;\n do {\n glyph = glyphs[Math.floor(Math.random() * glyphs.length)];\n } while (glyph === current);\n return glyph;\n}\n\ninterface DecodeSlot {\n readonly el: HTMLElement;\n readonly glyphs: readonly string[];\n /** When the slot locks, in ms from the first glyph. */\n readonly at: number;\n locked: boolean;\n}\n\n/**\n * A readout locking on: when it plays, every character of the host's text\n * shows random glyphs that change quickly, then settles on its real character,\n * one after another in reading order. The line never moves while it plays:\n * the real character stays in its slot, hidden, and the glyph is painted over\n * it, centred, out of flow, so a wide stand-in may overlap its neighbour but\n * never pushes it. A glyph keeps the shape of the character it stands in for\n * (upper, lower, digit, or a symbol for punctuation) so the word shape stays\n * readable; spaces never scramble. The host keeps its own tag and its authored\n * children: they are moved out while the slots play and the same nodes are\n * moved back when the last slot has settled, so selection, find-in-page and\n * Angular bindings inside work as before. While split, the slots are\n * `aria-hidden` and a visually-hidden copy of the text stands beside them, so\n * a screen reader hears the text once and never the noise. Nothing plays\n * under `prefers-reduced-motion: reduce`, on the server or, in `view` mode,\n * without `IntersectionObserver`.\n */\n@Directive({\n selector: '[wrDecode]',\n host: { class: 'wr-decode' },\n})\nexport class WrDecode {\n /**\n * `view` plays once, the first time most of the host is in the viewport.\n * `hover` plays on every pointer enter and focus of the host or its closest\n * focusable ancestor, but never restarts while already playing. @default 'view'\n */\n readonly trigger = input<WrDecodeTrigger>('view');\n\n /**\n * The characters random glyphs are drawn from, for every slot. Unset, each\n * slot draws from the shape of its own character: uppercase letters and\n * digits for an uppercase letter, lowercase for lowercase, digits for a digit,\n * a few symbols for anything else.\n */\n readonly glyphs = input<string | null>(null);\n\n /**\n * Gap between one slot locking and the next, in ms. Unset, 36. Either way\n * the locks spread over 1.2 s at most, so for a long text the gap shrinks\n * until the last slot locks by then.\n */\n readonly stagger = input<number | null, unknown>(null, { transform: optionalMs });\n\n /** Pause between the trigger and the first glyph, in ms. The text stands as authored meanwhile. @default 0 */\n readonly delay = input(0, { transform: wrNumAttr(0) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private observer: IntersectionObserver | null = null;\n private listeners: AbortController | null = null;\n private frame = 0;\n /** The host's authored children while they are out of the DOM, else `null`. */\n private original: ChildNode[] | null = null;\n private slots: DecodeSlot[] = [];\n private started: number | null = null;\n private lastGlyph = -Infinity;\n private playing = false;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/decode');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n if (this.trigger() === 'hover') {\n this.listen();\n return;\n }\n if (typeof IntersectionObserver === 'undefined') return;\n this.observer = new IntersectionObserver(\n entries => {\n if (!entries.some(entry => entry.isIntersecting)) return;\n this.observer?.disconnect();\n this.observer = null;\n this.start();\n },\n { threshold: VIEW_THRESHOLD }\n );\n this.observer.observe(this.host.nativeElement);\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.observer?.disconnect();\n this.observer = null;\n this.listeners?.abort();\n this.listeners = null;\n this.restore();\n });\n }\n\n /** `hover` mode: the closest focusable ancestor is what a keyboard reaches, so it is what both events are read on. */\n private listen(): void {\n const host = this.host.nativeElement;\n const target = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n target.addEventListener('pointerenter', () => this.start(), options);\n target.addEventListener('focusin', () => this.start(), options);\n }\n\n /** Begin a play, unless one is running or motion is reduced now. The DOM is touched only once the delay has passed. */\n private start(): void {\n if (this.playing || this.platform.prefersReducedMotion()) return;\n this.playing = true;\n this.started = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n private tick(now: number): void {\n this.started ??= now;\n const elapsed = now - this.started - Math.max(0, this.delay());\n if (elapsed < 0) {\n this.frame = requestAnimationFrame(t => this.tick(t));\n return;\n }\n if (!this.original) {\n this.arm();\n if (!this.original) return;\n }\n\n const reroll = now - this.lastGlyph >= DECODE_GLYPH_MS;\n if (reroll) this.lastGlyph = now;\n let busy = false;\n for (const slot of this.slots) {\n if (slot.locked) continue;\n if (elapsed >= slot.at) {\n slot.locked = true;\n slot.el.classList.remove('wr-decode__slot--scramble');\n continue;\n }\n busy = true;\n if (reroll) slot.el.dataset['glyph'] = pick(slot.glyphs, slot.el.dataset['glyph']);\n }\n if (!busy && elapsed >= this.slots[this.slots.length - 1].at + DECODE_SETTLE) {\n this.restore();\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Split the authored children into slots and scramble them in one task, so\n * the first frame the slots can be seen in already shows glyphs. A slot holds\n * its real character as its only text; the glyph lives in `data-glyph` and is\n * painted by the stylesheet, so the slot's width is the character's.\n */\n private arm(): void {\n const host = this.host.nativeElement;\n const original = Array.from(host.childNodes);\n const text = host.textContent ?? '';\n const custom = this.glyphs();\n const wrapper = document.createElement('span');\n wrapper.className = 'wr-decode__slots';\n wrapper.setAttribute('aria-hidden', 'true');\n const slots: DecodeSlot[] = [];\n\n for (const node of original) {\n if (node.nodeType !== Node.TEXT_NODE) {\n // An inline element (`<code>`, `<a>`) moves whole and does not scramble; a comment keeps its place.\n wrapper.append(node);\n continue;\n }\n // `split` on a capturing group alternates: a run of text, then the spaces after it.\n (node.textContent ?? '').split(BREAKING_SPACES).forEach((run, i) => {\n if (run === '') return;\n if (i % 2 === 1) {\n wrapper.append(run);\n return;\n }\n for (const grapheme of graphemes(run)) {\n if (/^\\s+$/.test(grapheme)) {\n wrapper.append(grapheme);\n continue;\n }\n const shape = decodeShape(grapheme);\n const el = document.createElement('span');\n el.className = `wr-decode__slot wr-decode__slot--${shape} wr-decode__slot--scramble`;\n el.textContent = grapheme;\n slots.push({\n el,\n glyphs: [...new Set(graphemes(custom && custom.length > 0 ? custom : GLYPHS[shape]))],\n at: 0,\n locked: false,\n });\n wrapper.append(el);\n }\n });\n }\n\n if (slots.length === 0) {\n this.playing = false;\n return;\n }\n\n const gap = staggerGap('letters', slots.length, this.stagger() ?? DECODE_GAP);\n this.slots = slots.map((slot, i) => ({ ...slot, at: DECODE_HOLD + i * gap }));\n this.lastGlyph = -Infinity;\n for (const slot of this.slots) slot.el.dataset['glyph'] = pick(slot.glyphs);\n\n const copy = document.createElement('span');\n copy.className = 'wr-decode__sr';\n copy.textContent = text;\n\n this.original = original;\n wrapper.style.setProperty('--wr-decode-settle', `${DECODE_SETTLE}ms`);\n host.replaceChildren(wrapper, copy);\n host.classList.add('wr-decode--run');\n }\n\n /**\n * Put the authored children back, the same node objects, drop the slots and\n * stop the frames. Idempotent: the end of a play and destroy both call it.\n */\n private restore(): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.playing = false;\n this.started = null;\n if (!this.original) return;\n const host = this.host.nativeElement;\n host.replaceChildren(...this.original);\n host.classList.remove('wr-decode--run');\n this.original = null;\n this.slots = [];\n }\n}\n\n// The timings and the shape rule, for the spec; the entry point does not export them.\nexport { DECODE_GAP, DECODE_GLYPH_MS, DECODE_HOLD, DECODE_SETTLE, decodeShape };\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrDecode } from './decode';\nexport type { WrDecodeShape, WrDecodeTrigger } from './types';\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,SAAkD;CACtD,OAAO;CACP,OAAO;CACP,OAAO;CACP,QAAQ;AACT;AAGD,SAAS,YAAY,UAAgB;CACnC,IAAI,OAAO,KAAK,QAAQ,GAAG,OAAO;CAClC,MAAM,QAAQ,SAAS,YAAW;CAElC,IAAI,UADU,SAAS,YACT,GAAO,OAAO;CAC5B,OAAO,aAAa,QAAQ,UAAU;AACxC;AAGA,SAAS,KAAK,QAA2B,SAAgB;CACvD,IAAI,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM;CAC3C,IAAI;CACJ;EACE,QAAQ,OAAO,KAAK,MAAM,KAAK,OAAM,IAAK,OAAO,MAAM;QAChD,UAAU;CACnB,OAAO;AACT;AA+BA,IAAa,WAAb,MAAa,SAAQ;CAMV,UAAU,MAAuB,QAAO,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAQxC,SAAS,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAOnC,UAAU,MAA8B,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,WAAW;CAAU,CAAA;CAGrE,QAAQ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,UAAO;EACb,qBAAqB,KAAK,KAAK;EAC/B,KAAK,QAAQ;EACb,KAAK,UAAU;EACf,KAAK,UAAU;EACf,IAAI,CAAC,KAAK,UAAU;EACpB,MAAM,OAAO,KAAK,KAAK;EACvB,KAAK,gBAAgB,GAAG,KAAK,QAAQ;EACrC,KAAK,UAAU,OAAO,gBAAgB;EACtC,KAAK,WAAW;EAChB,KAAK,QAAQ,CAAA;CACf;CA5MW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAQ,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,QAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,gBAAA,YAAA;EAAA,UAAA;CAAA,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EAJpB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,OAAO,YAAW;EAC3B,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-animations-decode.mjs","names":[],"sources":["../../../projects/lib/animations/decode/decode.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Directive, ElementRef, PLATFORM_ID, afterNextRender, inject, input } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { BREAKING_SPACES, FOCUSABLE, VIEW_THRESHOLD, graphemes, optionalMs, staggerGap } from '../internal';\n\nimport type { WrDecodeShape, WrDecodeTrigger } from './types';\n\n/** How long a glyph stays before the next one, in ms: fast enough to read as noise, slow enough to read as glyphs. */\nconst DECODE_GLYPH_MS = 55;\n\n/** How long the whole text scrambles before the first slot locks, in ms. */\nconst DECODE_HOLD = 360;\n\n/** The gap between one slot locking and the next when `stagger` is not set, in ms. */\nconst DECODE_GAP = 36;\n\n/** How long a locked slot takes to ease from the tint to the text colour, in ms. */\nconst DECODE_SETTLE = 240;\n\nconst GLYPHS: Readonly<Record<WrDecodeShape, string>> = {\n upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',\n lower: 'abcdefghijklmnopqrstuvwxyz',\n digit: '0123456789',\n symbol: '#%&*+-=<>?!/\\\\~',\n};\n\n/** The shape of one grapheme: what its random stand-ins are drawn from. */\nfunction decodeShape(grapheme: string): WrDecodeShape {\n if (/^\\d$/.test(grapheme)) return 'digit';\n const upper = grapheme.toUpperCase();\n const lower = grapheme.toLowerCase();\n if (upper === lower) return 'symbol';\n return grapheme === upper ? 'upper' : 'lower';\n}\n\n/** A random glyph from `glyphs`, another than `current` when there is a choice, so every reroll is a visible change. */\nfunction pick(glyphs: readonly string[], current?: string): string {\n if (glyphs.length < 2) return glyphs[0] ?? '';\n let glyph: string;\n do {\n glyph = glyphs[Math.floor(Math.random() * glyphs.length)];\n } while (glyph === current);\n return glyph;\n}\n\ninterface DecodeSlot {\n readonly el: HTMLElement;\n readonly glyphs: readonly string[];\n /** When the slot locks, in ms from the first glyph. */\n readonly at: number;\n locked: boolean;\n}\n\n/**\n * A readout locking on: when it plays, every character of the host's text\n * shows random glyphs that change quickly, then settles on its real character,\n * one after another in reading order. The line never moves while it plays:\n * the real character stays in its slot, hidden, and the glyph is painted over\n * it, centred, out of flow, so a wide stand-in may overlap its neighbour but\n * never pushes it. A glyph keeps the shape of the character it stands in for\n * (upper, lower, digit, or a symbol for punctuation) so the word shape stays\n * readable; spaces never scramble. The host keeps its own tag and its authored\n * children: they are moved out while the slots play and the same nodes are\n * moved back when the last slot has settled, so selection, find-in-page and\n * Angular bindings inside work as before. While split, the slots are\n * `aria-hidden` and a visually-hidden copy of the text stands beside them, so\n * a screen reader hears the text once and never the noise. Nothing plays\n * under `prefers-reduced-motion: reduce`, on the server or, in `view` mode,\n * without `IntersectionObserver`.\n */\n@Directive({\n selector: '[wrDecode]',\n host: { class: 'wr-decode' },\n})\nexport class WrDecode {\n /**\n * `view` plays once, the first time most of the host is in the viewport.\n * `hover` plays on every pointer enter and focus of the host or its closest\n * focusable ancestor, but never restarts while already playing. @default 'view'\n */\n readonly trigger = input<WrDecodeTrigger>('view');\n\n /**\n * The characters random glyphs are drawn from, for every slot. Unset, each\n * slot draws from the shape of its own character: uppercase letters and\n * digits for an uppercase letter, lowercase for lowercase, digits for a digit,\n * a few symbols for anything else.\n */\n readonly glyphs = input<string | null>(null);\n\n /**\n * Gap between one slot locking and the next, in ms. Unset, 36. Either way\n * the locks spread over 1.2 s at most, so for a long text the gap shrinks\n * until the last slot locks by then.\n */\n readonly stagger = input<number | null, unknown>(null, { transform: optionalMs });\n\n /** Pause between the trigger and the first glyph, in ms. The text stands as authored meanwhile. @default 0 */\n readonly delay = input(0, { transform: wrNumAttr(0) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private observer: IntersectionObserver | null = null;\n private listeners: AbortController | null = null;\n private frame = 0;\n /** The host's authored children while they are out of the DOM, else `null`. */\n private original: ChildNode[] | null = null;\n private slots: DecodeSlot[] = [];\n private started: number | null = null;\n private lastGlyph = -Infinity;\n private playing = false;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/decode');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n if (this.trigger() === 'hover') {\n this.listen();\n return;\n }\n if (typeof IntersectionObserver === 'undefined') return;\n this.observer = new IntersectionObserver(\n entries => {\n if (!entries.some(entry => entry.isIntersecting)) return;\n this.observer?.disconnect();\n this.observer = null;\n this.start();\n },\n { threshold: VIEW_THRESHOLD }\n );\n this.observer.observe(this.host.nativeElement);\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.observer?.disconnect();\n this.observer = null;\n this.listeners?.abort();\n this.listeners = null;\n this.restore();\n });\n }\n\n /** `hover` mode: the closest focusable ancestor is what a keyboard reaches, so it is what both events are read on. */\n private listen(): void {\n const host = this.host.nativeElement;\n const target = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n target.addEventListener('pointerenter', () => this.start(), options);\n target.addEventListener('focusin', () => this.start(), options);\n }\n\n /** Begin a play, unless one is running or motion is reduced now. The DOM is touched only once the delay has passed. */\n private start(): void {\n if (this.playing || this.platform.prefersReducedMotion()) return;\n this.playing = true;\n this.started = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n private tick(now: number): void {\n this.started ??= now;\n const elapsed = now - this.started - Math.max(0, this.delay());\n if (elapsed < 0) {\n this.frame = requestAnimationFrame(t => this.tick(t));\n return;\n }\n if (!this.original) {\n this.arm();\n if (!this.original) return;\n }\n\n const reroll = now - this.lastGlyph >= DECODE_GLYPH_MS;\n if (reroll) this.lastGlyph = now;\n let busy = false;\n for (const slot of this.slots) {\n if (slot.locked) continue;\n if (elapsed >= slot.at) {\n slot.locked = true;\n slot.el.classList.remove('wr-decode__slot--scramble');\n continue;\n }\n busy = true;\n if (reroll) slot.el.dataset['glyph'] = pick(slot.glyphs, slot.el.dataset['glyph']);\n }\n if (!busy && elapsed >= this.slots[this.slots.length - 1].at + DECODE_SETTLE) {\n this.restore();\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Split the authored children into slots and scramble them in one task, so\n * the first frame the slots can be seen in already shows glyphs. A slot holds\n * its real character as its only text; the glyph lives in `data-glyph` and is\n * painted by the stylesheet, so the slot's width is the character's.\n */\n private arm(): void {\n const host = this.host.nativeElement;\n const original = Array.from(host.childNodes);\n const text = host.textContent ?? '';\n const custom = this.glyphs();\n const wrapper = document.createElement('span');\n wrapper.className = 'wr-decode__slots';\n wrapper.setAttribute('aria-hidden', 'true');\n const slots: DecodeSlot[] = [];\n\n for (const node of original) {\n if (node.nodeType !== Node.TEXT_NODE) {\n // An inline element (`<code>`, `<a>`) moves whole and does not scramble; a comment keeps its place.\n wrapper.append(node);\n continue;\n }\n // `split` on a capturing group alternates: a run of text, then the spaces after it.\n (node.textContent ?? '').split(BREAKING_SPACES).forEach((run, i) => {\n if (run === '') return;\n if (i % 2 === 1) {\n wrapper.append(run);\n return;\n }\n for (const grapheme of graphemes(run)) {\n if (/^\\s+$/.test(grapheme)) {\n wrapper.append(grapheme);\n continue;\n }\n const shape = decodeShape(grapheme);\n const el = document.createElement('span');\n el.className = `wr-decode__slot wr-decode__slot--${shape} wr-decode__slot--scramble`;\n el.textContent = grapheme;\n slots.push({\n el,\n glyphs: [...new Set(graphemes(custom && custom.length > 0 ? custom : GLYPHS[shape]))],\n at: 0,\n locked: false,\n });\n wrapper.append(el);\n }\n });\n }\n\n if (slots.length === 0) {\n this.playing = false;\n return;\n }\n\n const gap = staggerGap('letters', slots.length, this.stagger() ?? DECODE_GAP);\n this.slots = slots.map((slot, i) => ({ ...slot, at: DECODE_HOLD + i * gap }));\n this.lastGlyph = -Infinity;\n for (const slot of this.slots) slot.el.dataset['glyph'] = pick(slot.glyphs);\n\n const copy = document.createElement('span');\n copy.className = 'wr-decode__sr';\n copy.textContent = text;\n\n this.original = original;\n wrapper.style.setProperty('--wr-decode-settle', `${DECODE_SETTLE}ms`);\n host.replaceChildren(wrapper, copy);\n host.classList.add('wr-decode--run');\n }\n\n /**\n * Put the authored children back, the same node objects, drop the slots and\n * stop the frames. Idempotent: the end of a play and destroy both call it.\n */\n private restore(): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.playing = false;\n this.started = null;\n if (!this.original) return;\n const host = this.host.nativeElement;\n host.replaceChildren(...this.original);\n host.classList.remove('wr-decode--run');\n this.original = null;\n this.slots = [];\n }\n}\n\n// The timings and the shape rule, for the spec; the entry point does not export them.\nexport { DECODE_GAP, DECODE_GLYPH_MS, DECODE_HOLD, DECODE_SETTLE, decodeShape };\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,SAAkD;CACtD,OAAO;CACP,OAAO;CACP,OAAO;CACP,QAAQ;AACT;AAGD,SAAS,YAAY,UAAgB;CACnC,IAAI,OAAO,KAAK,QAAQ,GAAG,OAAO;CAClC,MAAM,QAAQ,SAAS,YAAW;CAElC,IAAI,UADU,SAAS,YACT,GAAO,OAAO;CAC5B,OAAO,aAAa,QAAQ,UAAU;AACxC;AAGA,SAAS,KAAK,QAA2B,SAAgB;CACvD,IAAI,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM;CAC3C,IAAI;CACJ;EACE,QAAQ,OAAO,KAAK,MAAM,KAAK,OAAM,IAAK,OAAO,MAAM;QAChD,UAAU;CACnB,OAAO;AACT;AA+BA,IAAa,WAAb,MAAa,SAAQ;CAMV,UAAU,MAAuB,QAAO,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAQxC,SAAS,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAOnC,UAAU,MAA8B,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,WAAW;CAAU,CAAA;CAGrE,QAAQ,MAAM,GA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,qBAAqB,KAAK,KAAK;EAC/B,KAAK,QAAQ;EACb,KAAK,UAAU;EACf,KAAK,UAAU;EACf,IAAI,CAAC,KAAK,UAAU;EACpB,MAAM,OAAO,KAAK,KAAK;EACvB,KAAK,gBAAgB,GAAG,KAAK,QAAQ;EACrC,KAAK,UAAU,OAAO,gBAAgB;EACtC,KAAK,WAAW;EAChB,KAAK,QAAQ,CAAA;CACf;CA5MW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAQ,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,QAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,gBAAA,YAAA;EAAA,UAAA;CAAA,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EAJpB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,OAAO,YAAW;EAC3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-animations-destruct.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/destruct/destruct.ts","../../../projects/lib/animations/destruct/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { FOCUSABLE, roundTo } from '../internal';\n\n/** How far a pixel of the text may move at full noise, each way, in em: 2.4px on 16px text. */\nconst DESTRUCT_SHIFT = 0.15;\n\n/**\n * How long one noise field stays before the next replaces it, in ms: about 15\n * fields a second. The displacement eases every frame; only the field steps.\n */\nconst DESTRUCT_STEP = 66;\n\n/** Time constant of the ease in, in seconds: 63% of the way after this long, 95% after three times it. */\nconst RISE = 0.12;\n\n/** Time constant of the ease out, in seconds: the calm is slower than the onset. */\nconst FALL = 0.3;\n\n/** The longest step one frame may integrate, in seconds: a stalled frame eases a little, never jumps. */\nconst MAX_STEP = 0.1;\n\n/** Closer than this to the target, the intensity is the target. */\nconst SNAP = 0.01;\n\n/**\n * How many waves of noise fit in one em, across and down. Across, about one:\n * each letter of a short word leans its own way. Down, more: a line of pixels\n * through a glyph shifts apart from the line under it, the tear of a weak\n * signal. In em so a heading and a footnote wobble alike at their own size.\n */\nconst WAVES_X = 1;\nconst WAVES_Y = 2;\n\n/** Octaves of the fractal noise: the second adds the fine grain over the sway. */\nconst OCTAVES = 2;\n\n/** The fallback font size, in px, where the computed style gives none. */\nconst FONT_SIZE = 16;\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/**\n * Text that wobbles with a fine, living noise, as if seen through heat haze\n * or over a weak signal, while a pointer is over it or focus is in it, and\n * settles back to crisp, still text when the pointer leaves.\n *\n * The text stays real text: no copy, no canvas. One hidden inline `<svg>`,\n * put beside the host, holds a filter of two primitives, `feTurbulence`\n * (fractal noise) feeding `feDisplacementMap`, and the host wears it through\n * `filter: url(#id)` while the noise is above zero. So selection, copy,\n * find-in-page, a screen reader and the host's own styling see the element\n * as it was. The frequency of the noise is set from the host's font size, so\n * the waves are the same share of a glyph at any size, and the peak shift is\n * `shift` em of it, small enough that the word reads at full noise.\n *\n * One `requestAnimationFrame` loop runs only while the noise is above zero:\n * each frame the intensity eases toward its target (one while a pointer is\n * over the host or its closest focusable ancestor, or focus is in it; zero\n * otherwise) by an exponential step, faster in than out, and the\n * displacement's `scale` follows it. The noise field itself steps to a new\n * seed about fifteen times a second, not every frame: often enough to live,\n * seldom enough to read as haze, not a strobe. When the intensity reaches\n * zero the filter comes off the host entirely, the loop idles, and the text\n * renders exactly as without the effect. A hidden document pauses the loop\n * where it is.\n *\n * Nothing mounts under `prefers-reduced-motion: reduce`, under\n * `forced-colors: active` or on the server, and a preference that flips\n * mid-run clears the filter at once. Destroy removes the `<svg>`, the filter\n * and the listeners, and cancels the loop.\n */\n@Directive({\n selector: '[wrDestruct]',\n host: { class: 'wr-destruct' },\n})\nexport class WrDestruct {\n /** How far a pixel of the text may move at full noise, each way, in em of the host's font size. @default 0.15 */\n readonly shift = input(DESTRUCT_SHIFT, { transform: wrNumAttr(DESTRUCT_SHIFT) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private readonly id = wrRandomId('wr-destruct');\n private readonly hot = signal(false);\n private listeners: AbortController | null = null;\n private svg: SVGSVGElement | null = null;\n private turbulence: SVGElement | null = null;\n private map: SVGElement | null = null;\n private frame: number | null = null;\n /** The timestamp of the last frame, or `null` when the next one is the first after a start. */\n private last: number | null = null;\n /** When the noise field last stepped, or `null` before the first step of a run. */\n private stepped: number | null = null;\n private seed = 0;\n private intensity = 0;\n /** The peak shift, in px, for the current run. */\n private peak = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/destruct');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n // The stylesheet paints no filter under forced colours: nothing to mount.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n this.mount();\n this.listen();\n });\n\n // One place decides what the loop does: reduced motion clears, a hidden\n // page pauses, otherwise a frame is asked for and the tick decides when\n // to idle. `shift` is read so a new peak reaches a run in flight.\n effect(() => {\n const hot = this.hot();\n const visible = this.platform.pageVisible();\n const reduced = this.platform.prefersReducedMotion();\n this.shift();\n untracked(() => {\n if (reduced) this.clear();\n else if (!visible) this.pause();\n else if (hot || this.intensity > 0) this.start();\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n this.clear();\n this.svg?.remove();\n this.svg = null;\n this.turbulence = null;\n this.map = null;\n });\n }\n\n /**\n * The filter, in a 0 by 0 `<svg>` right after the host: it lives and dies\n * with the host's subtree, and the host's own nodes are not touched. The\n * region is wider than the box by a quarter each way, so a pixel moved\n * off the edge of the glyphs is drawn, not cut.\n */\n private mount(): void {\n const svg = this.doc.createElementNS(SVG, 'svg');\n svg.setAttribute('class', 'wr-destruct__filter');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n svg.setAttribute('width', '0');\n svg.setAttribute('height', '0');\n const filter = this.doc.createElementNS(SVG, 'filter');\n filter.setAttribute('id', this.id);\n filter.setAttribute('x', '-25%');\n filter.setAttribute('y', '-25%');\n filter.setAttribute('width', '150%');\n filter.setAttribute('height', '150%');\n const turbulence = this.doc.createElementNS(SVG, 'feTurbulence');\n turbulence.setAttribute('type', 'fractalNoise');\n turbulence.setAttribute('numOctaves', String(OCTAVES));\n turbulence.setAttribute('seed', String(this.seed));\n turbulence.setAttribute('result', 'noise');\n const map = this.doc.createElementNS(SVG, 'feDisplacementMap');\n map.setAttribute('in', 'SourceGraphic');\n map.setAttribute('in2', 'noise');\n map.setAttribute('scale', '0');\n map.setAttribute('xChannelSelector', 'R');\n map.setAttribute('yChannelSelector', 'G');\n filter.append(turbulence, map);\n svg.append(filter);\n this.host.nativeElement.after(svg);\n this.svg = svg;\n this.turbulence = turbulence;\n this.map = map;\n }\n\n /** The closest focusable ancestor is what a keyboard reaches, so it is what focus is read on; the pointer is read there too. */\n private listen(): void {\n const host = this.host.nativeElement;\n const source = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n source.addEventListener('pointerenter', () => this.hot.set(true), options);\n source.addEventListener('pointerleave', () => this.hot.set(false), options);\n source.addEventListener('focusin', () => this.hot.set(true), options);\n source.addEventListener('focusout', () => this.hot.set(false), options);\n }\n\n /**\n * Ask for a frame, unless one is pending or nothing is mounted. A run that\n * starts from rest measures the host first: the font size may have changed\n * with the viewport since the last one.\n */\n private start(): void {\n if (this.frame !== null || !this.svg) return;\n if (this.intensity === 0) this.measure();\n this.last = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /** The peak shift and the noise frequency, from the host's font size, so both scale with the text. */\n private measure(): void {\n const computed = this.doc.defaultView?.getComputedStyle(this.host.nativeElement).fontSize;\n const parsed = computed === undefined ? NaN : parseFloat(computed);\n const size = Number.isFinite(parsed) && parsed > 0 ? parsed : FONT_SIZE;\n this.peak = Math.max(0, this.shift()) * size;\n this.turbulence?.setAttribute('baseFrequency', `${roundTo(WAVES_X / size, 4)} ${roundTo(WAVES_Y / size, 4)}`);\n }\n\n /** Drop the pending frame. The intensity and the filter stay where they are, so a restart continues from them. */\n private pause(): void {\n if (this.frame === null) return;\n cancelAnimationFrame(this.frame);\n this.frame = null;\n this.last = null;\n }\n\n /** Off at once: no frame, no filter, intensity zero. */\n private clear(): void {\n this.pause();\n this.intensity = 0;\n this.stepped = null;\n this.paint();\n }\n\n /**\n * One frame: ease the intensity toward its target, step the noise field\n * when its time has come, paint. The first frame after a start has no\n * length, so a pause of any length moves nothing when the loop resumes.\n */\n private tick(now: number): void {\n const dt = this.last === null ? 0 : Math.min(Math.max(0, now - this.last) / 1000, MAX_STEP);\n this.last = now;\n const target = this.hot() ? 1 : 0;\n const glide = target > this.intensity ? RISE : FALL;\n this.intensity += (target - this.intensity) * (1 - Math.exp(-dt / glide));\n if (Math.abs(target - this.intensity) < SNAP) this.intensity = target;\n if (this.intensity > 0 && (this.stepped === null || now - this.stepped >= DESTRUCT_STEP)) {\n this.stepped = now;\n this.turbulence?.setAttribute('seed', String(++this.seed));\n }\n this.paint();\n if (this.intensity === 0 && target === 0) {\n // Still, and asked to be: no frame until a pointer or focus arrives.\n this.frame = null;\n this.last = null;\n this.stepped = null;\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Written to the DOM by hand: a binding would wait for change detection,\n * and this is every frame. At zero the filter comes off the host entirely;\n * above it the displacement's `scale` is twice the shift, since the map\n * moves a pixel by `scale` times the noise's distance from its middle.\n */\n private paint(): void {\n if (!this.map) return;\n const el = this.host.nativeElement;\n if (this.intensity === 0) {\n el.classList.remove('wr-destruct--on');\n el.style.removeProperty('--wr-destruct-filter');\n this.map.setAttribute('scale', '0');\n return;\n }\n this.map.setAttribute('scale', String(roundTo(2 * this.peak * this.intensity, 2)));\n if (!el.classList.contains('wr-destruct--on')) {\n el.style.setProperty('--wr-destruct-filter', `url(#${this.id})`);\n el.classList.add('wr-destruct--on');\n }\n }\n}\n\nexport { DESTRUCT_SHIFT, DESTRUCT_STEP };\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrDestruct } from './destruct';\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,iBAAiB;AASvB,MAAM,OAAO;AAGb,MAAM,OAAO;AAGb,MAAM,WAAW;AAGjB,MAAM,OAAO;AAQb,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,MAAM,UAAU;AAGhB,MAAM,YAAY;AAElB,MAAM,MA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,MAAA,EAAA,gBAAA,cAAA;EAAA,UAAA;CAAA,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EAJtB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,OAAO,cAAa;EAC7B,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-animations-destruct.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/animations/destruct/destruct.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { FOCUSABLE, roundTo } from '../internal';\n\n/** How far a pixel of the text may move at full noise, each way, in em: 2.4px on 16px text. */\nconst DESTRUCT_SHIFT = 0.15;\n\n/**\n * How long one noise field stays before the next replaces it, in ms: about 15\n * fields a second. The displacement eases every frame; only the field steps.\n */\nconst DESTRUCT_STEP = 66;\n\n/** Time constant of the ease in, in seconds: 63% of the way after this long, 95% after three times it. */\nconst RISE = 0.12;\n\n/** Time constant of the ease out, in seconds: the calm is slower than the onset. */\nconst FALL = 0.3;\n\n/** The longest step one frame may integrate, in seconds: a stalled frame eases a little, never jumps. */\nconst MAX_STEP = 0.1;\n\n/** Closer than this to the target, the intensity is the target. */\nconst SNAP = 0.01;\n\n/**\n * How many waves of noise fit in one em, across and down. Across, about one:\n * each letter of a short word leans its own way. Down, more: a line of pixels\n * through a glyph shifts apart from the line under it, the tear of a weak\n * signal. In em so a heading and a footnote wobble alike at their own size.\n */\nconst WAVES_X = 1;\nconst WAVES_Y = 2;\n\n/** Octaves of the fractal noise: the second adds the fine grain over the sway. */\nconst OCTAVES = 2;\n\n/** The fallback font size, in px, where the computed style gives none. */\nconst FONT_SIZE = 16;\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/**\n * Text that wobbles with a fine, living noise, as if seen through heat haze\n * or over a weak signal, while a pointer is over it or focus is in it, and\n * settles back to crisp, still text when the pointer leaves.\n *\n * The text stays real text: no copy, no canvas. One hidden inline `<svg>`,\n * put beside the host, holds a filter of two primitives, `feTurbulence`\n * (fractal noise) feeding `feDisplacementMap`, and the host wears it through\n * `filter: url(#id)` while the noise is above zero. So selection, copy,\n * find-in-page, a screen reader and the host's own styling see the element\n * as it was. The frequency of the noise is set from the host's font size, so\n * the waves are the same share of a glyph at any size, and the peak shift is\n * `shift` em of it, small enough that the word reads at full noise.\n *\n * One `requestAnimationFrame` loop runs only while the noise is above zero:\n * each frame the intensity eases toward its target (one while a pointer is\n * over the host or its closest focusable ancestor, or focus is in it; zero\n * otherwise) by an exponential step, faster in than out, and the\n * displacement's `scale` follows it. The noise field itself steps to a new\n * seed about fifteen times a second, not every frame: often enough to live,\n * seldom enough to read as haze, not a strobe. When the intensity reaches\n * zero the filter comes off the host entirely, the loop idles, and the text\n * renders exactly as without the effect. A hidden document pauses the loop\n * where it is.\n *\n * Nothing mounts under `prefers-reduced-motion: reduce`, under\n * `forced-colors: active` or on the server, and a preference that flips\n * mid-run clears the filter at once. Destroy removes the `<svg>`, the filter\n * and the listeners, and cancels the loop.\n */\n@Directive({\n selector: '[wrDestruct]',\n host: { class: 'wr-destruct' },\n})\nexport class WrDestruct {\n /** How far a pixel of the text may move at full noise, each way, in em of the host's font size. @default 0.15 */\n readonly shift = input(DESTRUCT_SHIFT, { transform: wrNumAttr(DESTRUCT_SHIFT) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private readonly doc = inject(DOCUMENT);\n private readonly id = wrRandomId('wr-destruct');\n private readonly hot = signal(false);\n private listeners: AbortController | null = null;\n private svg: SVGSVGElement | null = null;\n private turbulence: SVGElement | null = null;\n private map: SVGElement | null = null;\n private frame: number | null = null;\n /** The timestamp of the last frame, or `null` when the next one is the first after a start. */\n private last: number | null = null;\n /** When the noise field last stepped, or `null` before the first step of a run. */\n private stepped: number | null = null;\n private seed = 0;\n private intensity = 0;\n /** The peak shift, in px, for the current run. */\n private peak = 0;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/destruct');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n if (this.platform.prefersReducedMotion()) return;\n // The stylesheet paints no filter under forced colours: nothing to mount.\n if (this.doc.defaultView?.matchMedia?.('(forced-colors: active)').matches) return;\n this.mount();\n this.listen();\n });\n\n // One place decides what the loop does: reduced motion clears, a hidden\n // page pauses, otherwise a frame is asked for and the tick decides when\n // to idle. `shift` is read so a new peak reaches a run in flight.\n effect(() => {\n const hot = this.hot();\n const visible = this.platform.pageVisible();\n const reduced = this.platform.prefersReducedMotion();\n this.shift();\n untracked(() => {\n if (reduced) this.clear();\n else if (!visible) this.pause();\n else if (hot || this.intensity > 0) this.start();\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n this.clear();\n this.svg?.remove();\n this.svg = null;\n this.turbulence = null;\n this.map = null;\n });\n }\n\n /**\n * The filter, in a 0 by 0 `<svg>` right after the host: it lives and dies\n * with the host's subtree, and the host's own nodes are not touched. The\n * region is wider than the box by a quarter each way, so a pixel moved\n * off the edge of the glyphs is drawn, not cut.\n */\n private mount(): void {\n const svg = this.doc.createElementNS(SVG, 'svg');\n svg.setAttribute('class', 'wr-destruct__filter');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n svg.setAttribute('width', '0');\n svg.setAttribute('height', '0');\n const filter = this.doc.createElementNS(SVG, 'filter');\n filter.setAttribute('id', this.id);\n filter.setAttribute('x', '-25%');\n filter.setAttribute('y', '-25%');\n filter.setAttribute('width', '150%');\n filter.setAttribute('height', '150%');\n const turbulence = this.doc.createElementNS(SVG, 'feTurbulence');\n turbulence.setAttribute('type', 'fractalNoise');\n turbulence.setAttribute('numOctaves', String(OCTAVES));\n turbulence.setAttribute('seed', String(this.seed));\n turbulence.setAttribute('result', 'noise');\n const map = this.doc.createElementNS(SVG, 'feDisplacementMap');\n map.setAttribute('in', 'SourceGraphic');\n map.setAttribute('in2', 'noise');\n map.setAttribute('scale', '0');\n map.setAttribute('xChannelSelector', 'R');\n map.setAttribute('yChannelSelector', 'G');\n filter.append(turbulence, map);\n svg.append(filter);\n this.host.nativeElement.after(svg);\n this.svg = svg;\n this.turbulence = turbulence;\n this.map = map;\n }\n\n /** The closest focusable ancestor is what a keyboard reaches, so it is what focus is read on; the pointer is read there too. */\n private listen(): void {\n const host = this.host.nativeElement;\n const source = host.closest<HTMLElement>(FOCUSABLE) ?? host;\n this.listeners = new AbortController();\n const options = { signal: this.listeners.signal, passive: true };\n source.addEventListener('pointerenter', () => this.hot.set(true), options);\n source.addEventListener('pointerleave', () => this.hot.set(false), options);\n source.addEventListener('focusin', () => this.hot.set(true), options);\n source.addEventListener('focusout', () => this.hot.set(false), options);\n }\n\n /**\n * Ask for a frame, unless one is pending or nothing is mounted. A run that\n * starts from rest measures the host first: the font size may have changed\n * with the viewport since the last one.\n */\n private start(): void {\n if (this.frame !== null || !this.svg) return;\n if (this.intensity === 0) this.measure();\n this.last = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /** The peak shift and the noise frequency, from the host's font size, so both scale with the text. */\n private measure(): void {\n const computed = this.doc.defaultView?.getComputedStyle(this.host.nativeElement).fontSize;\n const parsed = computed === undefined ? NaN : parseFloat(computed);\n const size = Number.isFinite(parsed) && parsed > 0 ? parsed : FONT_SIZE;\n this.peak = Math.max(0, this.shift()) * size;\n this.turbulence?.setAttribute('baseFrequency', `${roundTo(WAVES_X / size, 4)} ${roundTo(WAVES_Y / size, 4)}`);\n }\n\n /** Drop the pending frame. The intensity and the filter stay where they are, so a restart continues from them. */\n private pause(): void {\n if (this.frame === null) return;\n cancelAnimationFrame(this.frame);\n this.frame = null;\n this.last = null;\n }\n\n /** Off at once: no frame, no filter, intensity zero. */\n private clear(): void {\n this.pause();\n this.intensity = 0;\n this.stepped = null;\n this.paint();\n }\n\n /**\n * One frame: ease the intensity toward its target, step the noise field\n * when its time has come, paint. The first frame after a start has no\n * length, so a pause of any length moves nothing when the loop resumes.\n */\n private tick(now: number): void {\n const dt = this.last === null ? 0 : Math.min(Math.max(0, now - this.last) / 1000, MAX_STEP);\n this.last = now;\n const target = this.hot() ? 1 : 0;\n const glide = target > this.intensity ? RISE : FALL;\n this.intensity += (target - this.intensity) * (1 - Math.exp(-dt / glide));\n if (Math.abs(target - this.intensity) < SNAP) this.intensity = target;\n if (this.intensity > 0 && (this.stepped === null || now - this.stepped >= DESTRUCT_STEP)) {\n this.stepped = now;\n this.turbulence?.setAttribute('seed', String(++this.seed));\n }\n this.paint();\n if (this.intensity === 0 && target === 0) {\n // Still, and asked to be: no frame until a pointer or focus arrives.\n this.frame = null;\n this.last = null;\n this.stepped = null;\n return;\n }\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /**\n * Written to the DOM by hand: a binding would wait for change detection,\n * and this is every frame. At zero the filter comes off the host entirely;\n * above it the displacement's `scale` is twice the shift, since the map\n * moves a pixel by `scale` times the noise's distance from its middle.\n */\n private paint(): void {\n if (!this.map) return;\n const el = this.host.nativeElement;\n if (this.intensity === 0) {\n el.classList.remove('wr-destruct--on');\n el.style.removeProperty('--wr-destruct-filter');\n this.map.setAttribute('scale', '0');\n return;\n }\n this.map.setAttribute('scale', String(roundTo(2 * this.peak * this.intensity, 2)));\n if (!el.classList.contains('wr-destruct--on')) {\n el.style.setProperty('--wr-destruct-filter', `url(#${this.id})`);\n el.classList.add('wr-destruct--on');\n }\n }\n}\n\nexport { DESTRUCT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EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAV,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAU,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,OAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,MAAA,EAAA,gBAAA,cAAA;EAAA,UAAA;CAAA,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EAJtB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM,EAAE,OAAO,cAAa;EAC7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-animations-dot-grid.mjs","names":[],"sources":["../../../projects/lib/animations/dot-grid/dot-grid.ts","../../../projects/lib/animations/dot-grid/dot-grid.html","../../../projects/lib/animations/dot-grid/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, DestroyRef, ElementRef, ViewEncapsulation, inject, input, viewChild } from '@angular/core';\n\nimport { wrClamp, wrNumAttr, wrResolveCssColorChannels, wrCheckStyles } from 'ngwr/utils';\n\nimport { MAX_DPR, MAX_PIXELS, createCanvasBackdrop } from '../internal';\n\n/** How far a dot is pushed at the pointer itself, in px. */\nconst PUSH = 14;\n/** Spring that returns a pushed dot, tuned per 60Hz frame: it overshoots about 15% and settles in half a second. */\nconst STIFFNESS = 0.12;\nconst DAMPING = 0.72;\n/** How much of the gap to its target a dot's light closes per 60Hz frame. */\nconst LIGHT_EASE = 0.18;\n/** Below this, in px and in light, a dot counts as at rest and snaps there. */\nconst REST_EPS = 0.02;\n/** The light is quantised into this many fill colours, so a frame is a handful of paths, not one per dot. */\nconst LEVELS = 8;\n/** A dot's radius at rest and fully lit, in px. */\nconst RADIUS = 1.1;\nconst RADIUS_LIT = 1.9;\n/** How much of its colour a dot shows at rest and fully lit. */\nconst ALPHA = 0.32;\nconst ALPHA_LIT = 0.75;\n/** A tap's ring: how far it travels and how long it takes. */\nconst PULSE_REACH = 220;\nconst PULSE_MS = 650;\nconst PULSE_WIDTH = 36;\nconst TAU = Math.PI * 2;\n\n/**\n * One damped spring step on one axis, in place: `vel[i]` is updated, then\n * added to `off[i]`. `scale` is the frame length in 60Hz frames, so a slow\n * frame takes a longer step and a fast screen a shorter one, and the motion\n * reads the same on both.\n */\nexport function dotGridSpringStep(\n off: Float32Array,\n vel: Float32Array,\n i: number,\n target: number,\n scale: number\n): void {\n const k = STIFFNESS * scale;\n const damping = DAMPING ** scale;\n vel[i] = (vel[i] + (target - off[i]) * k) * damping;\n off[i] += vel[i];\n}\n\n/** Where the dots of a `width` by `height` field sit, centred, `spacing` apart. */\nexport function dotGridLayout(\n width: number,\n height: number,\n spacing: number\n): { cols: number; rows: number; x: Float32Array<ArrayBuffer>; y: Float32Array<ArrayBuffer> } {\n const gap = Math.max(8, spacing);\n const cols = width > 0 && height > 0 ? Math.floor(width / gap) + 1 : 0;\n const rows = cols > 0 ? Math.floor(height / gap) + 1 : 0;\n const x0 = (width - (cols - 1) * gap) / 2;\n const y0 = (height - (rows - 1) * gap) / 2;\n const x = new Float32Array(cols * rows);\n const y = new Float32Array(cols * rows);\n for (let c = 0; c < cols; c++) {\n for (let r = 0; r < rows; r++) {\n const i = c * rows + r;\n x[i] = x0 + c * gap;\n y[i] = y0 + r * gap;\n }\n }\n return { cols, rows, x, y };\n}\n\n/**\n * An even field of small, faint dots behind a section's content. Near the\n * pointer the dots light up toward the primary colour and are pushed gently\n * away; each one follows a damped spring back to its place when the pointer\n * moves on, so a fast sweep leaves a short, soft wake that settles. With no\n * pointer the field rests.\n *\n * Fills its parent, which must be positioned (`position: relative`) and\n * isolated (`isolation: isolate`): the host is absolute, `inset: 0`, at\n * `z-index: -1`, so it lands at the floor of the parent's own stacking\n * context, under the content and over the page background. The parent takes\n * the pointer: the host and its canvas never do. One canvas through\n * `createCanvasBackdrop`, redrawn only while something moves: the frame loop\n * runs while the pointer is over the parent or a dot is still settling, and\n * only while the host is on screen and the document is visible; at rest the\n * still field is drawn once. Touch never pushes, so a\n * scroll over the section is never fought; a tap sends one ring of light out\n * from the finger instead.\n *\n * Colours come from the `--wr-dot-grid-*` hooks through `wrResolveCssColorChannels`,\n * re-read when the scheme changes. Under `prefers-reduced-motion: reduce` only\n * the still field is drawn; under `forced-colors: active` nothing is. The server\n * renders the empty canvas, absolutely positioned, so the browser's first draw\n * shifts no layout. Decorative: `aria-hidden`, no pointer events. Styles:\n * `@use 'ngwr/animations/dot-grid'`.\n */\n@Component({\n selector: 'wr-dot-grid',\n templateUrl: './dot-grid.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-dot-grid', 'aria-hidden': 'true' },\n})\nexport class WrDotGrid {\n /** Distance between two dots, in px. @default 26 */\n readonly spacing = input(26, { transform: wrNumAttr(26) });\n\n /** How far from the pointer a dot still lights and moves, in px. @default 140 */\n readonly reach = input(140, { transform: wrNumAttr(140) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly canvasRef = viewChild.required<ElementRef<HTMLCanvasElement>>('canvas');\n\n /** One fill per light level, rest first, and the radius that goes with it. */\n private fills: string[] = [];\n private radii: number[] = [];\n\n // One entry per dot, column-major\n private count = 0;\n private baseX = new Float32Array(0);\n private baseY = new Float32Array(0);\n private offX = new Float32Array(0);\n private offY = new Float32Array(0);\n private velX = new Float32Array(0);\n private velY = new Float32Array(0);\n private light = new Float32Array(0);\n /** Each dot's light level this frame, so the draw groups dots by fill. */\n private level = new Uint8Array(0);\n\n private pointerX = NaN;\n private pointerY = NaN;\n private pulseX = NaN;\n private pulseY = NaN;\n private pulseAge = Infinity;\n /** True while every dot sits at its place, unlit and still. */\n private settled = true;\n\n private pointerTarget: HTMLElement | null = null;\n\n private readonly backdrop = createCanvasBackdrop(() => this.canvasRef().nativeElement, {\n colors: canvas => this.resolveColors(canvas),\n layout: (width, height) => this.layout(width, height),\n active: () => this.pointerInside || !this.settled,\n advance: dt => this.advance(dt),\n draw: (ctx, width, height) => this.draw(ctx, width, height),\n rest: () => this.rest(),\n mounted: () => this.listen(),\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/dot-grid');\n inject(DestroyRef).onDestroy(() => {\n this.pointerTarget?.removeEventListener('pointermove', this.onPointerMove);\n this.pointerTarget?.removeEventListener('pointerleave', this.onPointerLeave);\n this.pointerTarget?.removeEventListener('pointerdown', this.onPointerDown);\n this.pointerTarget = null;\n });\n }\n\n /** The parent takes the pointer: the host and its canvas never do. */\n private listen(): void {\n const target = this.host.nativeElement.parentElement;\n this.pointerTarget = target;\n target?.addEventListener('pointermove', this.onPointerMove, { passive: true });\n target?.addEventListener('pointerleave', this.onPointerLeave, { passive: true });\n target?.addEventListener('pointerdown', this.onPointerDown, { passive: true });\n }\n\n // Pointer\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n // A finger that moves is scrolling: the field must never fight it.\n if (event.pointerType === 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pointerX = event.clientX - rect.left;\n this.pointerY = event.clientY - rect.top;\n this.settled = false;\n this.backdrop.sync();\n };\n\n private readonly onPointerLeave = (): void => {\n this.pointerX = NaN;\n this.pointerY = NaN;\n this.backdrop.sync();\n };\n\n private readonly onPointerDown = (event: PointerEvent): void => {\n if (event.pointerType !== 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pulseX = event.clientX - rect.left;\n this.pulseY = event.clientY - rect.top;\n this.pulseAge = 0;\n this.settled = false;\n this.backdrop.sync();\n };\n\n // Layout\n\n private resolveColors(canvas: HTMLCanvasElement): void {\n const ink = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-ink)', '#6b7280');\n const glow = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-glow)', '#3969e2');\n this.fills = [];\n this.radii = [];\n for (let l = 0; l < LEVELS; l++) {\n const t = l / (LEVELS - 1);\n const channel = (c: number): number => Math.round((ink[c] + (glow[c] - ink[c]) * t) * 255);\n const alpha = ALPHA + (ALPHA_LIT - ALPHA) * t;\n this.fills.push(`rgba(${channel(0)}, ${channel(1)}, ${channel(2)}, ${alpha.toFixed(3)})`);\n this.radii.push(RADIUS + (RADIUS_LIT - RADIUS) * t);\n }\n }\n\n private layout(width: number, height: number): void {\n const { x, y } = dotGridLayout(width, height, this.spacing());\n this.count = x.length;\n this.baseX = x;\n this.baseY = y;\n this.offX = new Float32Array(this.count);\n this.offY = new Float32Array(this.count);\n this.velX = new Float32Array(this.count);\n this.velY = new Float32Array(this.count);\n this.light = new Float32Array(this.count);\n this.level = new Uint8Array(this.count);\n this.settled = true;\n }\n\n // Motion\n\n /** Whether the pointer rests over the parent. */\n private get pointerInside(): boolean {\n return !Number.isNaN(this.pointerX);\n }\n\n /** Every dot back at its place, unlit and still. */\n private rest(): void {\n this.offX.fill(0);\n this.offY.fill(0);\n this.velX.fill(0);\n this.velY.fill(0);\n this.light.fill(0);\n this.level.fill(0);\n this.pulseAge = Infinity;\n this.settled = true;\n }\n\n /** Moves every dot one frame: the pointer's push and light, the tap's ring, then the springs. */\n private advance(dt: number): void {\n const scale = Math.min(2, dt / 16.7);\n const ease = 1 - (1 - LIGHT_EASE) ** scale;\n const reach = this.reach();\n const reach2 = reach * reach;\n const px = this.pointerX;\n const py = this.pointerY;\n const pointing = this.pointerInside;\n\n this.pulseAge += dt;\n const pulsing = this.pulseAge < PULSE_MS;\n const pulseT = this.pulseAge / PULSE_MS;\n const pulseR = PULSE_REACH * (1 - (1 - pulseT) ** 2);\n const pulseStrength = pulsing ? 1 - pulseT : 0;\n\n let settled = true;\n for (let i = 0; i < this.count; i++) {\n const x = this.baseX[i];\n const y = this.baseY[i];\n let targetX = 0;\n let targetY = 0;\n let targetLight = 0;\n if (pointing) {\n const dx = x - px;\n const dy = y - py;\n const d2 = dx * dx + dy * dy;\n if (d2 < reach2) {\n const d = Math.sqrt(d2);\n const w = (1 - d / reach) ** 2;\n targetLight = w;\n if (d > 0) {\n targetX = (dx / d) * w * PUSH;\n targetY = (dy / d) * w * PUSH;\n }\n }\n }\n if (pulsing) {\n const d = Math.hypot(x - this.pulseX, y - this.pulseY);\n const band = Math.abs(d - pulseR);\n if (band < PULSE_WIDTH) {\n targetLight = Math.max(targetLight, (1 - band / PULSE_WIDTH) * pulseStrength);\n }\n }\n\n dotGridSpringStep(this.offX, this.velX, i, targetX, scale);\n dotGridSpringStep(this.offY, this.velY, i, targetY, scale);\n this.light[i] += (targetLight - this.light[i]) * ease;\n\n const still =\n Math.abs(this.offX[i]) < REST_EPS &&\n Math.abs(this.offY[i]) < REST_EPS &&\n Math.abs(this.velX[i]) < REST_EPS &&\n Math.abs(this.velY[i]) < REST_EPS &&\n this.light[i] < REST_EPS;\n if (still) {\n this.offX[i] = 0;\n this.offY[i] = 0;\n this.velX[i] = 0;\n this.velY[i] = 0;\n this.light[i] = 0;\n } else {\n settled = false;\n }\n this.level[i] = Math.round(wrClamp(this.light[i], 0, 1) * (LEVELS - 1));\n }\n this.settled = settled && !pulsing;\n }\n\n /** One frame: one path per light level, every dot at that level in it. */\n private draw(ctx: CanvasRenderingContext2D, width: number, height: number): void {\n if (this.fills.length === 0) return;\n ctx.clearRect(0, 0, width, height);\n for (let l = 0; l < LEVELS; l++) {\n const r = this.radii[l];\n let any = false;\n ctx.beginPath();\n for (let i = 0; i < this.count; i++) {\n if (this.level[i] !== l) continue;\n const x = this.baseX[i] + this.offX[i];\n const y = this.baseY[i] + this.offY[i];\n ctx.moveTo(x + r, y);\n ctx.arc(x, y, r, 0, TAU);\n any = true;\n }\n if (!any) continue;\n ctx.fillStyle = this.fills[l];\n ctx.fill();\n }\n }\n}\n\nexport { LEVELS as DOT_GRID_LEVELS, MAX_DPR as DOT_GRID_MAX_DPR, MAX_PIXELS as DOT_GRID_MAX_PIXELS };\n","<canvas #canvas class=\"wr-dot-grid__canvas\"></canvas>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrDotGrid } from './dot-grid';\n"],"mappings":";;;;;;;;;;AAcA,MAAM,OAAO;AAEb,MAAM,YAAY;AAClB,MAAM,UAAU;AAIhB,MAAM,WAAW;AAIjB,MAAM,SAAS;AAGf,MAAM,QAAQ;AAGd,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,MAAM,KAAK,KAAK;AAQtB,SAAgB,kBACd,KACA,KACA,GACA,QACA,OAAa;CAEb,MAAM,IAAI,YAAY;CACtB,MAAM,UAAU,WAAW;CAC3B,IAAI,MAAM,IAAI,MAAM,SAAS,IAAI,MAAM,KAAK;CAC5C,IAAI,MAAM,IAAI;AAChB;AAGA,SAAgB,cACd,OACA,QACA,SAAe;CAEf,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO;CAC/B,MAAM,OAAO,QAAQ,KAAK,SAAS,IAAI,KAAK,MAAM,QAAQ,GAAG,IAAI,IAAI;CACrE,MAAM,OAAO,OAAO,IAAI,KAAK,MAAM,SAAS,GAAG,IAAI,IAAI;CACvD,MAAM,MAAM,SAAS,OAAO,KAAK,OAAO;CACxC,MAAM,MAAM,UAAU,OAAO,KAAK,OAAO;CACzC,MAAM,IAAI,IAAI,aAAa,OAAO,IAAI;CACtC,MAAM,IAAI,IAAI,aAAa,OAAO,IAAI;CACtC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,KACxB,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,KAAK;EAC7B,MAAM,IAAI,IAAI,OAAO;EACrB,EAAE,KAAK,KAAK,IAAI;EAChB,EAAE,KAAK,KAAK,IAAI;CAClB;CAEF,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A,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,eAAA,OAAA;GAAA,gBAAA;EAAA;EAAA,aAAA,CAAA;GAAA,cAAA;GAAA,OAAA;GAAA,WAAA,CAAA,QAAA;GAAA,aAAA;GAAA,UAAA;EAAA,CAAA;EAAA,UAAA;EAAA,UC9GtB;EACA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AD6Ga,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EANrB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAa,eAER,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAe,eAAe;GAAM;GAAE,UAAA;EAAA,CAAA;CAU0B,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-animations-dot-grid.mjs","names":[],"sources":["../../../projects/lib/animations/dot-grid/dot-grid.ts","../../../projects/lib/animations/dot-grid/dot-grid.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, DestroyRef, ElementRef, ViewEncapsulation, inject, input, viewChild } from '@angular/core';\n\nimport { wrClamp, wrNumAttr, wrResolveCssColorChannels, wrCheckStyles } from 'ngwr/utils';\n\nimport { MAX_DPR, MAX_PIXELS, createCanvasBackdrop } from '../internal';\n\n/** How far a dot is pushed at the pointer itself, in px. */\nconst PUSH = 14;\n/** Spring that returns a pushed dot, tuned per 60Hz frame: it overshoots about 15% and settles in half a second. */\nconst STIFFNESS = 0.12;\nconst DAMPING = 0.72;\n/** How much of the gap to its target a dot's light closes per 60Hz frame. */\nconst LIGHT_EASE = 0.18;\n/** Below this, in px and in light, a dot counts as at rest and snaps there. */\nconst REST_EPS = 0.02;\n/** The light is quantised into this many fill colours, so a frame is a handful of paths, not one per dot. */\nconst LEVELS = 8;\n/** A dot's radius at rest and fully lit, in px. */\nconst RADIUS = 1.1;\nconst RADIUS_LIT = 1.9;\n/** How much of its colour a dot shows at rest and fully lit. */\nconst ALPHA = 0.32;\nconst ALPHA_LIT = 0.75;\n/** A tap's ring: how far it travels and how long it takes. */\nconst PULSE_REACH = 220;\nconst PULSE_MS = 650;\nconst PULSE_WIDTH = 36;\nconst TAU = Math.PI * 2;\n\n/**\n * One damped spring step on one axis, in place: `vel[i]` is updated, then\n * added to `off[i]`. `scale` is the frame length in 60Hz frames, so a slow\n * frame takes a longer step and a fast screen a shorter one, and the motion\n * reads the same on both.\n */\nexport function dotGridSpringStep(\n off: Float32Array,\n vel: Float32Array,\n i: number,\n target: number,\n scale: number\n): void {\n const k = STIFFNESS * scale;\n const damping = DAMPING ** scale;\n vel[i] = (vel[i] + (target - off[i]) * k) * damping;\n off[i] += vel[i];\n}\n\n/** Where the dots of a `width` by `height` field sit, centred, `spacing` apart. */\nexport function dotGridLayout(\n width: number,\n height: number,\n spacing: number\n): { cols: number; rows: number; x: Float32Array<ArrayBuffer>; y: Float32Array<ArrayBuffer> } {\n const gap = Math.max(8, spacing);\n const cols = width > 0 && height > 0 ? Math.floor(width / gap) + 1 : 0;\n const rows = cols > 0 ? Math.floor(height / gap) + 1 : 0;\n const x0 = (width - (cols - 1) * gap) / 2;\n const y0 = (height - (rows - 1) * gap) / 2;\n const x = new Float32Array(cols * rows);\n const y = new Float32Array(cols * rows);\n for (let c = 0; c < cols; c++) {\n for (let r = 0; r < rows; r++) {\n const i = c * rows + r;\n x[i] = x0 + c * gap;\n y[i] = y0 + r * gap;\n }\n }\n return { cols, rows, x, y };\n}\n\n/**\n * An even field of small, faint dots behind a section's content. Near the\n * pointer the dots light up toward the primary colour and are pushed gently\n * away; each one follows a damped spring back to its place when the pointer\n * moves on, so a fast sweep leaves a short, soft wake that settles. With no\n * pointer the field rests.\n *\n * Fills its parent, which must be positioned (`position: relative`) and\n * isolated (`isolation: isolate`): the host is absolute, `inset: 0`, at\n * `z-index: -1`, so it lands at the floor of the parent's own stacking\n * context, under the content and over the page background. The parent takes\n * the pointer: the host and its canvas never do. One canvas through\n * `createCanvasBackdrop`, redrawn only while something moves: the frame loop\n * runs while the pointer is over the parent or a dot is still settling, and\n * only while the host is on screen and the document is visible; at rest the\n * still field is drawn once. Touch never pushes, so a\n * scroll over the section is never fought; a tap sends one ring of light out\n * from the finger instead.\n *\n * Colours come from the `--wr-dot-grid-*` hooks through `wrResolveCssColorChannels`,\n * re-read when the scheme changes. Under `prefers-reduced-motion: reduce` only\n * the still field is drawn; under `forced-colors: active` nothing is. The server\n * renders the empty canvas, absolutely positioned, so the browser's first draw\n * shifts no layout. Decorative: `aria-hidden`, no pointer events. Styles:\n * `@use 'ngwr/animations/dot-grid'`.\n */\n@Component({\n selector: 'wr-dot-grid',\n templateUrl: './dot-grid.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-dot-grid', 'aria-hidden': 'true' },\n})\nexport class WrDotGrid {\n /** Distance between two dots, in px. @default 26 */\n readonly spacing = input(26, { transform: wrNumAttr(26) });\n\n /** How far from the pointer a dot still lights and moves, in px. @default 140 */\n readonly reach = input(140, { transform: wrNumAttr(140) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly canvasRef = viewChild.required<ElementRef<HTMLCanvasElement>>('canvas');\n\n /** One fill per light level, rest first, and the radius that goes with it. */\n private fills: string[] = [];\n private radii: number[] = [];\n\n // One entry per dot, column-major\n private count = 0;\n private baseX = new Float32Array(0);\n private baseY = new Float32Array(0);\n private offX = new Float32Array(0);\n private offY = new Float32Array(0);\n private velX = new Float32Array(0);\n private velY = new Float32Array(0);\n private light = new Float32Array(0);\n /** Each dot's light level this frame, so the draw groups dots by fill. */\n private level = new Uint8Array(0);\n\n private pointerX = NaN;\n private pointerY = NaN;\n private pulseX = NaN;\n private pulseY = NaN;\n private pulseAge = Infinity;\n /** True while every dot sits at its place, unlit and still. */\n private settled = true;\n\n private pointerTarget: HTMLElement | null = null;\n\n private readonly backdrop = createCanvasBackdrop(() => this.canvasRef().nativeElement, {\n colors: canvas => this.resolveColors(canvas),\n layout: (width, height) => this.layout(width, height),\n active: () => this.pointerInside || !this.settled,\n advance: dt => this.advance(dt),\n draw: (ctx, width, height) => this.draw(ctx, width, height),\n rest: () => this.rest(),\n mounted: () => this.listen(),\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/dot-grid');\n inject(DestroyRef).onDestroy(() => {\n this.pointerTarget?.removeEventListener('pointermove', this.onPointerMove);\n this.pointerTarget?.removeEventListener('pointerleave', this.onPointerLeave);\n this.pointerTarget?.removeEventListener('pointerdown', this.onPointerDown);\n this.pointerTarget = null;\n });\n }\n\n /** The parent takes the pointer: the host and its canvas never do. */\n private listen(): void {\n const target = this.host.nativeElement.parentElement;\n this.pointerTarget = target;\n target?.addEventListener('pointermove', this.onPointerMove, { passive: true });\n target?.addEventListener('pointerleave', this.onPointerLeave, { passive: true });\n target?.addEventListener('pointerdown', this.onPointerDown, { passive: true });\n }\n\n // Pointer\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n // A finger that moves is scrolling: the field must never fight it.\n if (event.pointerType === 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pointerX = event.clientX - rect.left;\n this.pointerY = event.clientY - rect.top;\n this.settled = false;\n this.backdrop.sync();\n };\n\n private readonly onPointerLeave = (): void => {\n this.pointerX = NaN;\n this.pointerY = NaN;\n this.backdrop.sync();\n };\n\n private readonly onPointerDown = (event: PointerEvent): void => {\n if (event.pointerType !== 'touch' || !this.backdrop.ctx) return;\n const rect = this.canvasRef().nativeElement.getBoundingClientRect();\n this.pulseX = event.clientX - rect.left;\n this.pulseY = event.clientY - rect.top;\n this.pulseAge = 0;\n this.settled = false;\n this.backdrop.sync();\n };\n\n // Layout\n\n private resolveColors(canvas: HTMLCanvasElement): void {\n const ink = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-ink)', '#6b7280');\n const glow = wrResolveCssColorChannels(canvas, 'var(--wr-dot-grid-glow)', '#3969e2');\n this.fills = [];\n this.radii = [];\n for (let l = 0; l < LEVELS; l++) {\n const t = l / (LEVELS - 1);\n const channel = (c: number): number => Math.round((ink[c] + (glow[c] - ink[c]) * t) * 255);\n const alpha = ALPHA + (ALPHA_LIT - ALPHA) * t;\n this.fills.push(`rgba(${channel(0)}, ${channel(1)}, ${channel(2)}, ${alpha.toFixed(3)})`);\n this.radii.push(RADIUS + (RADIUS_LIT - RADIUS) * t);\n }\n }\n\n private layout(width: number, height: number): void {\n const { x, y } = dotGridLayout(width, height, this.spacing());\n this.count = x.length;\n this.baseX = x;\n this.baseY = y;\n this.offX = new Float32Array(this.count);\n this.offY = new Float32Array(this.count);\n this.velX = new Float32Array(this.count);\n this.velY = new Float32Array(this.count);\n this.light = new Float32Array(this.count);\n this.level = new Uint8Array(this.count);\n this.settled = true;\n }\n\n // Motion\n\n /** Whether the pointer rests over the parent. */\n private get pointerInside(): boolean {\n return !Number.isNaN(this.pointerX);\n }\n\n /** Every dot back at its place, unlit and still. */\n private rest(): void {\n this.offX.fill(0);\n this.offY.fill(0);\n this.velX.fill(0);\n this.velY.fill(0);\n this.light.fill(0);\n this.level.fill(0);\n this.pulseAge = Infinity;\n this.settled = true;\n }\n\n /** Moves every dot one frame: the pointer's push and light, the tap's ring, then the springs. */\n private advance(dt: number): void {\n const scale = Math.min(2, dt / 16.7);\n const ease = 1 - (1 - LIGHT_EASE) ** scale;\n const reach = this.reach();\n const reach2 = reach * reach;\n const px = this.pointerX;\n const py = this.pointerY;\n const pointing = this.pointerInside;\n\n this.pulseAge += dt;\n const pulsing = this.pulseAge < PULSE_MS;\n const pulseT = this.pulseAge / PULSE_MS;\n const pulseR = PULSE_REACH * (1 - (1 - pulseT) ** 2);\n const pulseStrength = pulsing ? 1 - pulseT : 0;\n\n let settled = true;\n for (let i = 0; i < this.count; i++) {\n const x = this.baseX[i];\n const y = this.baseY[i];\n let targetX = 0;\n let targetY = 0;\n let targetLight = 0;\n if (pointing) {\n const dx = x - px;\n const dy = y - py;\n const d2 = dx * dx + dy * dy;\n if (d2 < reach2) {\n const d = Math.sqrt(d2);\n const w = (1 - d / reach) ** 2;\n targetLight = w;\n if (d > 0) {\n targetX = (dx / d) * w * PUSH;\n targetY = (dy / d) * w * PUSH;\n }\n }\n }\n if (pulsing) {\n const d = Math.hypot(x - this.pulseX, y - this.pulseY);\n const band = Math.abs(d - pulseR);\n if (band < PULSE_WIDTH) {\n targetLight = Math.max(targetLight, (1 - band / PULSE_WIDTH) * pulseStrength);\n }\n }\n\n dotGridSpringStep(this.offX, this.velX, i, targetX, scale);\n dotGridSpringStep(this.offY, this.velY, i, targetY, scale);\n this.light[i] += (targetLight - this.light[i]) * ease;\n\n const still =\n Math.abs(this.offX[i]) < REST_EPS &&\n Math.abs(this.offY[i]) < REST_EPS &&\n Math.abs(this.velX[i]) < REST_EPS &&\n Math.abs(this.velY[i]) < REST_EPS &&\n this.light[i] < REST_EPS;\n if (still) {\n this.offX[i] = 0;\n this.offY[i] = 0;\n this.velX[i] = 0;\n this.velY[i] = 0;\n this.light[i] = 0;\n } else {\n settled = false;\n }\n this.level[i] = Math.round(wrClamp(this.light[i], 0, 1) * (LEVELS - 1));\n }\n this.settled = settled && !pulsing;\n }\n\n /** One frame: one path per light level, every dot at that level in it. */\n private draw(ctx: CanvasRenderingContext2D, width: number, height: number): void {\n if (this.fills.length === 0) return;\n ctx.clearRect(0, 0, width, height);\n for (let l = 0; l < LEVELS; l++) {\n const r = this.radii[l];\n let any = false;\n ctx.beginPath();\n for (let i = 0; i < this.count; i++) {\n if (this.level[i] !== l) continue;\n const x = this.baseX[i] + this.offX[i];\n const y = this.baseY[i] + this.offY[i];\n ctx.moveTo(x + r, y);\n ctx.arc(x, y, r, 0, TAU);\n any = true;\n }\n if (!any) continue;\n ctx.fillStyle = this.fills[l];\n ctx.fill();\n }\n }\n}\n\nexport { LEVELS as DOT_GRID_LEVELS, MAX_DPR as DOT_GRID_MAX_DPR, MAX_PIXELS as DOT_GRID_MAX_PIXELS };\n","<canvas #canvas class=\"wr-dot-grid__canvas\"></canvas>\n"],"mappings":";;;;;;;;;;AAcA,MAAM,OAAO;AAEb,MAAM,YAAY;AAClB,MAAM,UAAU;AAIhB,MAAM,WAAW;AAIjB,MAAM,SAAS;AAGf,MAAM,QAAQ;AAGd,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,MAAM,KAAK,KAAK;AAQtB,SAAgB,kBACd,KACA,KACA,GACA,QACA,OAAa;CAEb,MAAM,IAAI,YAAY;CACtB,MAAM,UAAU,WAAW;CAC3B,IAAI,MAAM,IAAI,MAAM,SAAS,IAAI,MAAM,KAAK;CAC5C,IAAI,MAAM,IAAI;AAChB;AAGA,SAAgB,cACd,OACA,QACA,SAAe;CAEf,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO;CAC/B,MAAM,OAAO,QAAQ,KAAK,SAAS,IAAI,KAAK,MAAM,QAAQ,GAAG,IAAI,IAAI;CACrE,MAAM,OAAO,OAAO,IAAI,KAAK,MAAM,SAAS,GAAG,IAAI,IAAI;CACvD,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AAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-animations-falling-letters.mjs","names":[],"sources":["../../../projects/lib/animations/falling-letters/falling-letters.ts","../../../projects/lib/animations/falling-letters/public-api.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n untracked,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { graphemes, optionalSelector, roundTo } from '../internal';\n\nimport type { WrFallingLettersState } from './types';\n\n/** How long the heap lies still before the letters spring back on their own, in ms. */\nconst FALLING_LETTERS_REST = 4000;\n\n/** Downward acceleration, in px/s²: a letter crosses half a screen in about two thirds of a second. */\nconst GRAVITY = 2400;\n\n/** The most a letter drifts sideways as it falls, each way, in px/s. */\nconst DRIFT = 80;\n\n/** The most a letter spins as it falls, each way, in degrees per second. */\nconst SPIN = 160;\n\n/** The letters let go over this long, not all at once, in ms. */\nconst RELEASE = 240;\n\n/** The width of one column of the height map, in px: narrower than a letter, so a heap has a shape. */\nconst COLUMN = 8;\n\n/** How much of the landing speed comes back as a hop. */\nconst RESTITUTION = 0.25;\n\n/** Landing slower than this, a letter settles instead of hopping, in px/s. */\nconst BOUNCE_MIN = 300;\n\n/** What a hop and a wall take off the sideways speed and the spin. */\nconst FRICTION = 0.5;\n\n/** How long one letter's flight back to its place takes, in ms. */\nconst RETURN = 700;\n\n/** The gap between two letters leaving the heap, in ms, and how far the last may start after the first. */\nconst RETURN_GAP = 24;\nconst RETURN_SPREAD = 300;\n\n/** The spring that brings a letter back: this much damping, this many turns of the overshoot per flight. */\nconst SPRING_DAMP = 7;\nconst SPRING_FREQ = 2.4 * Math.PI;\n\n/** The longest step one frame may integrate, in seconds: a stalled frame moves a little, never jumps. */\nconst MAX_STEP = 0.04;\n\n/**\n * How far under a letter's last bottom edge a surface may be, in px, and still\n * count as under it: the rounding of a frame, not a neighbour's top.\n */\nconst SLACK = 0.5;\n\n/** How fast a letter that lands against a neighbour slides clear of it, or climbs out from between two, in px/s. */\nconst SLIDE = 240;\n\n/** How far a letter slides and climbs at most, in px, before it gives up and lies where it is. */\nconst SLIDE_MAX = 48;\n\n/**\n * Multipliers of the low-discrepancy sequences, one per channel: `(n * m) mod 1`\n * spreads over (0, 1) with no two neighbours close, and three irrationals far\n * apart keep the release order, the drift and the spin from following one another.\n */\nconst SCATTER = [0.618_033_988_749_895, 0.414_213_562_373_095, 0.732_050_807_568_877] as const;\n\n/** Letter `i`'s place in (0, 1) on channel `k`: the same for the same letter every time. */\nfunction scatter(i: number, k: 0 | 1 | 2): number {\n const x = ((i + 1) * SCATTER[k]) % 1;\n return x < 0 ? x + 1 : x;\n}\n\n/**\n * A springy ease: overshoots its target by about seven percent, comes back a\n * little under, and is there at `t = 1`. `t` is clamped to [0, 1].\n */\nfunction spring(t: number): number {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n return 1 - Math.exp(-SPRING_DAMP * t) * Math.cos(SPRING_FREQ * t);\n}\n\n/**\n * The floor, as a row of narrow columns, each remembering the top of what has\n * landed in it. A letter lands on the highest top among the columns it covers\n * that lies under it, so later letters sit on earlier ones and the floor fills\n * into a heap, and a letter already level with a neighbour's top is beside\n * that neighbour, not on it.\n */\nclass Heap {\n private readonly tops: Float64Array;\n\n /** `floor` is the y of the empty floor; the columns span `from` to `to`. */\n constructor(\n private readonly from: number,\n to: number,\n private readonly floor: number\n ) {\n this.tops = new Float64Array(Math.max(1, Math.ceil((to - from) / COLUMN))).fill(floor);\n }\n\n /**\n * The y a body spanning `a` to `b` lands on: the smallest y (highest top)\n * among its columns at or under `below`, the body's own bottom edge a frame\n * ago. A column whose top is above that is a neighbour the body is passing\n * beside, so it does not count: a letter that lands next to one already on\n * the floor keeps falling to the floor instead of jumping up onto it. With\n * every column of the span above the body, it falls on to the floor itself.\n */\n top(a: number, b: number, below = -Infinity): number {\n let top = Infinity;\n for (let c = this.column(a); c <= this.column(b); c++) {\n const candidate = this.tops[c];\n if (candidate >= below) top = Math.min(top, candidate);\n }\n return top === Infinity ? this.floor : top;\n }\n\n /**\n * What stands beside a body spanning `a` to `b` that lies with its bottom\n * at `bottom`: how many of its columns, left and right of its middle, end\n * above that bottom, in a neighbour it landed against. `null` when none\n * does and it may lie where it is.\n */\n beside(a: number, b: number, bottom: number): { left: number; right: number } | null {\n const from = this.column(a);\n const to = this.column(b);\n const mid = (from + to) / 2;\n let left = 0;\n let right = 0;\n for (let c = from; c <= to; c++) {\n if (this.tops[c] >= bottom - SLACK) continue;\n if (c <= mid) left++;\n else right++;\n }\n return left === 0 && right === 0 ? null : { left, right };\n }\n\n /** A body spanning `a` to `b` has settled with its top at `y`: its columns now end there. */\n settle(a: number, b: number, y: number): void {\n for (let c = this.column(a); c <= this.column(b); c++) this.tops[c] = Math.min(this.tops[c], y);\n }\n\n private column(x: number): number {\n return Math.min(this.tops.length - 1, Math.max(0, Math.floor((x - this.from) / COLUMN)));\n }\n}\n\n/**\n * The part of a piece that falls and lands: the ink of the glyph, inside the\n * piece's box. `left` and `top` are from the box's top-left corner.\n */\ninterface Body {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** One letter on its way: a piece over the page, its place in the line, and its motion. */\ninterface Piece {\n readonly el: HTMLElement;\n /** The body's size, for the walls and the heap. */\n readonly bw: number;\n readonly bh: number;\n /** The body's centre from the piece's top-left corner: where the piece turns, and what `cx`, `cy` are the position of. */\n readonly ox: number;\n readonly oy: number;\n /** The centre of the body in the line, from the target's padding box. */\n readonly x0: number;\n readonly y0: number;\n /** How long after the click this letter lets go, in seconds. */\n readonly release: number;\n cx: number;\n cy: number;\n angle: number;\n vx: number;\n vy: number;\n spin: number;\n /** How far the letter may still slide and climb to get clear of a neighbour, in px. */\n slide: number;\n /** The top the letter is climbing to, squeezed up from between two neighbours; `null` otherwise. */\n climb: number | null;\n settled: boolean;\n /** Where the flight back started from. */\n fromX: number;\n fromY: number;\n fromAngle: number;\n}\n\n/** The box the letters fall in, from the target's padding box. */\ninterface Bounds {\n readonly minX: number;\n readonly maxX: number;\n readonly floor: number;\n}\n\n/** Half the width and half the height of a body's axis-aligned box at `angle` degrees. */\nfunction extent(piece: Pick<Piece, 'bw' | 'bh'>, angle: number): { hw: number; hh: number } {\n const rad = (angle * Math.PI) / 180;\n const cos = Math.abs(Math.cos(rad));\n const sin = Math.abs(Math.sin(rad));\n return { hw: (piece.bw * cos + piece.bh * sin) / 2, hh: (piece.bh * cos + piece.bw * sin) / 2 };\n}\n\n/**\n * The ink of one grapheme inside its line box, from the canvas text metrics\n * of the same font: the line box is mostly air (the leading, the ascender\n * space over an `a`, the descender space under it), and a heap of air boxes\n * is a heap of letters hanging apart in mid-air. The baseline sits at the\n * box's half-leading plus the font's ascent, as in the line it came from; the\n * ink is the glyph's own bounds about that baseline and the start of its\n * advance. `null` when the browser gives no context or no metrics (jsdom, an\n * invisible glyph), and the piece's box is the body.\n */\nfunction ink(ctx: CanvasRenderingContext2D | null, text: string, box: Pick<DOMRect, 'height'>): Body | null {\n if (!ctx) return null;\n const m = ctx.measureText(text);\n const ascent = m.fontBoundingBoxAscent;\n const descent = m.fontBoundingBoxDescent;\n if (!(ascent >= 0 && descent >= 0)) return null;\n const baseline = (box.height - ascent - descent) / 2 + ascent;\n const left = -m.actualBoundingBoxLeft || 0;\n const top = baseline - m.actualBoundingBoxAscent;\n const width = m.actualBoundingBoxRight - left;\n const height = baseline + m.actualBoundingBoxDescent - top;\n return width > 0.5 && height > 0.5 ? { left, top, width, height } : null;\n}\n\n/** A canvas context set to the element's font, for `ink`; `null` where there is no canvas. */\nfunction measurer(el: HTMLElement): CanvasRenderingContext2D | null {\n const doc = el.ownerDocument;\n const style = doc.defaultView?.getComputedStyle(el);\n const ctx = doc.createElement('canvas').getContext('2d');\n if (!style || !ctx) return null;\n ctx.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;\n return ctx;\n}\n\n/**\n * Click a line of text and its letters let go: each one drops with gravity,\n * drifts and tumbles a little on its own path, and lands on whatever already\n * lies under it, so the letters pile into a heap on the floor of a container.\n * Click again, or leave the heap for a few seconds, and every letter springs\n * back to its exact place in the line; the text is plain text again.\n *\n * No physics engine. A letter's path is gravity plus a sideways drift and a\n * spin drawn from a fixed low-discrepancy sequence by its index, so the same\n * text falls the same way every time and a spec can follow it. What falls is\n * the glyph's ink, measured from the canvas text metrics of the line's font\n * ({@link ink}), not its line box: the box is mostly air, and air boxes would\n * stack into a heap of letters hanging apart. Letters do not collide in the\n * air; they meet on the floor, which is a {@link Heap}: a row of narrow\n * columns, each remembering the top of what has landed in it, and a letter\n * lands on the highest top among the columns it covers that is under it. A\n * top above the letter's last bottom edge is a neighbour it is passing beside,\n * and is ignored: otherwise every letter landing beside one already down\n * would snap up on to it, and the heap would stack into towers in a frame. A\n * letter that lands fast hops once or twice ({@link RESTITUTION}); a slow one\n * that came down against such a neighbour slides along its surface until it\n * is clear ({@link SLIDE}), one down between two climbs out on to the taller,\n * and after {@link SLIDE_MAX} px of that a letter lies where it is. A wall of\n * the container turns the drift around. The floor and the walls are\n * the content box of `floor`'s element, measured when the fall starts.\n *\n * The line never moves. The authored nodes are moved into an invisible\n * wrapper that holds exactly their space, still the real text for a screen\n * reader and the clipboard, and the pieces, one `aria-hidden` span per\n * grapheme, are positioned from the target's own box and move by transform\n * alone, so nothing under them reflows and a button under a falling letter\n * stays clickable (`pointer-events: none`). They inherit the font and the\n * colour. When the last letter is back, the same authored node objects go\n * back where they were and the pieces are removed, so a binding inside the\n * text keeps working through the whole thing.\n *\n * One `requestAnimationFrame` loop runs only while a letter moves: it idles\n * once the heap is still and once the line is whole, and a hidden document\n * pauses it where it is. The return is a springy ease ({@link spring}) with a\n * short stagger in reading order. Nothing happens on the server, under\n * `prefers-reduced-motion: reduce`, or when the target has no box; a\n * preference that flips mid-fall puts the text back at once. Destroy puts the\n * text back, cancels the loop and drops the listener.\n *\n * The effect usually sits on its host, but a selector as the directive's value\n * points it at one descendant instead, for a paragraph a library component\n * draws (`<wr-result-404 wrFallingLetters=\".wr-result__description\">`). The\n * target is looked up once after the first render; if nothing matches, nothing\n * happens.\n */\n@Directive({\n selector: '[wrFallingLetters]',\n})\nexport class WrFallingLetters {\n /**\n * A selector for one descendant of the host whose letters fall instead of\n * the host's own, written as the directive's value:\n * `wrFallingLetters=\".wr-result__description\"`. Resolved once after the\n * first render with `querySelector`; a selector that matches nothing turns\n * the effect off. Unset or empty, the host.\n */\n readonly target = input<string | null, unknown>(null, { alias: 'wrFallingLetters', transform: optionalSelector });\n\n /**\n * A selector for the element whose content box is the floor and the walls,\n * found with `closest` from the host. Unset, the host's parent element: on\n * a `display: contents` host that is the box around it. On a `wr-*` host\n * write it as a binding (`[floor]=\"'main'\"`), since a static attribute that\n * is not one of the component's inputs fails `check:attrs`.\n */\n readonly floor = input<string | null, unknown>(null, { transform: optionalSelector });\n\n /** How long the heap lies still before the letters spring back on their own, in ms. @default 4000 */\n readonly rest = input(FALLING_LETTERS_REST, { transform: wrNumAttr(FALLING_LETTERS_REST) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private listeners: AbortController | null = null;\n /** The element whose letters fall, once resolved; `null` before and after. */\n private el: HTMLElement | null = null;\n private state: WrFallingLettersState = 'idle';\n /** The authored children while they sit in the wrapper, else `null`. */\n private original: ChildNode[] | null = null;\n private pieces: Piece[] = [];\n private heap: Heap | null = null;\n private bounds: Bounds | null = null;\n private frame: number | null = null;\n /** The timestamp of the last frame, or `null` when the next one is the first after a start. */\n private last: number | null = null;\n /** Seconds since the current phase began, summed from frame steps, so a pause adds nothing. */\n private clock = 0;\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/falling-letters');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n const host = this.host.nativeElement;\n const selector = this.target();\n const el = selector ? host.querySelector<HTMLElement>(selector) : host;\n if (!el) return;\n this.el = el;\n el.classList.add('wr-falling-letters');\n this.listeners = new AbortController();\n el.addEventListener('click', () => this.toggle(), { signal: this.listeners.signal });\n });\n\n // One place decides what the loop does: reduced motion puts the text\n // back, a hidden page pauses, otherwise a phase in motion gets a frame.\n effect(() => {\n const visible = this.platform.pageVisible();\n const reduced = this.platform.prefersReducedMotion();\n untracked(() => {\n if (reduced) this.restore();\n else if (!visible) this.pause();\n else if (this.state === 'fall' || this.state === 'return') this.start();\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n this.restore();\n this.el?.classList.remove('wr-falling-letters');\n this.el = null;\n });\n }\n\n /** A click: plain text falls; a heap, still or in the making, springs back; a flight back is left alone. */\n private toggle(): void {\n if (this.platform.prefersReducedMotion()) return;\n if (this.state === 'idle') this.fall();\n else if (this.state === 'fall' || this.state === 'rest') this.spring();\n }\n\n /**\n * Measure every grapheme in place, then swap in the pieces and hide the\n * line, all in one task, so the first paint shows each piece exactly over\n * its letter. The measurement wraps each grapheme in an inline-block for one\n * synchronous layout and puts the authored nodes straight back, so no frame\n * ever shows the probe.\n */\n private fall(): void {\n const el = this.el;\n if (!el) return;\n const doc = el.ownerDocument;\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) return;\n\n const original = Array.from(el.childNodes);\n const wrapper = doc.createElement('span');\n wrapper.className = 'wr-falling-letters__text';\n const glyphs: { el: HTMLElement; text: string; node: Node | null }[] = [];\n for (const node of original) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n // An inline element (`<code>`, `<a>`) is one piece, a copy of the whole thing.\n const probe = doc.createElement('span');\n probe.className = 'wr-falling-letters__glyph';\n probe.append(node);\n wrapper.append(probe);\n glyphs.push({ el: probe, text: '', node });\n } else if (node.nodeType === Node.TEXT_NODE) {\n for (const grapheme of graphemes(node.textContent ?? '')) {\n if (grapheme.trim() === '') {\n wrapper.append(grapheme);\n continue;\n }\n const probe = doc.createElement('span');\n probe.className = 'wr-falling-letters__glyph';\n probe.textContent = grapheme;\n wrapper.append(probe);\n glyphs.push({ el: probe, text: grapheme, node: null });\n }\n }\n }\n el.replaceChildren(wrapper);\n\n const origin = { x: box.left + el.clientLeft, y: box.top + el.clientTop };\n const rects = glyphs.map(glyph => glyph.el.getBoundingClientRect());\n const container = this.container();\n const bounds = this.measure(container ?? el, origin, box);\n // The text's font, read once: every grapheme of the line shares it. An\n // inline element is one piece with its own font and its own box, and its\n // box (a chip, a link) is its ink.\n const ctx = measurer(el);\n\n // The authored nodes back, the same objects, in their order: the wrapper now holds the line's space.\n wrapper.replaceChildren(...original);\n\n const layer = doc.createElement('span');\n layer.className = 'wr-falling-letters__pieces';\n layer.setAttribute('aria-hidden', 'true');\n const pieces: Piece[] = [];\n glyphs.forEach((glyph, i) => {\n const rect = rects[i];\n if (rect.width <= 0 || rect.height <= 0) return;\n const piece = doc.createElement('span');\n piece.className = 'wr-falling-letters__piece';\n if (glyph.node) piece.append(glyph.node.cloneNode(true));\n else piece.textContent = glyph.text;\n const n = pieces.length;\n const body: Body = (glyph.node ? null : ink(ctx, glyph.text, rect)) ?? {\n left: 0,\n top: 0,\n width: rect.width,\n height: rect.height,\n };\n const ox = body.left + body.width / 2;\n const oy = body.top + body.height / 2;\n piece.style.transformOrigin = `${roundTo(ox, 2)}px ${roundTo(oy, 2)}px`;\n const x0 = rect.left - origin.x + ox;\n const y0 = rect.top - origin.y + oy;\n pieces.push({\n el: piece,\n bw: body.width,\n bh: body.height,\n ox,\n oy,\n x0,\n y0,\n release: (scatter(n, 0) * RELEASE) / 1000,\n cx: x0,\n cy: y0,\n angle: 0,\n vx: (scatter(n, 1) - 0.5) * 2 * DRIFT,\n vy: 0,\n spin: (scatter(n, 2) - 0.5) * 2 * SPIN,\n slide: SLIDE_MAX,\n climb: null,\n settled: false,\n fromX: x0,\n fromY: y0,\n fromAngle: 0,\n });\n layer.append(piece);\n });\n if (pieces.length === 0) {\n el.replaceChildren(...original);\n return;\n }\n\n this.original = original;\n this.pieces = pieces;\n this.heap = new Heap(bounds.minX, bounds.maxX, bounds.floor);\n this.bounds = bounds;\n for (const piece of pieces) this.paint(piece);\n el.append(layer);\n el.classList.add('wr-falling-letters--out');\n this.state = 'fall';\n this.clock = 0;\n this.start();\n }\n\n /** The element whose content box is the floor: `floor`'s closest match from the host, else the host's parent. */\n private container(): HTMLElement | null {\n const host = this.host.nativeElement;\n const selector = this.floor();\n return selector ? host.closest<HTMLElement>(selector) : host.parentElement;\n }\n\n /**\n * The floor and the walls, from the target's padding box: the container's\n * content box, and never above the line itself, so a letter always has\n * somewhere to fall.\n */\n private measure(container: HTMLElement, origin: { x: number; y: number }, box: DOMRect): Bounds {\n const rect = container.getBoundingClientRect();\n const style = container.ownerDocument.defaultView?.getComputedStyle(container);\n const pad = (value: string | undefined): number => {\n const n = value === undefined ? NaN : parseFloat(value);\n return Number.isFinite(n) ? n : 0;\n };\n const minX = rect.left + pad(style?.paddingLeft) - origin.x;\n const maxX = rect.left + rect.width - pad(style?.paddingRight) - origin.x;\n const floor = rect.top + rect.height - pad(style?.paddingBottom) - origin.y;\n return { minX: Math.min(minX, 0), maxX: Math.max(maxX, box.width), floor: Math.max(floor, box.height) };\n }\n\n /** Every letter leaves where it is, heap or mid-air, for its place in the line. */\n private spring(): void {\n this.clearTimer();\n for (const piece of this.pieces) {\n piece.fromX = piece.cx;\n piece.fromY = piece.cy;\n piece.fromAngle = piece.angle;\n }\n this.state = 'return';\n this.clock = 0;\n this.start();\n }\n\n /** Ask for a frame, unless one is pending, nothing moves or the page is hidden. */\n private start(): void {\n if (this.frame !== null || this.state === 'idle' || this.state === 'rest') return;\n if (!untracked(() => this.platform.pageVisible())) return;\n this.last = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /** Drop the pending frame. The pieces stay where they are, so a restart continues from them. */\n private pause(): void {\n if (this.frame === null) return;\n cancelAnimationFrame(this.frame);\n this.frame = null;\n this.last = null;\n }\n\n /**\n * Put the authored children back, the same node objects, and drop the\n * wrapper and the pieces. Idempotent: the end of the flight back, reduced\n * motion and destroy all call it.\n */\n private restore(): void {\n this.pause();\n this.clearTimer();\n this.state = 'idle';\n if (!this.original) return;\n this.el?.replaceChildren(...this.original);\n this.el?.classList.remove('wr-falling-letters--out');\n this.original = null;\n this.pieces = [];\n this.heap = null;\n this.bounds = null;\n }\n\n /**\n * One frame. The first after a start has no length, so a pause of any length\n * moves nothing when the loop resumes. The fall ends when the last letter\n * settles, and the heap lies still until a click or the rest timer; the\n * flight back ends when the last letter is home, and the text is whole again.\n */\n private tick(now: number): void {\n const dt = this.last === null ? 0 : Math.min(Math.max(0, now - this.last) / 1000, MAX_STEP);\n this.last = now;\n this.clock += dt;\n const done = this.state === 'fall' ? this.stepFall(dt) : this.stepReturn();\n if (!done) {\n this.frame = requestAnimationFrame(t => this.tick(t));\n return;\n }\n this.frame = null;\n this.last = null;\n if (this.state === 'return') {\n this.restore();\n return;\n }\n this.state = 'rest';\n this.timer = setTimeout(\n () => {\n this.timer = null;\n this.spring();\n },\n Math.max(0, this.rest())\n );\n }\n\n /** Gravity, drift, spin, the walls and the heap for every letter still in the air. True once all have settled. */\n private stepFall(dt: number): boolean {\n const heap = this.heap;\n const bounds = this.bounds;\n if (!heap || !bounds) return true;\n let settled = true;\n for (const piece of this.pieces) {\n if (piece.settled) continue;\n settled = false;\n if (this.clock < piece.release) continue;\n if (piece.climb !== null) {\n // Squeezed up from between two neighbours at the slide's pace, until\n // the body is level with the top of the taller one; then it drops on.\n const rest = piece.climb - extent(piece, piece.angle).hh;\n piece.cy = Math.max(rest, piece.cy - SLIDE * dt);\n piece.slide -= SLIDE * dt;\n if (piece.cy <= rest) piece.climb = null;\n this.paint(piece);\n continue;\n }\n const below = piece.cy + extent(piece, piece.angle).hh;\n piece.vy += GRAVITY * dt;\n piece.cx += piece.vx * dt;\n piece.cy += piece.vy * dt;\n piece.angle += piece.spin * dt;\n const { hw, hh } = extent(piece, piece.angle);\n\n if (piece.cx - hw < bounds.minX) {\n piece.cx = bounds.minX + hw;\n piece.vx = Math.abs(piece.vx) * FRICTION;\n } else if (piece.cx + hw > bounds.maxX) {\n piece.cx = bounds.maxX - hw;\n piece.vx = -Math.abs(piece.vx) * FRICTION;\n }\n\n const top = heap.top(piece.cx - hw, piece.cx + hw, below - SLACK);\n if (piece.cy + hh >= top) {\n piece.cy = top - hh;\n if (piece.vy > BOUNCE_MIN) {\n piece.vy = -piece.vy * RESTITUTION;\n piece.vx *= FRICTION;\n piece.spin *= FRICTION;\n } else {\n piece.vy = 0;\n piece.spin = 0;\n const beside = piece.slide > 0 ? heap.beside(piece.cx - hw, piece.cx + hw, piece.cy + hh) : null;\n if (beside && beside.left > 0 && beside.right > 0) {\n // Down between two neighbours: climb out, to the top of the taller.\n piece.vx = 0;\n piece.climb = heap.top(piece.cx - hw, piece.cx + hw);\n } else if (beside) {\n // Down against a neighbour that is already there: slide along the\n // surface until clear of it, as letters landing on one another do,\n // instead of lying inside it or jumping up on to it.\n piece.vx = (beside.left > 0 ? 1 : -1) * SLIDE;\n piece.slide -= SLIDE * dt;\n } else {\n piece.vx = 0;\n piece.settled = true;\n // The heap learns of the letter once it lies still, not at first\n // touch: a letter that touched down, hopped and came to rest a step\n // away would leave a top in the air for the next one to hang on.\n heap.settle(piece.cx - hw, piece.cx + hw, piece.cy - hh);\n }\n }\n }\n this.paint(piece);\n }\n return settled;\n }\n\n /** Each letter springs from where it left toward its place, in reading order. True once all are home. */\n private stepReturn(): boolean {\n const count = this.pieces.length;\n const gap = Math.min(RETURN_GAP, RETURN_SPREAD / Math.max(1, count - 1)) / 1000;\n let home = true;\n this.pieces.forEach((piece, i) => {\n const t = (this.clock - i * gap) / (RETURN / 1000);\n if (t < 0) {\n home = false;\n return;\n }\n const s = spring(t);\n piece.cx = piece.fromX + (piece.x0 - piece.fromX) * s;\n piece.cy = piece.fromY + (piece.y0 - piece.fromY) * s;\n piece.angle = piece.fromAngle * (1 - s);\n if (t < 1) home = false;\n this.paint(piece);\n });\n return home;\n }\n\n /** Written to the DOM by hand: a binding would wait for change detection, and this is every frame. */\n private paint(piece: Piece): void {\n const x = roundTo(piece.cx - piece.ox, 2);\n const y = roundTo(piece.cy - piece.oy, 2);\n const angle = roundTo(piece.angle, 2);\n piece.el.style.transform = `translate(${x}px, ${y}px) rotate(${angle}deg)`;\n }\n\n private clearTimer(): void {\n if (this.timer !== null) clearTimeout(this.timer);\n this.timer = null;\n }\n}\n\nexport {\n BOUNCE_MIN,\n COLUMN,\n DRIFT,\n FALLING_LETTERS_REST,\n GRAVITY,\n Heap,\n RELEASE,\n RESTITUTION,\n RETURN,\n RETURN_GAP,\n RETURN_SPREAD,\n SLACK,\n SLIDE,\n SLIDE_MAX,\n SPIN,\n ink,\n scatter,\n spring,\n};\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nexport { WrFallingLetters } from './falling-letters';\nexport type { WrFallingLettersState } from './types';\n"],"mappings":";;;;;;;;;;;;AA4BA,MAAM,uBAAuB;AAG7B,MAAM,UAAU;AAehB,MAAM,cAAc;AAMpB,MAAM,WAAW;AAWjB,MAAM,cAAc,MAAM,KAAK;AAG/B,MAAM,WAAW;AAMjB,MAAM,QAAQ;AAad,MAAM,UAAU;CAAC;CAAuB;CAAuB;AAAqB;AAGpF,SAAS,QAAQ,GAAW,GAAY;CACtC,MAAM,KAAM,IAAI,KAAK,QAAQ,KAAM;CACnC,OAA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,aAAa,IAAI;GACrC,IAAI,IAAI,GAAG,OAAO;GAClB,KAAK,MAAM,KAAK;EAClB,CAAC;EACD,OAAO;CACT;CAGQ,MAAM,OAAY;EACxB,MAAM,IAAI,QAAQ,MAAM,KAAK,MAAM,IAAI,CAAC;EACxC,MAAM,IAAI,QAAQ,MAAM,KAAK,MAAM,IAAI,CAAC;EACxC,MAAM,QAAQ,QAAQ,MAAM,OAAO,CAAC;EACpC,MAAM,GAAG,MAAM,YAAY,aAAa,EAAC,MAAO,EAAC,aAAc,MAAK;CACtE;CAEQ,aAAU;EAChB,IAAI,KAAK,UAAU,MAAM,aAAa,KAAK,KAAK;EAChD,KAAK,QAAQ;CACf;CAvZW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAgB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAhB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAgB,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,QAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,UAAA;CAAA,CAAA;;AAAhB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA;EAH5B,MAAA;EAAU,MAAA,CAAA,EACT,UAAU,qBACX,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-animations-falling-letters.mjs","names":[],"sources":["../../../projects/lib/animations/falling-letters/falling-letters.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n afterNextRender,\n effect,\n inject,\n input,\n untracked,\n} from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\nimport { wrNumAttr, wrCheckStyles } from 'ngwr/utils';\n\nimport { graphemes, optionalSelector, roundTo } from '../internal';\n\nimport type { WrFallingLettersState } from './types';\n\n/** How long the heap lies still before the letters spring back on their own, in ms. */\nconst FALLING_LETTERS_REST = 4000;\n\n/** Downward acceleration, in px/s²: a letter crosses half a screen in about two thirds of a second. */\nconst GRAVITY = 2400;\n\n/** The most a letter drifts sideways as it falls, each way, in px/s. */\nconst DRIFT = 80;\n\n/** The most a letter spins as it falls, each way, in degrees per second. */\nconst SPIN = 160;\n\n/** The letters let go over this long, not all at once, in ms. */\nconst RELEASE = 240;\n\n/** The width of one column of the height map, in px: narrower than a letter, so a heap has a shape. */\nconst COLUMN = 8;\n\n/** How much of the landing speed comes back as a hop. */\nconst RESTITUTION = 0.25;\n\n/** Landing slower than this, a letter settles instead of hopping, in px/s. */\nconst BOUNCE_MIN = 300;\n\n/** What a hop and a wall take off the sideways speed and the spin. */\nconst FRICTION = 0.5;\n\n/** How long one letter's flight back to its place takes, in ms. */\nconst RETURN = 700;\n\n/** The gap between two letters leaving the heap, in ms, and how far the last may start after the first. */\nconst RETURN_GAP = 24;\nconst RETURN_SPREAD = 300;\n\n/** The spring that brings a letter back: this much damping, this many turns of the overshoot per flight. */\nconst SPRING_DAMP = 7;\nconst SPRING_FREQ = 2.4 * Math.PI;\n\n/** The longest step one frame may integrate, in seconds: a stalled frame moves a little, never jumps. */\nconst MAX_STEP = 0.04;\n\n/**\n * How far under a letter's last bottom edge a surface may be, in px, and still\n * count as under it: the rounding of a frame, not a neighbour's top.\n */\nconst SLACK = 0.5;\n\n/** How fast a letter that lands against a neighbour slides clear of it, or climbs out from between two, in px/s. */\nconst SLIDE = 240;\n\n/** How far a letter slides and climbs at most, in px, before it gives up and lies where it is. */\nconst SLIDE_MAX = 48;\n\n/**\n * Multipliers of the low-discrepancy sequences, one per channel: `(n * m) mod 1`\n * spreads over (0, 1) with no two neighbours close, and three irrationals far\n * apart keep the release order, the drift and the spin from following one another.\n */\nconst SCATTER = [0.618_033_988_749_895, 0.414_213_562_373_095, 0.732_050_807_568_877] as const;\n\n/** Letter `i`'s place in (0, 1) on channel `k`: the same for the same letter every time. */\nfunction scatter(i: number, k: 0 | 1 | 2): number {\n const x = ((i + 1) * SCATTER[k]) % 1;\n return x < 0 ? x + 1 : x;\n}\n\n/**\n * A springy ease: overshoots its target by about seven percent, comes back a\n * little under, and is there at `t = 1`. `t` is clamped to [0, 1].\n */\nfunction spring(t: number): number {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n return 1 - Math.exp(-SPRING_DAMP * t) * Math.cos(SPRING_FREQ * t);\n}\n\n/**\n * The floor, as a row of narrow columns, each remembering the top of what has\n * landed in it. A letter lands on the highest top among the columns it covers\n * that lies under it, so later letters sit on earlier ones and the floor fills\n * into a heap, and a letter already level with a neighbour's top is beside\n * that neighbour, not on it.\n */\nclass Heap {\n private readonly tops: Float64Array;\n\n /** `floor` is the y of the empty floor; the columns span `from` to `to`. */\n constructor(\n private readonly from: number,\n to: number,\n private readonly floor: number\n ) {\n this.tops = new Float64Array(Math.max(1, Math.ceil((to - from) / COLUMN))).fill(floor);\n }\n\n /**\n * The y a body spanning `a` to `b` lands on: the smallest y (highest top)\n * among its columns at or under `below`, the body's own bottom edge a frame\n * ago. A column whose top is above that is a neighbour the body is passing\n * beside, so it does not count: a letter that lands next to one already on\n * the floor keeps falling to the floor instead of jumping up onto it. With\n * every column of the span above the body, it falls on to the floor itself.\n */\n top(a: number, b: number, below = -Infinity): number {\n let top = Infinity;\n for (let c = this.column(a); c <= this.column(b); c++) {\n const candidate = this.tops[c];\n if (candidate >= below) top = Math.min(top, candidate);\n }\n return top === Infinity ? this.floor : top;\n }\n\n /**\n * What stands beside a body spanning `a` to `b` that lies with its bottom\n * at `bottom`: how many of its columns, left and right of its middle, end\n * above that bottom, in a neighbour it landed against. `null` when none\n * does and it may lie where it is.\n */\n beside(a: number, b: number, bottom: number): { left: number; right: number } | null {\n const from = this.column(a);\n const to = this.column(b);\n const mid = (from + to) / 2;\n let left = 0;\n let right = 0;\n for (let c = from; c <= to; c++) {\n if (this.tops[c] >= bottom - SLACK) continue;\n if (c <= mid) left++;\n else right++;\n }\n return left === 0 && right === 0 ? null : { left, right };\n }\n\n /** A body spanning `a` to `b` has settled with its top at `y`: its columns now end there. */\n settle(a: number, b: number, y: number): void {\n for (let c = this.column(a); c <= this.column(b); c++) this.tops[c] = Math.min(this.tops[c], y);\n }\n\n private column(x: number): number {\n return Math.min(this.tops.length - 1, Math.max(0, Math.floor((x - this.from) / COLUMN)));\n }\n}\n\n/**\n * The part of a piece that falls and lands: the ink of the glyph, inside the\n * piece's box. `left` and `top` are from the box's top-left corner.\n */\ninterface Body {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** One letter on its way: a piece over the page, its place in the line, and its motion. */\ninterface Piece {\n readonly el: HTMLElement;\n /** The body's size, for the walls and the heap. */\n readonly bw: number;\n readonly bh: number;\n /** The body's centre from the piece's top-left corner: where the piece turns, and what `cx`, `cy` are the position of. */\n readonly ox: number;\n readonly oy: number;\n /** The centre of the body in the line, from the target's padding box. */\n readonly x0: number;\n readonly y0: number;\n /** How long after the click this letter lets go, in seconds. */\n readonly release: number;\n cx: number;\n cy: number;\n angle: number;\n vx: number;\n vy: number;\n spin: number;\n /** How far the letter may still slide and climb to get clear of a neighbour, in px. */\n slide: number;\n /** The top the letter is climbing to, squeezed up from between two neighbours; `null` otherwise. */\n climb: number | null;\n settled: boolean;\n /** Where the flight back started from. */\n fromX: number;\n fromY: number;\n fromAngle: number;\n}\n\n/** The box the letters fall in, from the target's padding box. */\ninterface Bounds {\n readonly minX: number;\n readonly maxX: number;\n readonly floor: number;\n}\n\n/** Half the width and half the height of a body's axis-aligned box at `angle` degrees. */\nfunction extent(piece: Pick<Piece, 'bw' | 'bh'>, angle: number): { hw: number; hh: number } {\n const rad = (angle * Math.PI) / 180;\n const cos = Math.abs(Math.cos(rad));\n const sin = Math.abs(Math.sin(rad));\n return { hw: (piece.bw * cos + piece.bh * sin) / 2, hh: (piece.bh * cos + piece.bw * sin) / 2 };\n}\n\n/**\n * The ink of one grapheme inside its line box, from the canvas text metrics\n * of the same font: the line box is mostly air (the leading, the ascender\n * space over an `a`, the descender space under it), and a heap of air boxes\n * is a heap of letters hanging apart in mid-air. The baseline sits at the\n * box's half-leading plus the font's ascent, as in the line it came from; the\n * ink is the glyph's own bounds about that baseline and the start of its\n * advance. `null` when the browser gives no context or no metrics (jsdom, an\n * invisible glyph), and the piece's box is the body.\n */\nfunction ink(ctx: CanvasRenderingContext2D | null, text: string, box: Pick<DOMRect, 'height'>): Body | null {\n if (!ctx) return null;\n const m = ctx.measureText(text);\n const ascent = m.fontBoundingBoxAscent;\n const descent = m.fontBoundingBoxDescent;\n if (!(ascent >= 0 && descent >= 0)) return null;\n const baseline = (box.height - ascent - descent) / 2 + ascent;\n const left = -m.actualBoundingBoxLeft || 0;\n const top = baseline - m.actualBoundingBoxAscent;\n const width = m.actualBoundingBoxRight - left;\n const height = baseline + m.actualBoundingBoxDescent - top;\n return width > 0.5 && height > 0.5 ? { left, top, width, height } : null;\n}\n\n/** A canvas context set to the element's font, for `ink`; `null` where there is no canvas. */\nfunction measurer(el: HTMLElement): CanvasRenderingContext2D | null {\n const doc = el.ownerDocument;\n const style = doc.defaultView?.getComputedStyle(el);\n const ctx = doc.createElement('canvas').getContext('2d');\n if (!style || !ctx) return null;\n ctx.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;\n return ctx;\n}\n\n/**\n * Click a line of text and its letters let go: each one drops with gravity,\n * drifts and tumbles a little on its own path, and lands on whatever already\n * lies under it, so the letters pile into a heap on the floor of a container.\n * Click again, or leave the heap for a few seconds, and every letter springs\n * back to its exact place in the line; the text is plain text again.\n *\n * No physics engine. A letter's path is gravity plus a sideways drift and a\n * spin drawn from a fixed low-discrepancy sequence by its index, so the same\n * text falls the same way every time and a spec can follow it. What falls is\n * the glyph's ink, measured from the canvas text metrics of the line's font\n * ({@link ink}), not its line box: the box is mostly air, and air boxes would\n * stack into a heap of letters hanging apart. Letters do not collide in the\n * air; they meet on the floor, which is a {@link Heap}: a row of narrow\n * columns, each remembering the top of what has landed in it, and a letter\n * lands on the highest top among the columns it covers that is under it. A\n * top above the letter's last bottom edge is a neighbour it is passing beside,\n * and is ignored: otherwise every letter landing beside one already down\n * would snap up on to it, and the heap would stack into towers in a frame. A\n * letter that lands fast hops once or twice ({@link RESTITUTION}); a slow one\n * that came down against such a neighbour slides along its surface until it\n * is clear ({@link SLIDE}), one down between two climbs out on to the taller,\n * and after {@link SLIDE_MAX} px of that a letter lies where it is. A wall of\n * the container turns the drift around. The floor and the walls are\n * the content box of `floor`'s element, measured when the fall starts.\n *\n * The line never moves. The authored nodes are moved into an invisible\n * wrapper that holds exactly their space, still the real text for a screen\n * reader and the clipboard, and the pieces, one `aria-hidden` span per\n * grapheme, are positioned from the target's own box and move by transform\n * alone, so nothing under them reflows and a button under a falling letter\n * stays clickable (`pointer-events: none`). They inherit the font and the\n * colour. When the last letter is back, the same authored node objects go\n * back where they were and the pieces are removed, so a binding inside the\n * text keeps working through the whole thing.\n *\n * One `requestAnimationFrame` loop runs only while a letter moves: it idles\n * once the heap is still and once the line is whole, and a hidden document\n * pauses it where it is. The return is a springy ease ({@link spring}) with a\n * short stagger in reading order. Nothing happens on the server, under\n * `prefers-reduced-motion: reduce`, or when the target has no box; a\n * preference that flips mid-fall puts the text back at once. Destroy puts the\n * text back, cancels the loop and drops the listener.\n *\n * The effect usually sits on its host, but a selector as the directive's value\n * points it at one descendant instead, for a paragraph a library component\n * draws (`<wr-result-404 wrFallingLetters=\".wr-result__description\">`). The\n * target is looked up once after the first render; if nothing matches, nothing\n * happens.\n */\n@Directive({\n selector: '[wrFallingLetters]',\n})\nexport class WrFallingLetters {\n /**\n * A selector for one descendant of the host whose letters fall instead of\n * the host's own, written as the directive's value:\n * `wrFallingLetters=\".wr-result__description\"`. Resolved once after the\n * first render with `querySelector`; a selector that matches nothing turns\n * the effect off. Unset or empty, the host.\n */\n readonly target = input<string | null, unknown>(null, { alias: 'wrFallingLetters', transform: optionalSelector });\n\n /**\n * A selector for the element whose content box is the floor and the walls,\n * found with `closest` from the host. Unset, the host's parent element: on\n * a `display: contents` host that is the box around it. On a `wr-*` host\n * write it as a binding (`[floor]=\"'main'\"`), since a static attribute that\n * is not one of the component's inputs fails `check:attrs`.\n */\n readonly floor = input<string | null, unknown>(null, { transform: optionalSelector });\n\n /** How long the heap lies still before the letters spring back on their own, in ms. @default 4000 */\n readonly rest = input(FALLING_LETTERS_REST, { transform: wrNumAttr(FALLING_LETTERS_REST) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly platform = inject(WrPlatform);\n private listeners: AbortController | null = null;\n /** The element whose letters fall, once resolved; `null` before and after. */\n private el: HTMLElement | null = null;\n private state: WrFallingLettersState = 'idle';\n /** The authored children while they sit in the wrapper, else `null`. */\n private original: ChildNode[] | null = null;\n private pieces: Piece[] = [];\n private heap: Heap | null = null;\n private bounds: Bounds | null = null;\n private frame: number | null = null;\n /** The timestamp of the last frame, or `null` when the next one is the first after a start. */\n private last: number | null = null;\n /** Seconds since the current phase began, summed from frame steps, so a pause adds nothing. */\n private clock = 0;\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('animations/falling-letters');\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n\n afterNextRender(() => {\n const host = this.host.nativeElement;\n const selector = this.target();\n const el = selector ? host.querySelector<HTMLElement>(selector) : host;\n if (!el) return;\n this.el = el;\n el.classList.add('wr-falling-letters');\n this.listeners = new AbortController();\n el.addEventListener('click', () => this.toggle(), { signal: this.listeners.signal });\n });\n\n // One place decides what the loop does: reduced motion puts the text\n // back, a hidden page pauses, otherwise a phase in motion gets a frame.\n effect(() => {\n const visible = this.platform.pageVisible();\n const reduced = this.platform.prefersReducedMotion();\n untracked(() => {\n if (reduced) this.restore();\n else if (!visible) this.pause();\n else if (this.state === 'fall' || this.state === 'return') this.start();\n });\n });\n\n inject(DestroyRef).onDestroy(() => {\n this.listeners?.abort();\n this.listeners = null;\n this.restore();\n this.el?.classList.remove('wr-falling-letters');\n this.el = null;\n });\n }\n\n /** A click: plain text falls; a heap, still or in the making, springs back; a flight back is left alone. */\n private toggle(): void {\n if (this.platform.prefersReducedMotion()) return;\n if (this.state === 'idle') this.fall();\n else if (this.state === 'fall' || this.state === 'rest') this.spring();\n }\n\n /**\n * Measure every grapheme in place, then swap in the pieces and hide the\n * line, all in one task, so the first paint shows each piece exactly over\n * its letter. The measurement wraps each grapheme in an inline-block for one\n * synchronous layout and puts the authored nodes straight back, so no frame\n * ever shows the probe.\n */\n private fall(): void {\n const el = this.el;\n if (!el) return;\n const doc = el.ownerDocument;\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) return;\n\n const original = Array.from(el.childNodes);\n const wrapper = doc.createElement('span');\n wrapper.className = 'wr-falling-letters__text';\n const glyphs: { el: HTMLElement; text: string; node: Node | null }[] = [];\n for (const node of original) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n // An inline element (`<code>`, `<a>`) is one piece, a copy of the whole thing.\n const probe = doc.createElement('span');\n probe.className = 'wr-falling-letters__glyph';\n probe.append(node);\n wrapper.append(probe);\n glyphs.push({ el: probe, text: '', node });\n } else if (node.nodeType === Node.TEXT_NODE) {\n for (const grapheme of graphemes(node.textContent ?? '')) {\n if (grapheme.trim() === '') {\n wrapper.append(grapheme);\n continue;\n }\n const probe = doc.createElement('span');\n probe.className = 'wr-falling-letters__glyph';\n probe.textContent = grapheme;\n wrapper.append(probe);\n glyphs.push({ el: probe, text: grapheme, node: null });\n }\n }\n }\n el.replaceChildren(wrapper);\n\n const origin = { x: box.left + el.clientLeft, y: box.top + el.clientTop };\n const rects = glyphs.map(glyph => glyph.el.getBoundingClientRect());\n const container = this.container();\n const bounds = this.measure(container ?? el, origin, box);\n // The text's font, read once: every grapheme of the line shares it. An\n // inline element is one piece with its own font and its own box, and its\n // box (a chip, a link) is its ink.\n const ctx = measurer(el);\n\n // The authored nodes back, the same objects, in their order: the wrapper now holds the line's space.\n wrapper.replaceChildren(...original);\n\n const layer = doc.createElement('span');\n layer.className = 'wr-falling-letters__pieces';\n layer.setAttribute('aria-hidden', 'true');\n const pieces: Piece[] = [];\n glyphs.forEach((glyph, i) => {\n const rect = rects[i];\n if (rect.width <= 0 || rect.height <= 0) return;\n const piece = doc.createElement('span');\n piece.className = 'wr-falling-letters__piece';\n if (glyph.node) piece.append(glyph.node.cloneNode(true));\n else piece.textContent = glyph.text;\n const n = pieces.length;\n const body: Body = (glyph.node ? null : ink(ctx, glyph.text, rect)) ?? {\n left: 0,\n top: 0,\n width: rect.width,\n height: rect.height,\n };\n const ox = body.left + body.width / 2;\n const oy = body.top + body.height / 2;\n piece.style.transformOrigin = `${roundTo(ox, 2)}px ${roundTo(oy, 2)}px`;\n const x0 = rect.left - origin.x + ox;\n const y0 = rect.top - origin.y + oy;\n pieces.push({\n el: piece,\n bw: body.width,\n bh: body.height,\n ox,\n oy,\n x0,\n y0,\n release: (scatter(n, 0) * RELEASE) / 1000,\n cx: x0,\n cy: y0,\n angle: 0,\n vx: (scatter(n, 1) - 0.5) * 2 * DRIFT,\n vy: 0,\n spin: (scatter(n, 2) - 0.5) * 2 * SPIN,\n slide: SLIDE_MAX,\n climb: null,\n settled: false,\n fromX: x0,\n fromY: y0,\n fromAngle: 0,\n });\n layer.append(piece);\n });\n if (pieces.length === 0) {\n el.replaceChildren(...original);\n return;\n }\n\n this.original = original;\n this.pieces = pieces;\n this.heap = new Heap(bounds.minX, bounds.maxX, bounds.floor);\n this.bounds = bounds;\n for (const piece of pieces) this.paint(piece);\n el.append(layer);\n el.classList.add('wr-falling-letters--out');\n this.state = 'fall';\n this.clock = 0;\n this.start();\n }\n\n /** The element whose content box is the floor: `floor`'s closest match from the host, else the host's parent. */\n private container(): HTMLElement | null {\n const host = this.host.nativeElement;\n const selector = this.floor();\n return selector ? host.closest<HTMLElement>(selector) : host.parentElement;\n }\n\n /**\n * The floor and the walls, from the target's padding box: the container's\n * content box, and never above the line itself, so a letter always has\n * somewhere to fall.\n */\n private measure(container: HTMLElement, origin: { x: number; y: number }, box: DOMRect): Bounds {\n const rect = container.getBoundingClientRect();\n const style = container.ownerDocument.defaultView?.getComputedStyle(container);\n const pad = (value: string | undefined): number => {\n const n = value === undefined ? NaN : parseFloat(value);\n return Number.isFinite(n) ? n : 0;\n };\n const minX = rect.left + pad(style?.paddingLeft) - origin.x;\n const maxX = rect.left + rect.width - pad(style?.paddingRight) - origin.x;\n const floor = rect.top + rect.height - pad(style?.paddingBottom) - origin.y;\n return { minX: Math.min(minX, 0), maxX: Math.max(maxX, box.width), floor: Math.max(floor, box.height) };\n }\n\n /** Every letter leaves where it is, heap or mid-air, for its place in the line. */\n private spring(): void {\n this.clearTimer();\n for (const piece of this.pieces) {\n piece.fromX = piece.cx;\n piece.fromY = piece.cy;\n piece.fromAngle = piece.angle;\n }\n this.state = 'return';\n this.clock = 0;\n this.start();\n }\n\n /** Ask for a frame, unless one is pending, nothing moves or the page is hidden. */\n private start(): void {\n if (this.frame !== null || this.state === 'idle' || this.state === 'rest') return;\n if (!untracked(() => this.platform.pageVisible())) return;\n this.last = null;\n this.frame = requestAnimationFrame(t => this.tick(t));\n }\n\n /** Drop the pending frame. The pieces stay where they are, so a restart continues from them. */\n private pause(): void {\n if (this.frame === null) return;\n cancelAnimationFrame(this.frame);\n this.frame = null;\n this.last = null;\n }\n\n /**\n * Put the authored children back, the same node objects, and drop the\n * wrapper and the pieces. Idempotent: the end of the flight back, reduced\n * motion and destroy all call it.\n */\n private restore(): void {\n this.pause();\n this.clearTimer();\n this.state = 'idle';\n if (!this.original) return;\n this.el?.replaceChildren(...this.original);\n this.el?.classList.remove('wr-falling-letters--out');\n this.original = null;\n this.pieces = [];\n this.heap = null;\n this.bounds = null;\n }\n\n /**\n * One frame. The first after a start has no length, so a pause of any length\n * moves nothing when the loop resumes. The fall ends when the last letter\n * settles, and the heap lies still until a click or the rest timer; the\n * flight back ends when the last letter is home, and the text is whole again.\n */\n private tick(now: number): void {\n const dt = this.last === null ? 0 : Math.min(Math.max(0, now - this.last) / 1000, MAX_STEP);\n this.last = now;\n this.clock += dt;\n const done = this.state === 'fall' ? this.stepFall(dt) : this.stepReturn();\n if (!done) {\n this.frame = requestAnimationFrame(t => this.tick(t));\n return;\n }\n this.frame = null;\n this.last = null;\n if (this.state === 'return') {\n this.restore();\n return;\n }\n this.state = 'rest';\n this.timer = setTimeout(\n () => {\n this.timer = null;\n this.spring();\n },\n Math.max(0, this.rest())\n );\n }\n\n /** Gravity, drift, spin, the walls and the heap for every letter still in the air. True once all have settled. */\n private stepFall(dt: number): boolean {\n const heap = this.heap;\n const bounds = this.bounds;\n if (!heap || !bounds) return true;\n let settled = true;\n for (const piece of this.pieces) {\n if (piece.settled) continue;\n settled = false;\n if (this.clock < piece.release) continue;\n if (piece.climb !== null) {\n // Squeezed up from between two neighbours at the slide's pace, until\n // the body is level with the top of the taller one; then it drops on.\n const rest = piece.climb - extent(piece, piece.angle).hh;\n piece.cy = Math.max(rest, piece.cy - SLIDE * dt);\n piece.slide -= SLIDE * dt;\n if (piece.cy <= rest) piece.climb = null;\n this.paint(piece);\n continue;\n }\n const below = piece.cy + extent(piece, piece.angle).hh;\n piece.vy += GRAVITY * dt;\n piece.cx += piece.vx * dt;\n piece.cy += piece.vy * dt;\n piece.angle += piece.spin * dt;\n const { hw, hh } = extent(piece, piece.angle);\n\n if (piece.cx - hw < bounds.minX) {\n piece.cx = bounds.minX + hw;\n piece.vx = Math.abs(piece.vx) * FRICTION;\n } else if (piece.cx + hw > bounds.maxX) {\n piece.cx = bounds.maxX - hw;\n piece.vx = -Math.abs(piece.vx) * FRICTION;\n }\n\n const top = heap.top(piece.cx - hw, piece.cx + hw, below - SLACK);\n if (piece.cy + hh >= top) {\n piece.cy = top - hh;\n if (piece.vy > BOUNCE_MIN) {\n piece.vy = -piece.vy * RESTITUTION;\n piece.vx *= FRICTION;\n piece.spin *= FRICTION;\n } else {\n piece.vy = 0;\n piece.spin = 0;\n const beside = piece.slide > 0 ? heap.beside(piece.cx - hw, piece.cx + hw, piece.cy + hh) : null;\n if (beside && beside.left > 0 && beside.right > 0) {\n // Down between two neighbours: climb out, to the top of the taller.\n piece.vx = 0;\n piece.climb = heap.top(piece.cx - hw, piece.cx + hw);\n } else if (beside) {\n // Down against a neighbour that is already there: slide along the\n // surface until clear of it, as letters landing on one another do,\n // instead of lying inside it or jumping up on to it.\n piece.vx = (beside.left > 0 ? 1 : -1) * SLIDE;\n piece.slide -= SLIDE * dt;\n } else {\n piece.vx = 0;\n piece.settled = true;\n // The heap learns of the letter once it lies still, not at first\n // touch: a letter that touched down, hopped and came to rest a step\n // away would leave a top in the air for the next one to hang on.\n heap.settle(piece.cx - hw, piece.cx + hw, piece.cy - hh);\n }\n }\n }\n this.paint(piece);\n }\n return settled;\n }\n\n /** Each letter springs from where it left toward its place, in reading order. True once all are home. */\n private stepReturn(): boolean {\n const count = this.pieces.length;\n const gap = Math.min(RETURN_GAP, RETURN_SPREAD / Math.max(1, count - 1)) / 1000;\n let home = true;\n this.pieces.forEach((piece, i) => {\n const t = (this.clock - i * gap) / (RETURN / 1000);\n if (t < 0) {\n home = false;\n return;\n }\n const s = spring(t);\n piece.cx = piece.fromX + (piece.x0 - piece.fromX) * s;\n piece.cy = piece.fromY + (piece.y0 - piece.fromY) * s;\n piece.angle = piece.fromAngle * (1 - s);\n if (t < 1) home = false;\n this.paint(piece);\n });\n return home;\n }\n\n /** Written to the DOM by hand: a binding would wait for change detection, and this is every frame. */\n private paint(piece: Piece): void {\n const x = roundTo(piece.cx - piece.ox, 2);\n const y = roundTo(piece.cy - piece.oy, 2);\n const angle = roundTo(piece.angle, 2);\n piece.el.style.transform = `translate(${x}px, ${y}px) rotate(${angle}deg)`;\n }\n\n private clearTimer(): void {\n if (this.timer !== null) clearTimeout(this.timer);\n this.timer = null;\n }\n}\n\nexport {\n BOUNCE_MIN,\n COLUMN,\n DRIFT,\n FALLING_LETTERS_REST,\n GRAVITY,\n Heap,\n RELEASE,\n RESTITUTION,\n RETURN,\n RETURN_GAP,\n RETURN_SPREAD,\n SLACK,\n SLIDE,\n SLIDE_MAX,\n SPIN,\n ink,\n scatter,\n spring,\n};\n"],"mappings":";;;;;;;;;;;;AA4BA,MAAM,uBAAuB;AAG7B,MAAM,UAAU;AAehB,MAAM,cAAc;AAMpB,MAAM,WAAW;AAWjB,MAAM,cAAc,MAAM,KAAK;AAG/B,MAAM,WAAW;AAMjB,MAAM,QAAQ;AAad,MAAM,UAAU;CAAC;CAAuB;CAAuB;AAAqB;AAGpF,SAAS,QAAQ,GAAW,GAAY;CACtC,MAAM,KAAM,IAAI,KAAK,QAAQ,KAAM;CACnC,OAAO,IAAI,IAAI,IAAI,IAAI;AACzB;AAMA,SAAS,OAAO,GAAS;CACvB,IAAI,KAAK,GAAG,OAAO;CACnB,IAAI,KAAK,GAAG,OAAO;CACnB,OAAO,IAAI,KAAK,IAAI,KAAe,CAAC,IAAI,KAAK,IAAI,cAAc,CAAC;AAClE;AASA,IAAM,OAAN,MAAU;CAKW;CAEA;CANF;CAGjB,YACmB,MACjB,IACiB,OAAa;EAFb,KAAA,OAAA;EAEA,KAAA,QAAA;EAEjB,KAAK,OAAO,IAAI,aAAa,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,QAAA,CAAc,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK;CACvF;CAUA,IAAI,GAAW,GAAW,QAAQ,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