u2ui 1.0.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/.htaccess +7 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/attr/behavior/README.md +25 -0
- package/attr/behavior/behavior.js +261 -0
- package/attr/behavior/manifest.json +43 -0
- package/attr/behavior/tests/minimal.html +19 -0
- package/attr/behavior/tests/test.html +98 -0
- package/attr/confirm/README.md +36 -0
- package/attr/confirm/confirm.js +90 -0
- package/attr/confirm/manifest.json +43 -0
- package/attr/confirm/tests/minimal.html +23 -0
- package/attr/confirm/tests/test.html +79 -0
- package/attr/draghandle/README.md +41 -0
- package/attr/draghandle/draghandle.js +42 -0
- package/attr/draghandle/tests/minimal.html +44 -0
- package/attr/focusgroup/README.md +49 -0
- package/attr/focusgroup/focusgroup.js +100 -0
- package/attr/focusgroup/manifest.json +38 -0
- package/attr/focusgroup/tests/minimal.html +27 -0
- package/attr/focusgroup/tests/test.html +154 -0
- package/attr/href/README.md +38 -0
- package/attr/href/href.js +42 -0
- package/attr/href/manifest.json +43 -0
- package/attr/href/tests/minimal.html +17 -0
- package/attr/href/tests/test.html +70 -0
- package/attr/intersect/README.md +42 -0
- package/attr/intersect/intersect.js +99 -0
- package/attr/intersect/manifest.json +57 -0
- package/attr/intersect/tests/minimal.html +30 -0
- package/attr/intersect/tests/test.html +64 -0
- package/attr/navigable/README.md +31 -0
- package/attr/navigable/TargetObserver.js +91 -0
- package/attr/navigable/U2TargetObserver.js +75 -0
- package/attr/navigable/manifest.json +42 -0
- package/attr/navigable/navigable.js +87 -0
- package/attr/navigable/tests/U1TargetObserver.html +56 -0
- package/attr/navigable/tests/minimal.html +17 -0
- package/attr/navigable/tests/targetObserver.html +106 -0
- package/attr/navigable/tests/test.html +84 -0
- package/attr/parallax/README.md +48 -0
- package/attr/parallax/parallax.js +119 -0
- package/attr/parallax/tests/minimal.html +25 -0
- package/attr/parallax/tests/performance.html +102 -0
- package/attr/parallax/tests/test.html +108 -0
- package/attr/skin/README.md +59 -0
- package/attr/skin/skin.css +51 -0
- package/attr/skin/tests/minimal.html +34 -0
- package/attr/skin/tests/test.html +96 -0
- package/class/badge/README.md +25 -0
- package/class/badge/badge.css +35 -0
- package/class/badge/tests/minimal.html +17 -0
- package/class/badge/tests/test.html +112 -0
- package/class/card1/README.md +45 -0
- package/class/card1/card1.css +30 -0
- package/class/card1/tests/minimal.html +33 -0
- package/class/card1/tests/test.html +78 -0
- package/class/flex/README.md +62 -0
- package/class/flex/flex.css +25 -0
- package/class/flex/tests/minimal.html +31 -0
- package/class/flex/tests/test.html +58 -0
- package/class/grid/README.md +52 -0
- package/class/grid/grid.css +40 -0
- package/class/grid/tests/minimal.html +34 -0
- package/class/grid/tests/test.html +78 -0
- package/class/input/README.md +49 -0
- package/class/input/input.css +33 -0
- package/class/input/tests/minimal.html +39 -0
- package/class/input/tests/test.html +29 -0
- package/class/reset/README.md +47 -0
- package/class/reset/reset.css +8 -0
- package/class/reset/tests/minimal.html +23 -0
- package/class/table/README.md +57 -0
- package/class/table/table.css +126 -0
- package/class/table/tests/minimal.html +40 -0
- package/class/table/tests/test.html +226 -0
- package/class/unstyle/README.md +32 -0
- package/class/unstyle/tests/minimal.html +22 -0
- package/class/unstyle/tests/test.html +32 -0
- package/class/unstyle/unstyle.css +12 -0
- package/class/width/README.md +48 -0
- package/class/width/tests/minimal.html +27 -0
- package/class/width/tests/test.html +101 -0
- package/class/width/width.css +22 -0
- package/css/base/README.md +25 -0
- package/css/base/base.css +127 -0
- package/css/base/beta.css +50 -0
- package/css/base/full.css +5 -0
- package/css/base/nomotion.css +9 -0
- package/css/base/print.css +36 -0
- package/css/base/tests/nomotion.html +89 -0
- package/css/base/tests/test.html +539 -0
- package/css/classes/README.md +17 -0
- package/css/classes/classes.css +78 -0
- package/css/classes/tests/test.html +63 -0
- package/css/classless/README.md +26 -0
- package/css/classless/aria.css +64 -0
- package/css/classless/classless.css +124 -0
- package/css/classless/full.css +11 -0
- package/css/classless/more.css +340 -0
- package/css/classless/simple.css +103 -0
- package/css/classless/snippeds/a/icons.css +12 -0
- package/css/classless/snippeds/experiments/conventions.css +41 -0
- package/css/classless/snippeds/hr/gradient.css +3 -0
- package/css/classless/snippeds/hr/section_sign.css +16 -0
- package/css/classless/snippeds/hr/tests.html +50 -0
- package/css/classless/tests/aria.html +101 -0
- package/css/classless/tests/foreign/classless-almond.css.html +445 -0
- package/css/classless/tests/foreign/classless-classless.css.html +831 -0
- package/css/classless/tests/foreign/classless-mvp.html +415 -0
- package/css/classless/tests/foreign/classless.sakura.html +224 -0
- package/css/classless/tests/foreign/stylestage.dev.html +304 -0
- package/css/classless/tests/foreign/test-homogenizer.html +433 -0
- package/css/classless/tests/foreign/test-html5-elements-tester.html +956 -0
- package/css/classless/tests/foreign/test-opinionated_css.html +148 -0
- package/css/classless/tests/list-bullet.html +110 -0
- package/css/classless/tests/more.html +246 -0
- package/css/classless/tests/oklch.experiments.html +280 -0
- package/css/classless/tests/test.html +106 -0
- package/css/classless/tests/variables.html +109 -0
- package/css/classless/variables.css +99 -0
- package/css/norm/README.md +37 -0
- package/css/norm/beta.css +40 -0
- package/css/norm/norm.css +98 -0
- package/css/norm/oldies.css +60 -0
- package/css/norm/tests/test.html +434 -0
- package/css/norm/tests/test.js +103 -0
- package/el/accordion/README.md +59 -0
- package/el/accordion/accordion.css +7 -0
- package/el/accordion/accordion.js +258 -0
- package/el/accordion/manifest.json +57 -0
- package/el/accordion/tests/minimal.html +44 -0
- package/el/accordion/tests/test.html +168 -0
- package/el/alert/README.md +67 -0
- package/el/alert/alert copy.js +224 -0
- package/el/alert/alert.css +73 -0
- package/el/alert/alert.js +187 -0
- package/el/alert/manifest.json +77 -0
- package/el/alert/tests/minimal.html +36 -0
- package/el/alert/tests/test.html +105 -0
- package/el/buttongroup/README.md +36 -0
- package/el/buttongroup/buttongroup.css +30 -0
- package/el/buttongroup/buttongroup.js +56 -0
- package/el/buttongroup/tests/minimal.html +31 -0
- package/el/buttongroup/tests/test.html +83 -0
- package/el/bytes/README.md +41 -0
- package/el/bytes/bytes.css +6 -0
- package/el/bytes/bytes.js +97 -0
- package/el/bytes/manifest.json +95 -0
- package/el/bytes/tests/minimal.html +19 -0
- package/el/bytes/tests/test.html +117 -0
- package/el/carousel/README.md +52 -0
- package/el/carousel/carousel.css +46 -0
- package/el/carousel/carousel.js +371 -0
- package/el/carousel/manifest.json +58 -0
- package/el/carousel/tests/experiments.html +77 -0
- package/el/carousel/tests/minimal.html +31 -0
- package/el/carousel/tests/nested.html +54 -0
- package/el/carousel/tests/test.html +136 -0
- package/el/carousel-nav/README.md +40 -0
- package/el/carousel-nav/carousel-nav.js +74 -0
- package/el/carousel-nav/tests/minimal.html +32 -0
- package/el/carousel-nav/tests/test.html +59 -0
- package/el/code/README.md +68 -0
- package/el/code/code.css +46 -0
- package/el/code/code.js +289 -0
- package/el/code/manifest.json +66 -0
- package/el/code/tests/minimal.html +35 -0
- package/el/code/tests/test.html +162 -0
- package/el/copy/README.md +35 -0
- package/el/copy/copy.css +3 -0
- package/el/copy/copy.js +118 -0
- package/el/copy/manifest.json +49 -0
- package/el/copy/tests/minimal.html +21 -0
- package/el/copy/tests/test.html +75 -0
- package/el/counter/README.md +47 -0
- package/el/counter/counter.css +8 -0
- package/el/counter/counter.js +95 -0
- package/el/counter/manifest.json +59 -0
- package/el/counter/tests/minimal.html +27 -0
- package/el/counter/tests/test.html +106 -0
- package/el/ico/README.md +162 -0
- package/el/ico/font/Font Awesome.css +22 -0
- package/el/ico/font/LigatureSymbols.css +7 -0
- package/el/ico/font/Material Icons.css +6 -0
- package/el/ico/font/RemixFilled.css +8 -0
- package/el/ico/font/RemixOutlined.css +8 -0
- package/el/ico/font/old/anicons.css +31 -0
- package/el/ico/font/old/devicons.css +210 -0
- package/el/ico/font/old/material.all.css +36 -0
- package/el/ico/font/old/remix.css +15 -0
- package/el/ico/font/old/utf8.css +54 -0
- package/el/ico/ico.css +111 -0
- package/el/ico/ico.js +189 -0
- package/el/ico/manifest.json +86 -0
- package/el/ico/tests/combinations.html +86 -0
- package/el/ico/tests/emojis.html +213 -0
- package/el/ico/tests/fonts.html +110 -0
- package/el/ico/tests/ico-directory.html +254 -0
- package/el/ico/tests/minimal.html +46 -0
- package/el/ico/tests/test.html +210 -0
- package/el/ico/tests/util-multi.svg +6 -0
- package/el/ico/tests/util.css +2 -0
- package/el/ico/tests/util.js +110 -0
- package/el/input/README.md +39 -0
- package/el/input/input.css +35 -0
- package/el/input/input.js +331 -0
- package/el/input/tests/formParticipation.html +113 -0
- package/el/input/tests/minimal.html +33 -0
- package/el/input/tests/test.html +258 -0
- package/el/masonry/README.md +51 -0
- package/el/masonry/manifest.json +60 -0
- package/el/masonry/masonry.css +27 -0
- package/el/masonry/masonry.js +92 -0
- package/el/masonry/tests/minimal.html +39 -0
- package/el/masonry/tests/test.html +42 -0
- package/el/number/README.md +47 -0
- package/el/number/manifest.json +121 -0
- package/el/number/number.css +6 -0
- package/el/number/number.js +67 -0
- package/el/number/tests/minimal.html +25 -0
- package/el/number/tests/test.html +138 -0
- package/el/out/README.md +32 -0
- package/el/out/manifest.json +38 -0
- package/el/out/out.css +2 -0
- package/el/out/out.js +59 -0
- package/el/out/tests/minimal.html +25 -0
- package/el/out/tests/test.html +37 -0
- package/el/parallax-bg/README.md +36 -0
- package/el/parallax-bg/parallax-bg.css +13 -0
- package/el/parallax-bg/parallax-bg.js +186 -0
- package/el/parallax-bg/tests/bg.jpg +0 -0
- package/el/parallax-bg/tests/bg1.jpg +0 -0
- package/el/parallax-bg/tests/bg2.jpg +0 -0
- package/el/parallax-bg/tests/demo.html +88 -0
- package/el/parallax-bg/tests/minimal.html +30 -0
- package/el/parallax-bg/tests/test.html +64 -0
- package/el/parallax-bg/tests/visible.html +90 -0
- package/el/qrcode/README.md +38 -0
- package/el/qrcode/manifest.json +43 -0
- package/el/qrcode/package.json +22 -0
- package/el/qrcode/qrcode.css +13 -0
- package/el/qrcode/qrcode.js +46 -0
- package/el/qrcode/tests/minimal.html +26 -0
- package/el/qrcode/tests/test.html +31 -0
- package/el/rating/README.md +45 -0
- package/el/rating/manifest.json +65 -0
- package/el/rating/rating.css +11 -0
- package/el/rating/rating.js +139 -0
- package/el/rating/tests/minimal.html +26 -0
- package/el/rating/tests/tests.html +77 -0
- package/el/rte/README.md +37 -0
- package/el/rte/rte.css +9 -0
- package/el/rte/rte.js +56 -0
- package/el/rte/tests/minimal.html +25 -0
- package/el/rte/tests/test.html +37 -0
- package/el/skeleton/README.md +30 -0
- package/el/skeleton/manifest.json +51 -0
- package/el/skeleton/skeleton.css +61 -0
- package/el/skeleton/skeleton.js +72 -0
- package/el/skeleton/tests/minimal.html +22 -0
- package/el/skeleton/tests/test.html +22 -0
- package/el/splitbutton/README.md +39 -0
- package/el/splitbutton/splitbutton.css +48 -0
- package/el/splitbutton/splitbutton.js +26 -0
- package/el/splitbutton/tests/minimal.html +30 -0
- package/el/splitbutton/tests/test.html +68 -0
- package/el/splitpanel/README.md +39 -0
- package/el/splitpanel/manifest.json +49 -0
- package/el/splitpanel/splitpanel.css +17 -0
- package/el/splitpanel/splitpanel.js +116 -0
- package/el/splitpanel/tests/minimal.html +31 -0
- package/el/splitpanel/tests/tests.html +121 -0
- package/el/table/README.md +68 -0
- package/el/table/manifest.json +43 -0
- package/el/table/table.css +59 -0
- package/el/table/table.js +194 -0
- package/el/table/tests/minimal.html +38 -0
- package/el/table/tests/test.html +108 -0
- package/el/tabs/README.md +50 -0
- package/el/tabs/manifest.json +59 -0
- package/el/tabs/tabs.css +23 -0
- package/el/tabs/tabs.js +210 -0
- package/el/tabs/tests/minimal.html +35 -0
- package/el/tabs/tests/test.html +180 -0
- package/el/textfit/README.md +34 -0
- package/el/textfit/manifest.json +45 -0
- package/el/textfit/tests/minimal.html +25 -0
- package/el/textfit/tests/test.html +26 -0
- package/el/textfit/textfit.css +6 -0
- package/el/textfit/textfit.js +80 -0
- package/el/time/README.md +72 -0
- package/el/time/manifest.json +118 -0
- package/el/time/tests/minimal.html +19 -0
- package/el/time/tests/test.html +160 -0
- package/el/time/time copy.js +141 -0
- package/el/time/time.js +168 -0
- package/el/time/time.old.uhtml.js +129 -0
- package/el/tooltip/README.md +48 -0
- package/el/tooltip/manifest.json +69 -0
- package/el/tooltip/tests/minimal.html +25 -0
- package/el/tooltip/tests/test.html +178 -0
- package/el/tooltip/tooltip.css +97 -0
- package/el/tooltip/tooltip.js +82 -0
- package/el/tree1/README.md +111 -0
- package/el/tree1/manifest.json +78 -0
- package/el/tree1/tests/animated.html +134 -0
- package/el/tree1/tests/custom.html +51 -0
- package/el/tree1/tests/minimal.html +44 -0
- package/el/tree1/tests/test.html +260 -0
- package/el/tree1/tree1.css +26 -0
- package/el/tree1/tree1.js +265 -0
- package/el/typewriter/README.md +62 -0
- package/el/typewriter/manifest.json +66 -0
- package/el/typewriter/tests/minimal.html +25 -0
- package/el/typewriter/tests/test.html +78 -0
- package/el/typewriter/typewriter.css +6 -0
- package/el/typewriter/typewriter.js +166 -0
- package/el/typewriter/typewriter.mp3 +0 -0
- package/js/Placer/Placer.js +156 -0
- package/js/Placer/README.md +62 -0
- package/js/Placer/tests/minimal.html +34 -0
- package/js/Placer/tests/test.html +49 -0
- package/js/PointerObserver/PointerObserver.js +130 -0
- package/js/PointerObserver/README.md +34 -0
- package/js/PointerObserver/tests/minimal.html +29 -0
- package/js/PointerObserver/tests/test.html +35 -0
- package/js/SelectorObserver/README.md +47 -0
- package/js/SelectorObserver/SelectorObserver.js +201 -0
- package/js/SelectorObserver/tests/minimal.html +21 -0
- package/js/SelectorObserver/tests/test.html +57 -0
- package/js/SelectorObserver/tests/tests.html +161 -0
- package/js/contextmenu/README.md +93 -0
- package/js/contextmenu/contextmenu.js +336 -0
- package/js/contextmenu/tests/minimal.html +44 -0
- package/js/contextmenu/tests/test.html +131 -0
- package/js/dialog/README.md +49 -0
- package/js/dialog/dialog.js +261 -0
- package/js/dialog/notification.mp3 +0 -0
- package/js/dialog/tests/minimal.html +29 -0
- package/js/dialog/tests/notification.mp3 +0 -0
- package/js/dialog/tests/test.html +135 -0
- package/js/rte/README.md +44 -0
- package/js/rte/old/NodeCleaner.js +315 -0
- package/js/rte/old/Rte/Rte.mjs +316 -0
- package/js/rte/old/Rte/Rte.ui.items.mjs +543 -0
- package/js/rte/old/Rte/Rte.ui.mjs +154 -0
- package/js/rte/old/Rte/crossbrowser.mjs +323 -0
- package/js/rte/old/Rte/font/tinymce.svg +98 -0
- package/js/rte/old/Rte/font/tinymce.woff +0 -0
- package/js/rte/old/Rte/helpers.mjs +159 -0
- package/js/rte/old/Rte/htmlparser.mjs +178 -0
- package/js/rte/old/Rte/index.mjs +5 -0
- package/js/rte/old/Rte/main.css +189 -0
- package/js/rte/old/old.rte.js +132 -0
- package/js/rte/old/range-selection.old.js +394 -0
- package/js/rte/rte.js +7 -0
- package/js/rte/src/behavior.js +228 -0
- package/js/rte/src/events.js +73 -0
- package/js/rte/src/fixes.js +251 -0
- package/js/rte/src/range.js +472 -0
- package/js/rte/src/rte.js +72 -0
- package/js/rte/src/ui/items/ai.js +167 -0
- package/js/rte/src/ui/items/code.js +93 -0
- package/js/rte/src/ui/items/undo.js +183 -0
- package/js/rte/src/ui.items.js +571 -0
- package/js/rte/src/ui.js +269 -0
- package/js/rte/src/util/htmlparser.js +178 -0
- package/js/rte/src/util/indentHtml.js +48 -0
- package/js/rte/tests/ai.html +81 -0
- package/js/rte/tests/behavior.html +88 -0
- package/js/rte/tests/events.html +69 -0
- package/js/rte/tests/fixes.html +95 -0
- package/js/rte/tests/minimal.html +34 -0
- package/js/rte/tests/notes.md +6 -0
- package/js/rte/tests/range.html +167 -0
- package/js/rte/tests/selection-explorer.html +222 -0
- package/js/rte/tests/test.html +92 -0
- package/js/shortcut/README.md +33 -0
- package/js/shortcut/shortcut.js +89 -0
- package/js/shortcut/tests/minimal.html +23 -0
- package/js/shortcut/tests/test.html +68 -0
- package/package.json +12 -0
- package/u2/README.md +4 -0
- package/u2/auto.js +161 -0
- package/u2/auto.ui.js +85 -0
- package/u2/experiments/Waiter/test.html +132 -0
- package/u2/experiments/getElementByIdPromise/test.html +76 -0
- package/u2/experiments/patchInputValue.html +124 -0
- package/u2/experiments/radiobutton/test.html +75 -0
- package/u2/experiments/tests/test.html +223 -0
- package/u2/experiments/u1-responsive/responsive.js +62 -0
- package/u2/experiments/u1-responsive/test.html +65 -0
- package/u2/experiments/u2Element.js +139 -0
- package/u2/experiments/u2Element.test.html +47 -0
- package/u2/old-stuff/IterableWeakMap/mod.js +70 -0
- package/u2/old-stuff/css/onStyleSheet/mod.js +114 -0
- package/u2/old-stuff/css/onStyleSheet/monkeypatches.js +28 -0
- package/u2/old-stuff/css/onStyleSheet/test/include.css +19 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-has-include.css +6 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-no-include.css +3 -0
- package/u2/old-stuff/css/onStyleSheet/test/test.html +48 -0
- package/u2/old-stuff/css/parser/mod.js +182 -0
- package/u2/old-stuff/css/parser/parser_old/mod.js +128 -0
- package/u2/old-stuff/css/parser/parser_old/test.html +43 -0
- package/u2/old-stuff/css/parser/parser_old/util.js +22 -0
- package/u2/old-stuff/css/parser/style.html +52 -0
- package/u2/old-stuff/css/parser/test.html +38 -0
- package/u2/old-stuff/el/ai-texter/README.md +23 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.css +12 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.js +153 -0
- package/u2/old-stuff/el/ai-texter/tests/minimal.html +47 -0
- package/u2/old-stuff/el/ai-texter/tests/test.html +71 -0
- package/u2/old-stuff/init.js +38 -0
- package/u2/old-stuff/markHashLinks.js +51 -0
- package/u2/old-stuff/onElement/mod.js +73 -0
- package/u2/old-stuff/test-helpers/mod.js +36 -0
- package/u2/old-stuff/test-helpers/test.html +4 -0
- package/u2/old-stuff/tests/init.js.html +51 -0
- package/u2/old-stuff/viewport.js +64 -0
- package/u2/projects.json +468 -0
- package/u2/tests/boilerplate.html +46 -0
- package/u2/tests/kacheln.html +245 -0
- package/u2/tests/showcase.html +270 -0
- package/u2/tests/showcase2.html +157 -0
- package/u2/tests/test-init.js +35 -0
- package/u2/tests/test.html +355 -0
- package/u2/tools/baseElement.js +95 -0
- package/u2/tools/baseElement.test.html +119 -0
- package/u2/tools/ce-inspector.js +308 -0
- package/u2/tools/ce-inspector.test.html +66 -0
- package/u2/tools/ce-manfest-from-element.js +207 -0
- package/u2/tools/dev-iframe.js +213 -0
- package/u2/tools/dev-iframe.test.html +75 -0
- package/u2/tools/eventsExplorer.js +101 -0
- package/u2/tools/logo/u1.svg +9 -0
- package/u2/tools/logo/u1ui.svg +6 -0
- package/u2/tools/update.repos.json.js +234 -0
- package/u2/u2.js +14 -0
- package/u2/utils.js +59 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset=utf-8>
|
|
5
|
+
<meta name=viewport content="width=device-width">
|
|
6
|
+
<script src="../../../u2/tests/test-init.js" type=module async></script>
|
|
7
|
+
<script src="../../../u2/auto.js" type=module async></script>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<link rel=stylesheet href="../../../css/classless/full.css">
|
|
11
|
+
<link rel=stylesheet href="../../../css/classless/simple.css">
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<script src="../bytes.js" type=module async></script>
|
|
15
|
+
<link href="../bytes.css" rel=stylesheet>
|
|
16
|
+
|
|
17
|
+
<body>
|
|
18
|
+
|
|
19
|
+
<section>
|
|
20
|
+
|
|
21
|
+
<figure style="padding:1rem; background:var(--color-light); font-size:1.5rem">
|
|
22
|
+
|
|
23
|
+
<table id="table"></table>
|
|
24
|
+
<script>
|
|
25
|
+
for (const lang of ['de', 'de-CH', 'fr', 'en', 'ru', 'jp']) {
|
|
26
|
+
table.insertAdjacentHTML('beforeend',
|
|
27
|
+
`<tr lang=${lang}>
|
|
28
|
+
<td> ${lang}
|
|
29
|
+
<td> <u2-bytes value="1" lang=${lang}></u2-bytes>
|
|
30
|
+
<td> <u2-bytes value="89277" lang=${lang}></u2-bytes>
|
|
31
|
+
<td> <u2-bytes value="-89277" lang=${lang}></u2-bytes>
|
|
32
|
+
<td> <u2-bytes value="11277987" lang=${lang}></u2-bytes>
|
|
33
|
+
<td> <u2-bytes value="4565277987987" lang=${lang}></u2-bytes>
|
|
34
|
+
`);
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
Speicher: <u2-bytes id=testSet>42847597</u2-bytes>
|
|
39
|
+
</figure>
|
|
40
|
+
|
|
41
|
+
<script type=module>
|
|
42
|
+
attrForm.oninput = function({target}) {
|
|
43
|
+
for (let [key, value] of new FormData(attrForm)) {
|
|
44
|
+
if (key === 'inner') {
|
|
45
|
+
testSet.innerHTML = value;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (value.trim() === '') {
|
|
49
|
+
testSet.removeAttribute(key);
|
|
50
|
+
} else {
|
|
51
|
+
testSet.setAttribute(key, value.trim());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<div class="u2-table -Fields -Flex">
|
|
58
|
+
<strong>
|
|
59
|
+
<span>
|
|
60
|
+
<span>Attribute</span>
|
|
61
|
+
<span>Value</span>
|
|
62
|
+
</span>
|
|
63
|
+
</strong>
|
|
64
|
+
<form id=attrForm>
|
|
65
|
+
<label>
|
|
66
|
+
<span>value</span>
|
|
67
|
+
<input name=value>
|
|
68
|
+
</label>
|
|
69
|
+
<label>
|
|
70
|
+
<div>
|
|
71
|
+
innerHTML* <br>
|
|
72
|
+
</div>
|
|
73
|
+
<input name=inner value="42847597">
|
|
74
|
+
</label>
|
|
75
|
+
<label>
|
|
76
|
+
<span>lang</span>
|
|
77
|
+
<select name=lang>
|
|
78
|
+
<option value="">
|
|
79
|
+
<option>de
|
|
80
|
+
<option>en
|
|
81
|
+
<option>es
|
|
82
|
+
<option>it
|
|
83
|
+
<option>fr
|
|
84
|
+
</select>
|
|
85
|
+
</label>
|
|
86
|
+
<label>
|
|
87
|
+
<span>digits</span>
|
|
88
|
+
<select name=digits>
|
|
89
|
+
<option>
|
|
90
|
+
<option>0
|
|
91
|
+
<option>1
|
|
92
|
+
<option>2
|
|
93
|
+
<option>3
|
|
94
|
+
<option>4
|
|
95
|
+
<option>5
|
|
96
|
+
<option>6
|
|
97
|
+
</select>
|
|
98
|
+
</label>
|
|
99
|
+
</form>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<br><br>
|
|
103
|
+
|
|
104
|
+
<small>* innerHTML is evaluated as value if value-attribute is not present, else its simply a fallback for when no javascript is available</small>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
<style>
|
|
108
|
+
label {
|
|
109
|
+
display:block;
|
|
110
|
+
gap:1rem;
|
|
111
|
+
}
|
|
112
|
+
u2-bytes {
|
|
113
|
+
font-size:2em;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
116
|
+
</section>
|
|
117
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# <u2-carousel> - element
|
|
2
|
+
Simple carousel component
|
|
3
|
+
|
|
4
|
+
## Features
|
|
5
|
+
|
|
6
|
+
- css only fallback
|
|
7
|
+
- no unnecessary css, style it yourself!
|
|
8
|
+
- keyboard navigation
|
|
9
|
+
- play / stop
|
|
10
|
+
- stops playing if focus is inside
|
|
11
|
+
- slide on focus (eg. inputs inside)
|
|
12
|
+
- 3 Modes (slide, scroll, fade)
|
|
13
|
+
- light-weight
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<u2-carousel autoplay controls>
|
|
19
|
+
<div>Carousel<br>Demo<br>Item 1</div>
|
|
20
|
+
<div>Item 2</div>
|
|
21
|
+
</u2-carousel>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```css
|
|
25
|
+
u2-carousel {
|
|
26
|
+
background:var(--color-light);
|
|
27
|
+
}
|
|
28
|
+
u2-carousel > :not([slot]) {
|
|
29
|
+
padding:3rem;
|
|
30
|
+
text-align:center;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<link href="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/carousel/carousel.min.css" rel=stylesheet>
|
|
38
|
+
<script src="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/carousel/carousel.min.js" type=module async></script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Demos
|
|
42
|
+
|
|
43
|
+
[experiments.html](http://gcdn.li/u2ui/u2@main/el/carousel/tests/experiments.html)
|
|
44
|
+
[minimal.html](http://gcdn.li/u2ui/u2@main/el/carousel/tests/minimal.html)
|
|
45
|
+
[nested.html](http://gcdn.li/u2ui/u2@main/el/carousel/tests/nested.html)
|
|
46
|
+
[test.html](http://gcdn.li/u2ui/u2@main/el/carousel/tests/test.html)
|
|
47
|
+
|
|
48
|
+
## About
|
|
49
|
+
|
|
50
|
+
- MIT License, Copyright (c) 2022 <u2> (like all repositories in this organization) <br>
|
|
51
|
+
- Suggestions, ideas, finding bugs and making pull requests make us very happy. ♥
|
|
52
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* slideshow
|
|
2
|
+
inspiration: https://codepen.io/argyleink/pen/yLovWjz?editors=1100
|
|
3
|
+
*/
|
|
4
|
+
u2-carousel {
|
|
5
|
+
/* custom
|
|
6
|
+
--u2-carousel-slideshow-speed:6s;
|
|
7
|
+
--u2-carousel-animation-speed:1s;
|
|
8
|
+
*/
|
|
9
|
+
display:flex;
|
|
10
|
+
overflow:auto;
|
|
11
|
+
scroll-snap-type: x mandatory;
|
|
12
|
+
/* if its a list */
|
|
13
|
+
list-style:none;
|
|
14
|
+
margin:0;
|
|
15
|
+
padding:0; /* todo?: !important, always set padding on children */
|
|
16
|
+
/* align-items:center or stretch; todo default? */
|
|
17
|
+
}
|
|
18
|
+
u2-carousel > :not([slot]) {
|
|
19
|
+
inline-size:100%;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
/* width:-moz-available; to be able to use margins, not working properly
|
|
22
|
+
width:-webkit-fill-available; */
|
|
23
|
+
|
|
24
|
+
flex-shrink:0;
|
|
25
|
+
scroll-snap-align: center;
|
|
26
|
+
/* ok? */
|
|
27
|
+
/* height:100%; /* vertical mode (needs height and flex-direction:column set on the slideshow) */
|
|
28
|
+
/* todo? especially for images
|
|
29
|
+
display:flex;
|
|
30
|
+
align-items:center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
object-fit: cover;
|
|
33
|
+
*/
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
todo: until js is loaded
|
|
38
|
+
u2-carousel > [slot] {
|
|
39
|
+
display:none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* needed if padding
|
|
43
|
+
u2-carousel > img:not([xyz]) { /* just make it stronger
|
|
44
|
+
padding:0;
|
|
45
|
+
}
|
|
46
|
+
*/
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
// todo add privet fields
|
|
2
|
+
/* element */
|
|
3
|
+
class u2Carousel extends HTMLElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
let shadowRoot = this.attachShadow({mode:'open'});
|
|
8
|
+
const svg = '<svg viewBox="0 0 9 18" width="9" height="18"><path d="M1 1l7 8-7 8"/></svg>';
|
|
9
|
+
|
|
10
|
+
shadowRoot.innerHTML = `
|
|
11
|
+
<style>
|
|
12
|
+
:host {
|
|
13
|
+
position:relative;
|
|
14
|
+
contain: layout;
|
|
15
|
+
}
|
|
16
|
+
:host .-arrow {
|
|
17
|
+
position:absolute;
|
|
18
|
+
padding:1rem;
|
|
19
|
+
inset-block:0;
|
|
20
|
+
display:flex;
|
|
21
|
+
cursor:pointer;
|
|
22
|
+
border:0;
|
|
23
|
+
background:none;
|
|
24
|
+
user-select:none;
|
|
25
|
+
width:auto;
|
|
26
|
+
z-index:1;
|
|
27
|
+
align-items:center;
|
|
28
|
+
flex:0 0 auto; /* grow if controls are static */
|
|
29
|
+
stroke-linejoin:round;
|
|
30
|
+
stroke-linecap:round;
|
|
31
|
+
stroke-width:.1rem;
|
|
32
|
+
box-sizing:content-box;
|
|
33
|
+
contain:layout;
|
|
34
|
+
}
|
|
35
|
+
:host .-prev { inset-inline-start: 0; }
|
|
36
|
+
:host .-next { inset-inline-end: 0; }
|
|
37
|
+
|
|
38
|
+
:host > .-arrow svg {
|
|
39
|
+
fill:none;
|
|
40
|
+
flex:1 1 auto;
|
|
41
|
+
height: auto;
|
|
42
|
+
stroke:currentColor;
|
|
43
|
+
max-height:100%;
|
|
44
|
+
}
|
|
45
|
+
:host > .-prev svg {
|
|
46
|
+
transform:rotate(180deg);
|
|
47
|
+
}
|
|
48
|
+
:host([item-count="0"]) > .-arrow, :host([item-count="1"]) > .-arrow {
|
|
49
|
+
display:none;
|
|
50
|
+
}
|
|
51
|
+
:host > slot.body {
|
|
52
|
+
flex:1 1 auto; /* grow if controls are static */
|
|
53
|
+
z-index: 0;
|
|
54
|
+
}
|
|
55
|
+
::slotted([name=prev]) {
|
|
56
|
+
display:block;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* slide */
|
|
60
|
+
:host([mode=slide]) {
|
|
61
|
+
/*
|
|
62
|
+
todo: important is too strong! what can i do to make just overwrite the css
|
|
63
|
+
clip: prevent focus-scroll
|
|
64
|
+
*/
|
|
65
|
+
overflow:hidden !important;
|
|
66
|
+
overflow:clip !important;
|
|
67
|
+
}
|
|
68
|
+
:host([mode=slide]) > slot.body {
|
|
69
|
+
width:100%; /* needed bud why? */
|
|
70
|
+
display:flex;
|
|
71
|
+
transition: transform var(--u2-carousel-animation-speed, .7s) ease-out;
|
|
72
|
+
will-change: transform;
|
|
73
|
+
overflow: visible;
|
|
74
|
+
}
|
|
75
|
+
/* scroll */
|
|
76
|
+
:host([mode=scroll]) {
|
|
77
|
+
overflow:visible !important;
|
|
78
|
+
}
|
|
79
|
+
:host([mode=scroll]) > slot.body {
|
|
80
|
+
display:flex;
|
|
81
|
+
overflow:auto !important;
|
|
82
|
+
scroll-snap-type: x mandatory;
|
|
83
|
+
scrollbar-width: none; /* Firefox */
|
|
84
|
+
}
|
|
85
|
+
:host([mode=scroll]) > slot.body::-webkit-scrollbar {
|
|
86
|
+
display: none; /* Safari and Chrome */
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* fade */
|
|
90
|
+
:host([mode=fade]) {
|
|
91
|
+
display:flex !important;
|
|
92
|
+
z-index:0;
|
|
93
|
+
overflow: visible !important;
|
|
94
|
+
}
|
|
95
|
+
:host([mode=fade]) .body {
|
|
96
|
+
display:flex;
|
|
97
|
+
}
|
|
98
|
+
:host([mode=fade]) .body::slotted(*) {
|
|
99
|
+
transition:opacity var(--u2-carousel-animation-speed, .7s) ease-in-out;
|
|
100
|
+
will-change: opacity;
|
|
101
|
+
opacity:0;
|
|
102
|
+
margin-left:-100% !important;
|
|
103
|
+
}
|
|
104
|
+
:host([mode=fade]) .body::slotted(:first-child) {
|
|
105
|
+
margin-left:0 !important;
|
|
106
|
+
}
|
|
107
|
+
:host([mode=fade]) .body::slotted([aria-hidden=false]) {
|
|
108
|
+
opacity:1;
|
|
109
|
+
z-index:1;
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
112
|
+
<button part="control prev" class="-arrow -prev" aria-label="previous slide">
|
|
113
|
+
<slot name=prev aria-hidden=true>${svg}</slot>
|
|
114
|
+
</button>
|
|
115
|
+
<slot class=body tabindex=-1></slot>
|
|
116
|
+
<button part="control next" class="-arrow -next" aria-label="next slide">
|
|
117
|
+
<slot name=next aria-hidden=true>${svg}</slot>
|
|
118
|
+
</button>
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
setTimeout(()=>{ !this.active && this.next(); }); // this way i can add eventlistener that reacts to the change
|
|
122
|
+
this._nextDelayed = this._nextDelayed.bind(this);
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
this.slider = this.shadowRoot.querySelector('slot.body');
|
|
126
|
+
|
|
127
|
+
this.mode = this.getAttribute('mode');
|
|
128
|
+
|
|
129
|
+
const prev = this.shadowRoot.querySelector('.-prev');
|
|
130
|
+
const next = this.shadowRoot.querySelector('.-next');
|
|
131
|
+
next.addEventListener('click',()=>this.next());
|
|
132
|
+
prev.addEventListener('click',()=>this.prev());
|
|
133
|
+
|
|
134
|
+
// this.addEventListener('beforematch', e=>{ // todo: findable
|
|
135
|
+
// let el = e.target;
|
|
136
|
+
// while (el && el.parentNode) {
|
|
137
|
+
// if (el.parentNode === this) {
|
|
138
|
+
// e.preventDefault();
|
|
139
|
+
// this.slideTo(el);
|
|
140
|
+
// return;
|
|
141
|
+
// }
|
|
142
|
+
// el = el.parentElement;
|
|
143
|
+
// }
|
|
144
|
+
// })
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
static observedAttributes = ['play', 'autoplay', 'mode'/*, 'tabindex'*/]; // zzz "play"
|
|
149
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
150
|
+
if (oldValue === newValue) return;
|
|
151
|
+
if (name === 'play') { console.warn('play is deprecated, use autoplay'); let play = this.hasAttribute('play'); this[play?'play':'stop'](); } // zzz
|
|
152
|
+
if (name === 'autoplay') this[newValue===null?'stop':'play']();
|
|
153
|
+
if (name === 'mode') this.mode = newValue;
|
|
154
|
+
}
|
|
155
|
+
set mode(mode){
|
|
156
|
+
if (!u2Carousel.mode[mode]) mode = 'slide';
|
|
157
|
+
this.setAttribute('mode', mode);
|
|
158
|
+
this.handler = u2Carousel.mode[mode];
|
|
159
|
+
this.handler.init && this.handler.init.call(this);
|
|
160
|
+
}
|
|
161
|
+
get mode(){
|
|
162
|
+
return this.getAttribute('mode');
|
|
163
|
+
}
|
|
164
|
+
_items(){
|
|
165
|
+
return this.slider.assignedElements({flatten:true});
|
|
166
|
+
}
|
|
167
|
+
activeIndex(){
|
|
168
|
+
return Array.prototype.indexOf.call(this._items(), this.active);
|
|
169
|
+
}
|
|
170
|
+
slideTo(target){
|
|
171
|
+
if (typeof target === 'number') target = this._items()[target]; // by index
|
|
172
|
+
|
|
173
|
+
if (Array.from(this._items()).indexOf(target) === -1) console.error('target not a child of this slider!')
|
|
174
|
+
|
|
175
|
+
if (this.active !== target) { // just trigger if not active
|
|
176
|
+
for (let child of this._items()) {
|
|
177
|
+
child.setAttribute('aria-hidden', target !== child);
|
|
178
|
+
// target !== child ? child.setAttribute('hidden', 'until-found') : child.removeAttribute('hidden'); // todo: findable
|
|
179
|
+
}
|
|
180
|
+
this.active = target;
|
|
181
|
+
|
|
182
|
+
target.dispatchEvent(new CustomEvent('u2-carousel.slide',{
|
|
183
|
+
bubbles:true,
|
|
184
|
+
detail:{
|
|
185
|
+
slide:target,
|
|
186
|
+
index:Array.prototype.indexOf.call(this._items(), target),
|
|
187
|
+
slider:this,
|
|
188
|
+
}
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
this.handler.slideTo && this.handler.slideTo.call(this, target); // needed if not active?
|
|
192
|
+
}
|
|
193
|
+
next(){ this.slideTo(this._sibling('next')); }
|
|
194
|
+
prev(){ this.slideTo(this._sibling('prev')); }
|
|
195
|
+
|
|
196
|
+
_sibling(direction){
|
|
197
|
+
const items = this._items();
|
|
198
|
+
let sibling = this.active || items.at(-1);
|
|
199
|
+
const index = this.activeIndex();
|
|
200
|
+
if (!sibling) return; // no slide
|
|
201
|
+
while (1) {
|
|
202
|
+
sibling = direction === 'prev'
|
|
203
|
+
? items[index-1] || items.at(-1)
|
|
204
|
+
: items[index+1] || items.at(0);
|
|
205
|
+
break; // also hidden
|
|
206
|
+
// if (sibling.offsetParent) break; // next visible // can cause infinite loops!!
|
|
207
|
+
if (sibling === this.active) break; // only one
|
|
208
|
+
}
|
|
209
|
+
return sibling;
|
|
210
|
+
}
|
|
211
|
+
play(){
|
|
212
|
+
this.addEventListener('u2-carousel.slide', this._nextDelayed);
|
|
213
|
+
this._nextDelayed();
|
|
214
|
+
}
|
|
215
|
+
stop(){
|
|
216
|
+
this.removeEventListener('u2-carousel.slide', this._nextDelayed)
|
|
217
|
+
clearTimeout(this._nextDelayedTimeout);
|
|
218
|
+
}
|
|
219
|
+
_nextDelayed(){
|
|
220
|
+
clearTimeout(this._nextDelayedTimeout);
|
|
221
|
+
|
|
222
|
+
let speed = this.customProperty('slideshow-speed');
|
|
223
|
+
if (speed==='') speed = '6000';
|
|
224
|
+
const unit = speed.match(/[^0-9]*$/)[0];
|
|
225
|
+
speed = parseFloat(speed);
|
|
226
|
+
if (unit === 's') speed *= 1000;
|
|
227
|
+
|
|
228
|
+
this._nextDelayedTimeout = setTimeout(()=>{
|
|
229
|
+
if (this.contains(document.activeElement)) return;
|
|
230
|
+
this.next();
|
|
231
|
+
},speed);
|
|
232
|
+
}
|
|
233
|
+
customProperty(property){
|
|
234
|
+
return getComputedStyle(this).getPropertyValue('--u2-carousel-'+property);
|
|
235
|
+
}
|
|
236
|
+
connectedCallback() {
|
|
237
|
+
this.hasAttribute('play') && this.play();
|
|
238
|
+
this.setAttribute('item-count', this._items().length); // todo, dynamic react on dynamic added slides, mutation observer?
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
u2Carousel.mode = {};
|
|
244
|
+
|
|
245
|
+
// scroll
|
|
246
|
+
u2Carousel.mode.scroll = {
|
|
247
|
+
slideTo:function(target){
|
|
248
|
+
let left = target.offsetLeft - this.slider.offsetLeft;
|
|
249
|
+
this.slider.scroll({ // todo: better calculation of offset
|
|
250
|
+
top: target.offsetTop,
|
|
251
|
+
left: left,
|
|
252
|
+
behavior: 'smooth'
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
init:function(){
|
|
256
|
+
this.slider.style.transform = ''; // if changed from mode=slide
|
|
257
|
+
|
|
258
|
+
this.slider.addEventListener('scroll',()=>{ // trigger on manual scroll
|
|
259
|
+
clearTimeout(this.scroll_slideing_timeout);
|
|
260
|
+
this.scroll_slideing_timeout = setTimeout(()=>{
|
|
261
|
+
const rect = this.slider.getBoundingClientRect();
|
|
262
|
+
const targets = document.elementsFromPoint(rect.left + rect.width/2, rect.top + rect.height/2);
|
|
263
|
+
for (let target of targets) {
|
|
264
|
+
if (target.parentElement === this) {
|
|
265
|
+
if (target !== this.active) this.slideTo(target);
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},100)
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// slide
|
|
275
|
+
u2Carousel.mode.slide = {
|
|
276
|
+
init:function(){
|
|
277
|
+
//this.addSwipe();
|
|
278
|
+
},
|
|
279
|
+
slideTo:function(target){
|
|
280
|
+
const sliderStyle = getComputedStyle(this);
|
|
281
|
+
const wMode = sliderStyle.getPropertyValue('writing-mode'); // trigger reflow
|
|
282
|
+
const paddingStart = parseFloat(sliderStyle.getPropertyValue('padding-inline-start'));
|
|
283
|
+
const vertical = wMode.includes('vertical');
|
|
284
|
+
const XY = vertical ? 'Y' : 'X';
|
|
285
|
+
const translate = (vertical ? -target.offsetTop : -target.offsetLeft) + paddingStart;
|
|
286
|
+
this.slider.style.transform = `translate${XY}(${translate}px)`;
|
|
287
|
+
},
|
|
288
|
+
}
|
|
289
|
+
// fade (entirely done by css)
|
|
290
|
+
u2Carousel.mode.fade = {
|
|
291
|
+
init:function(){
|
|
292
|
+
this.slider.style.transform = ''; // if changed from mode=slide
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
customElements.define('u2-carousel', u2Carousel)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
// slide on target
|
|
301
|
+
function hashchange(){
|
|
302
|
+
if (!location.hash) return;
|
|
303
|
+
const el = document.getElementById(location.hash.substring(1));
|
|
304
|
+
if (!el) return;
|
|
305
|
+
const slide = el.closest('u2-carousel > *');
|
|
306
|
+
if (!slide) return;
|
|
307
|
+
const sliderEl = slide.parentElement;
|
|
308
|
+
sliderEl.slideTo(slide);
|
|
309
|
+
}
|
|
310
|
+
addEventListener('DOMContentLoaded', hashchange);
|
|
311
|
+
addEventListener('hashchange', hashchange);
|
|
312
|
+
// slide on focus
|
|
313
|
+
addEventListener('focusin', e=>{
|
|
314
|
+
const el = document.activeElement;
|
|
315
|
+
const slide = el.closest('u2-carousel > *');
|
|
316
|
+
if (!slide) return;
|
|
317
|
+
const sliderEl = slide.parentElement;
|
|
318
|
+
sliderEl.slideTo(slide);
|
|
319
|
+
});
|
|
320
|
+
// keyboard nav
|
|
321
|
+
addEventListener('keydown', ({target,code})=>{
|
|
322
|
+
if (target.tagName !== 'U2-CAROUSEL') return;
|
|
323
|
+
if (code === 'ArrowRight') target.next();
|
|
324
|
+
if (code === 'ArrowLeft') target.prev();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
/* sync */
|
|
328
|
+
addEventListener('u2-carousel.slide', e=>{
|
|
329
|
+
const group = e.detail.slider.getAttribute('sync');
|
|
330
|
+
group && document.querySelectorAll('u2-carousel[sync="'+group+'"]').forEach( el => el.slideTo(e.detail.index) );
|
|
331
|
+
});
|
|
332
|
+
/* */
|
|
333
|
+
|
|
334
|
+
/*
|
|
335
|
+
u2Carousel.prototype.addSwipe = function(){
|
|
336
|
+
c1.c1Use('pointerObserver',function(){
|
|
337
|
+
const pO = this.pointerObserver = new c1.pointerObserver(this);
|
|
338
|
+
let startX = 0;
|
|
339
|
+
pO.onstart = function(e){
|
|
340
|
+
//e.preventDefault(); // enable drag image, can not select text
|
|
341
|
+
startX = getComputedTranslate(this).x;
|
|
342
|
+
this.style.transform = 'translateX('+startX+'px)';
|
|
343
|
+
this.style.transition = 'none';
|
|
344
|
+
}
|
|
345
|
+
pO.onmove = function(){
|
|
346
|
+
const to = (this.startDiff().x*1) + startX;
|
|
347
|
+
this.style.transform = 'translateX('+to+'px)';
|
|
348
|
+
}
|
|
349
|
+
pO.onstop = function(){
|
|
350
|
+
let x = -getComputedTranslate(this).x;
|
|
351
|
+
const add = this.lastDiff().x * 50;
|
|
352
|
+
add = Math.max(-this.offsetWidth, Math.min(add, this.offsetWidth));
|
|
353
|
+
x -= add;
|
|
354
|
+
let next = Math.round(x / this.offsetWidth);
|
|
355
|
+
next = Math.max(0, Math.min(next, this.children.length-1));
|
|
356
|
+
next = this.children[next];
|
|
357
|
+
if (!next) next = this.active;
|
|
358
|
+
this.style.transition = '';
|
|
359
|
+
this.slideTo(next);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function getComputedTranslate(el) {
|
|
364
|
+
const style = getComputedStyle(el);
|
|
365
|
+
const matrix = new (window.WebKitCSSMatrix || window.MSCSSMatrix)(style.transform);
|
|
366
|
+
return {
|
|
367
|
+
x:matrix.m41,
|
|
368
|
+
y:matrix.m42,
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
*/
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "README.md",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "carousel.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "class",
|
|
11
|
+
"description": "",
|
|
12
|
+
"name": "carousel",
|
|
13
|
+
"members": [
|
|
14
|
+
{
|
|
15
|
+
"kind": "method",
|
|
16
|
+
"name": "slideTo"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"events": [
|
|
20
|
+
{
|
|
21
|
+
"name": "u2-carousel.slide",
|
|
22
|
+
"type": {
|
|
23
|
+
"text": "Event"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"attributes": [
|
|
28
|
+
{
|
|
29
|
+
"name": "autoplay",
|
|
30
|
+
"description": "If specified, the carousel automatically begins to slide.",
|
|
31
|
+
"u2-type": "boolean"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "mode",
|
|
35
|
+
"description": "The mode of the carousel. scroll: uses native scroll, fade: uses css opacity, slide: uses css-transform.",
|
|
36
|
+
"u2-type": ["slide","fade","scroll"]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"superclass": {
|
|
40
|
+
"name": "HTMLElement"
|
|
41
|
+
},
|
|
42
|
+
"tagName": "u2-carousel",
|
|
43
|
+
"customElement": true
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"exports": [
|
|
47
|
+
{
|
|
48
|
+
"kind": "custom-element-definition",
|
|
49
|
+
"name": "u2-carousel",
|
|
50
|
+
"declaration": {
|
|
51
|
+
"name": "MyElement",
|
|
52
|
+
"module": "my-project/my-element.js"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|