@ulu/frontend 0.0.3
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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/ulu-frontend.min.css +1 -0
- package/dist/ulu-frontend.min.js +1 -0
- package/index.js +2 -0
- package/js/deprecated/doc-ready.js +28 -0
- package/js/deprecated/jquery-prototypes.js +309 -0
- package/js/deprecated/mini-collapsible-popper-positioning.js +126 -0
- package/js/deprecated/mini-collapsible.js +607 -0
- package/js/deprecated/script-loader.js +60 -0
- package/js/events/index.js +42 -0
- package/js/helpers/css-breakpoint.js +247 -0
- package/js/helpers/file-save.js +48 -0
- package/js/helpers/node-data-manager.js +74 -0
- package/js/helpers/pause-youtube-video.js +42 -0
- package/js/helpers/scrollbar-width-property.js +10 -0
- package/js/index.js +15 -0
- package/js/polyfills/element-closest.js +17 -0
- package/js/ui/flipcard.js +202 -0
- package/js/ui/grid.js +67 -0
- package/js/ui/modals.js +219 -0
- package/js/ui/overflow-scroller-pager.js +58 -0
- package/js/ui/overflow-scroller.js +160 -0
- package/js/ui/programmatic-modal.js +91 -0
- package/js/ui/resizer.js +60 -0
- package/js/ui/slider.js +468 -0
- package/js/ui/tabs.js +109 -0
- package/js/ui/tooltip.js +82 -0
- package/js/utils/array.js +28 -0
- package/js/utils/dom.js +122 -0
- package/js/utils/logger.js +69 -0
- package/js/utils/object.js +22 -0
- package/js/utils/performance.js +43 -0
- package/js/utils/regex.js +10 -0
- package/js/utils/string.js +107 -0
- package/js/waypoints/README.md +3 -0
- package/js/waypoints/anchor-menu.js +76 -0
- package/js/waypoints/element-waypoint.js +75 -0
- package/js/waypoints/examples/page-link-menu.md +106 -0
- package/js/waypoints/state-in-attribute.js +32 -0
- package/package.json +38 -0
- package/scss/README.md +58 -0
- package/scss/_breakpoint.scss +190 -0
- package/scss/_button.scss +241 -0
- package/scss/_calculate.scss +64 -0
- package/scss/_color.scss +211 -0
- package/scss/_cssvar.scss +116 -0
- package/scss/_element.scss +276 -0
- package/scss/_grid.scss +699 -0
- package/scss/_index.scss +29 -0
- package/scss/_layout.scss +202 -0
- package/scss/_path.scss +58 -0
- package/scss/_selector.scss +81 -0
- package/scss/_typography.scss +320 -0
- package/scss/_units.scss +47 -0
- package/scss/_utility.scss +12 -0
- package/scss/_utils.scss +209 -0
- package/scss/base/_color.scss +13 -0
- package/scss/base/_elements.scss +188 -0
- package/scss/base/_index.scss +62 -0
- package/scss/base/_keyframes.scss +78 -0
- package/scss/base/_layout.scss +100 -0
- package/scss/base/_normalize.scss +315 -0
- package/scss/base/_typography.scss +41 -0
- package/scss/components/README.md +5 -0
- package/scss/components/README.todos +15 -0
- package/scss/components/_button.scss +95 -0
- package/scss/components/_index.scss +63 -0
- package/scss/components/_links.scss +34 -0
- package/scss/components/_list-lines.scss +73 -0
- package/scss/components/_list-ordered.scss +16 -0
- package/scss/components/_list-unordered.scss +21 -0
- package/scss/components/_rule.scss +93 -0
- package/scss/helpers/_color.scss +14 -0
- package/scss/helpers/_display.scss +73 -0
- package/scss/helpers/_index.scss +67 -0
- package/scss/helpers/_print.scss +58 -0
- package/scss/helpers/_typography.scss +80 -0
- package/scss/helpers/_units.scss +79 -0
- package/scss/helpers/_utilities.scss +102 -0
- package/scss/stylesheets/README.md +3 -0
- package/scss/stylesheets/full.scss +17 -0
- package/trash/js-old/deprecated/doc-ready.js +28 -0
- package/trash/js-old/deprecated/jquery-prototypes.js +309 -0
- package/trash/js-old/deprecated/mini-collapsible-popper-positioning.js +126 -0
- package/trash/js-old/deprecated/mini-collapsible.js +607 -0
- package/trash/js-old/deprecated/script-loader.js +60 -0
- package/trash/js-old/events/index.js +42 -0
- package/trash/js-old/helpers/css-breakpoint.js +247 -0
- package/trash/js-old/helpers/file-save.js +48 -0
- package/trash/js-old/helpers/node-data-manager.js +74 -0
- package/trash/js-old/helpers/pause-youtube-video.js +42 -0
- package/trash/js-old/index.js +15 -0
- package/trash/js-old/polyfills/element-closest.js +17 -0
- package/trash/js-old/ui/flipcard.js +202 -0
- package/trash/js-old/ui/grid.js +67 -0
- package/trash/js-old/ui/modals.js +219 -0
- package/trash/js-old/ui/programmatic-modal.js +91 -0
- package/trash/js-old/ui/resizer.js +60 -0
- package/trash/js-old/ui/slider.js +469 -0
- package/trash/js-old/ui/tabs.js +109 -0
- package/trash/js-old/ui/tooltip.js +82 -0
- package/trash/js-old/utils/array.js +28 -0
- package/trash/js-old/utils/dom.js +122 -0
- package/trash/js-old/utils/logger.js +69 -0
- package/trash/js-old/utils/object.js +22 -0
- package/trash/js-old/utils/performance.js +43 -0
- package/trash/js-old/utils/regex.js +10 -0
- package/trash/js-old/utils/string.js +107 -0
- package/trash/js-old/waypoints/README.md +3 -0
- package/trash/js-old/waypoints/anchor-menu.js +76 -0
- package/trash/js-old/waypoints/element-waypoint.js +75 -0
- package/trash/js-old/waypoints/examples/page-link-menu.md +106 -0
- package/trash/js-old/waypoints/state-in-attribute.js +32 -0
- package/trash/js-old-230729/deprecated/doc-ready.js +28 -0
- package/trash/js-old-230729/deprecated/jquery-prototypes.js +309 -0
- package/trash/js-old-230729/deprecated/mini-collapsible-popper-positioning.js +126 -0
- package/trash/js-old-230729/deprecated/mini-collapsible.js +607 -0
- package/trash/js-old-230729/deprecated/script-loader.js +60 -0
- package/trash/js-old-230729/events/index.js +42 -0
- package/trash/js-old-230729/helpers/css-breakpoint.js +247 -0
- package/trash/js-old-230729/helpers/file-save.js +48 -0
- package/trash/js-old-230729/helpers/node-data-manager.js +74 -0
- package/trash/js-old-230729/helpers/pause-youtube-video.js +42 -0
- package/trash/js-old-230729/helpers/scrollbar-width-property.js +10 -0
- package/trash/js-old-230729/index.js +15 -0
- package/trash/js-old-230729/polyfills/element-closest.js +17 -0
- package/trash/js-old-230729/ui/flipcard.js +202 -0
- package/trash/js-old-230729/ui/grid.js +67 -0
- package/trash/js-old-230729/ui/modals.js +219 -0
- package/trash/js-old-230729/ui/overflow-scroller-pager.js +58 -0
- package/trash/js-old-230729/ui/overflow-scroller.js +160 -0
- package/trash/js-old-230729/ui/programmatic-modal.js +91 -0
- package/trash/js-old-230729/ui/resizer.js +60 -0
- package/trash/js-old-230729/ui/slider.js +468 -0
- package/trash/js-old-230729/ui/tabs.js +109 -0
- package/trash/js-old-230729/ui/tooltip.js +82 -0
- package/trash/js-old-230729/utils/array.js +28 -0
- package/trash/js-old-230729/utils/dom.js +122 -0
- package/trash/js-old-230729/utils/logger.js +69 -0
- package/trash/js-old-230729/utils/object.js +22 -0
- package/trash/js-old-230729/utils/performance.js +43 -0
- package/trash/js-old-230729/utils/regex.js +10 -0
- package/trash/js-old-230729/utils/string.js +107 -0
- package/trash/js-old-230729/waypoints/README.md +3 -0
- package/trash/js-old-230729/waypoints/anchor-menu.js +76 -0
- package/trash/js-old-230729/waypoints/element-waypoint.js +75 -0
- package/trash/js-old-230729/waypoints/examples/page-link-menu.md +106 -0
- package/trash/js-old-230729/waypoints/state-in-attribute.js +32 -0
- package/trash/logo-1.svg +13 -0
- package/trash/logo.svg +16 -0
- package/trash/scss-before-cqc-update/README.md +58 -0
- package/trash/scss-before-cqc-update/_breakpoint.scss +190 -0
- package/trash/scss-before-cqc-update/_button.scss +229 -0
- package/trash/scss-before-cqc-update/_calculate.scss +65 -0
- package/trash/scss-before-cqc-update/_color.scss +211 -0
- package/trash/scss-before-cqc-update/_cssvar.scss +116 -0
- package/trash/scss-before-cqc-update/_element.scss +275 -0
- package/trash/scss-before-cqc-update/_index.scss +29 -0
- package/trash/scss-before-cqc-update/_layout.scss +247 -0
- package/trash/scss-before-cqc-update/_path.scss +59 -0
- package/trash/scss-before-cqc-update/_selector.scss +82 -0
- package/trash/scss-before-cqc-update/_typography.scss +322 -0
- package/trash/scss-before-cqc-update/_units.scss +48 -0
- package/trash/scss-before-cqc-update/_utility.scss +13 -0
- package/trash/scss-before-cqc-update/_utils.scss +211 -0
- package/trash/scss-before-cqc-update/base/_color.scss +14 -0
- package/trash/scss-before-cqc-update/base/_elements.scss +189 -0
- package/trash/scss-before-cqc-update/base/_index.scss +63 -0
- package/trash/scss-before-cqc-update/base/_keyframes.scss +74 -0
- package/trash/scss-before-cqc-update/base/_layout.scss +88 -0
- package/trash/scss-before-cqc-update/base/_normalize.scss +316 -0
- package/trash/scss-before-cqc-update/base/_typography.scss +42 -0
- package/trash/scss-before-cqc-update/components/README.md +5 -0
- package/trash/scss-before-cqc-update/components/README.todos +15 -0
- package/trash/scss-before-cqc-update/components/_button.scss +96 -0
- package/trash/scss-before-cqc-update/components/_grid.scss +671 -0
- package/trash/scss-before-cqc-update/components/_index.scss +70 -0
- package/trash/scss-before-cqc-update/components/_links.scss +35 -0
- package/trash/scss-before-cqc-update/components/_list-lines.scss +74 -0
- package/trash/scss-before-cqc-update/components/_list-ordered.scss +17 -0
- package/trash/scss-before-cqc-update/components/_list-unordered.scss +22 -0
- package/trash/scss-before-cqc-update/components/_rule.scss +94 -0
- package/trash/scss-before-cqc-update/helpers/_color.scss +15 -0
- package/trash/scss-before-cqc-update/helpers/_display.scss +73 -0
- package/trash/scss-before-cqc-update/helpers/_index.scss +68 -0
- package/trash/scss-before-cqc-update/helpers/_print.scss +59 -0
- package/trash/scss-before-cqc-update/helpers/_typography.scss +73 -0
- package/trash/scss-before-cqc-update/helpers/_units.scss +79 -0
- package/trash/scss-before-cqc-update/helpers/_utilities.scss +88 -0
- package/trash/scss-before-cqc-update/stylesheets/README.md +3 -0
- package/trash/scss-before-cqc-update/stylesheets/full.scss +17 -0
- package/trash/scss-old/README.md +58 -0
- package/trash/scss-old/_breakpoint.scss +140 -0
- package/trash/scss-old/_button.scss +223 -0
- package/trash/scss-old/_calculate.scss +64 -0
- package/trash/scss-old/_color.scss +200 -0
- package/trash/scss-old/_element.scss +262 -0
- package/trash/scss-old/_grid.scss +558 -0
- package/trash/scss-old/_index.scss +25 -0
- package/trash/scss-old/_layout.scss +170 -0
- package/trash/scss-old/_path.scss +58 -0
- package/trash/scss-old/_selector.scss +81 -0
- package/trash/scss-old/_typography.scss +320 -0
- package/trash/scss-old/_units.scss +47 -0
- package/trash/scss-old/_utility.scss +12 -0
- package/trash/scss-old/_utils.scss +186 -0
- package/trash/scss-old/base/_color.scss +13 -0
- package/trash/scss-old/base/_elements.scss +183 -0
- package/trash/scss-old/base/_index.scss +62 -0
- package/trash/scss-old/base/_keyframes.scss +74 -0
- package/trash/scss-old/base/_layout.scss +81 -0
- package/trash/scss-old/base/_normalize.scss +316 -0
- package/trash/scss-old/base/_typography.scss +42 -0
- package/trash/scss-old/components/README.md +5 -0
- package/trash/scss-old/components/README.todos +15 -0
- package/trash/scss-old/components/_button.scss +74 -0
- package/trash/scss-old/components/_index.scss +63 -0
- package/trash/scss-old/components/_links.scss +34 -0
- package/trash/scss-old/components/_list-lines.scss +73 -0
- package/trash/scss-old/components/_list-ordered.scss +16 -0
- package/trash/scss-old/components/_list-unordered.scss +21 -0
- package/trash/scss-old/components/_rule.scss +84 -0
- package/trash/scss-old/helpers/_color.scss +14 -0
- package/trash/scss-old/helpers/_display.scss +68 -0
- package/trash/scss-old/helpers/_index.scss +67 -0
- package/trash/scss-old/helpers/_print.scss +59 -0
- package/trash/scss-old/helpers/_typography.scss +73 -0
- package/trash/scss-old/helpers/_units.scss +68 -0
- package/trash/scss-old/helpers/_utilities.scss +82 -0
- package/trash/scss-old/packages/README.md +3 -0
- package/trash/scss-old/packages/everything.scss +17 -0
- package/trash/scss-old-2/README.md +58 -0
- package/trash/scss-old-2/_breakpoint.scss +139 -0
- package/trash/scss-old-2/_button.scss +223 -0
- package/trash/scss-old-2/_calculate.scss +64 -0
- package/trash/scss-old-2/_color.scss +202 -0
- package/trash/scss-old-2/_element.scss +263 -0
- package/trash/scss-old-2/_grid.scss +558 -0
- package/trash/scss-old-2/_index.scss +25 -0
- package/trash/scss-old-2/_layout.scss +170 -0
- package/trash/scss-old-2/_path.scss +58 -0
- package/trash/scss-old-2/_selector.scss +81 -0
- package/trash/scss-old-2/_typography.scss +320 -0
- package/trash/scss-old-2/_units.scss +47 -0
- package/trash/scss-old-2/_utility.scss +12 -0
- package/trash/scss-old-2/_utils.scss +186 -0
- package/trash/scss-old-2/base/_color.scss +13 -0
- package/trash/scss-old-2/base/_elements.scss +182 -0
- package/trash/scss-old-2/base/_index.scss +62 -0
- package/trash/scss-old-2/base/_keyframes.scss +73 -0
- package/trash/scss-old-2/base/_layout.scss +83 -0
- package/trash/scss-old-2/base/_normalize.scss +315 -0
- package/trash/scss-old-2/base/_typography.scss +41 -0
- package/trash/scss-old-2/components/README.md +5 -0
- package/trash/scss-old-2/components/README.todos +15 -0
- package/trash/scss-old-2/components/_button.scss +95 -0
- package/trash/scss-old-2/components/_index.scss +63 -0
- package/trash/scss-old-2/components/_links.scss +33 -0
- package/trash/scss-old-2/components/_list-lines.scss +73 -0
- package/trash/scss-old-2/components/_list-ordered.scss +16 -0
- package/trash/scss-old-2/components/_list-unordered.scss +21 -0
- package/trash/scss-old-2/components/_rule.scss +84 -0
- package/trash/scss-old-2/helpers/_color.scss +14 -0
- package/trash/scss-old-2/helpers/_display.scss +67 -0
- package/trash/scss-old-2/helpers/_index.scss +67 -0
- package/trash/scss-old-2/helpers/_print.scss +58 -0
- package/trash/scss-old-2/helpers/_typography.scss +72 -0
- package/trash/scss-old-2/helpers/_units.scss +68 -0
- package/trash/scss-old-2/helpers/_utilities.scss +81 -0
- package/trash/scss-old-2/packages/README.md +3 -0
- package/trash/scss-old-2/packages/everything.scss +17 -0
- package/trash/scss-old-230729/README.md +58 -0
- package/trash/scss-old-230729/_breakpoint.scss +139 -0
- package/trash/scss-old-230729/_button.scss +223 -0
- package/trash/scss-old-230729/_calculate.scss +64 -0
- package/trash/scss-old-230729/_color.scss +202 -0
- package/trash/scss-old-230729/_element.scss +273 -0
- package/trash/scss-old-230729/_grid.scss +694 -0
- package/trash/scss-old-230729/_index.scss +25 -0
- package/trash/scss-old-230729/_layout.scss +193 -0
- package/trash/scss-old-230729/_path.scss +58 -0
- package/trash/scss-old-230729/_selector.scss +81 -0
- package/trash/scss-old-230729/_typography.scss +320 -0
- package/trash/scss-old-230729/_units.scss +47 -0
- package/trash/scss-old-230729/_utility.scss +12 -0
- package/trash/scss-old-230729/_utils.scss +186 -0
- package/trash/scss-old-230729/base/_color.scss +13 -0
- package/trash/scss-old-230729/base/_elements.scss +188 -0
- package/trash/scss-old-230729/base/_index.scss +62 -0
- package/trash/scss-old-230729/base/_keyframes.scss +73 -0
- package/trash/scss-old-230729/base/_layout.scss +83 -0
- package/trash/scss-old-230729/base/_normalize.scss +315 -0
- package/trash/scss-old-230729/base/_typography.scss +41 -0
- package/trash/scss-old-230729/components/README.md +5 -0
- package/trash/scss-old-230729/components/README.todos +15 -0
- package/trash/scss-old-230729/components/_button.scss +95 -0
- package/trash/scss-old-230729/components/_index.scss +63 -0
- package/trash/scss-old-230729/components/_links.scss +34 -0
- package/trash/scss-old-230729/components/_list-lines.scss +73 -0
- package/trash/scss-old-230729/components/_list-ordered.scss +16 -0
- package/trash/scss-old-230729/components/_list-unordered.scss +21 -0
- package/trash/scss-old-230729/components/_rule.scss +93 -0
- package/trash/scss-old-230729/helpers/_color.scss +14 -0
- package/trash/scss-old-230729/helpers/_display.scss +73 -0
- package/trash/scss-old-230729/helpers/_index.scss +67 -0
- package/trash/scss-old-230729/helpers/_print.scss +58 -0
- package/trash/scss-old-230729/helpers/_typography.scss +72 -0
- package/trash/scss-old-230729/helpers/_units.scss +68 -0
- package/trash/scss-old-230729/helpers/_utilities.scss +87 -0
- package/trash/scss-old-230729/packages/README.md +3 -0
- package/trash/scss-old-230729/packages/everything.scss +17 -0
- package/trash/vue/directives/background-image-url.js +12 -0
- package/trash/vue/helpers/add-required-components.js +14 -0
- package/trash/vue/ui/CollapsibleRegion/CollapsibleRegion.vue +277 -0
- package/trash/vue/ui/CollapsibleRegion/Demo.vue +101 -0
- package/trash/vue/ui/Dropdown/Dropdown.vue +184 -0
- package/trash/vue/ui/Modals/components/Modal.vue +49 -0
- package/trash/vue/ui/Modals/components/Modals.vue +103 -0
- package/trash/vue/ui/Modals/plugin.js +215 -0
- package/trash/vue/ui/Modals/readme.note +10 -0
- package/trash/vue/ui/Modals/reference/example-usage.vue +27 -0
- package/trash/vue/ui/Modals/reference/wcag-example/dialog.js +324 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Flipcard
|
|
3
|
+
// =============================================================================
|
|
4
|
+
|
|
5
|
+
// Version: 1.0.1
|
|
6
|
+
|
|
7
|
+
// Changes 1.0.1 | Added allow selection
|
|
8
|
+
|
|
9
|
+
import { log, logError } from "../utils/logger.js";
|
|
10
|
+
import { trimWhitespace } from "../utils/string.js";
|
|
11
|
+
const debugMode = false; // Global dev debug
|
|
12
|
+
|
|
13
|
+
export class Flipcard {
|
|
14
|
+
static instances = [];
|
|
15
|
+
static defaults = {
|
|
16
|
+
namespace: "Flipcard",
|
|
17
|
+
proxyClick: {
|
|
18
|
+
allowSelection: true, // Don't proxy click if the user has more than the minmimum selected
|
|
19
|
+
selectionMin: 10, // Minimum length that qualifies as a selection
|
|
20
|
+
exclude: "a, input, textarea, button" // Selectors to avoid closing a flipcard onProxyclick
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
constructor(container, front, back, config, debug = false) {
|
|
24
|
+
if (!container, !front, !back) {
|
|
25
|
+
logError(this, 'Missing an element (container, front, back)');
|
|
26
|
+
}
|
|
27
|
+
this.options = Object.assign({}, Flipcard.defaults, config);
|
|
28
|
+
const { namespace } = this.options;
|
|
29
|
+
Flipcard.instances.push(this);
|
|
30
|
+
|
|
31
|
+
this.debug = debugMode || debug;
|
|
32
|
+
this.elements = { container, front, back };
|
|
33
|
+
this.isOpen = false;
|
|
34
|
+
this.uid = `${ namespace }-id-${ Flipcard.instances.length }`;
|
|
35
|
+
this.stateAttr = `data-${ namespace }-state`.toLowerCase();
|
|
36
|
+
this.setup();
|
|
37
|
+
this.setVisiblity(false);
|
|
38
|
+
log(this, this);
|
|
39
|
+
}
|
|
40
|
+
toggle() {
|
|
41
|
+
this.setVisiblity(!this.isOpen);
|
|
42
|
+
}
|
|
43
|
+
setup() {
|
|
44
|
+
const { uid } = this;
|
|
45
|
+
const { namespace, proxyClick } = this.options;
|
|
46
|
+
const { container, front, back } = this.elements;
|
|
47
|
+
const control = this.elements.control = document.createElement("button");
|
|
48
|
+
|
|
49
|
+
// Styling and markup
|
|
50
|
+
control.classList.add(this.getClass("control-button"));
|
|
51
|
+
control.setAttribute("type", "button");
|
|
52
|
+
control.innerHTML = this.createControlContent();
|
|
53
|
+
control.style.gridArea = namespace;
|
|
54
|
+
control.style.zIndex = "-1"; // Behind everything only used for focus
|
|
55
|
+
control.addEventListener('focusin', () => {
|
|
56
|
+
control.style.zIndex = "20"; // above the back
|
|
57
|
+
});
|
|
58
|
+
control.addEventListener('focusout', () => {
|
|
59
|
+
control.style.zIndex = "-1"
|
|
60
|
+
});
|
|
61
|
+
control.addEventListener("click", this.toggle.bind(this));
|
|
62
|
+
back.parentNode.insertBefore(control, back);
|
|
63
|
+
|
|
64
|
+
container.classList.add(this.options.namespace);
|
|
65
|
+
container.setAttribute("style", trimWhitespace(this.containerCss()));
|
|
66
|
+
if (proxyClick) {
|
|
67
|
+
container.addEventListener("click", this.onProxyClick.bind(this));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
front.style.gridArea = namespace;
|
|
71
|
+
back.style.gridArea = namespace;
|
|
72
|
+
|
|
73
|
+
// Accessibility
|
|
74
|
+
control.id = `${ uid }-control`;
|
|
75
|
+
control.setAttribute("aria-controls", back.id);
|
|
76
|
+
control.setAttribute("aria-expanded", "false");
|
|
77
|
+
back.id = `${ uid }-back`;
|
|
78
|
+
back.setAttribute('aria-labelledby', control.id)
|
|
79
|
+
back.setAttribute('aria-hidden', "true");
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Click handler on everything on container
|
|
83
|
+
* - Determines if click was something that should be ignored (link, etc)
|
|
84
|
+
*/
|
|
85
|
+
onProxyClick({ target }) {
|
|
86
|
+
const { exclude, allowSelection, selectionMin } = this.options.proxyClick;
|
|
87
|
+
const selection = window.getSelection();
|
|
88
|
+
if (exclude && !target.matches(exclude)) {
|
|
89
|
+
if (!allowSelection || selection.toString().length < selectionMin) {
|
|
90
|
+
this.toggle();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
getClass(child) {
|
|
95
|
+
const { namespace } = this.options;
|
|
96
|
+
return child ? `${ namespace }__${ child }` : namespace;
|
|
97
|
+
}
|
|
98
|
+
createControlContent() {
|
|
99
|
+
return `
|
|
100
|
+
<span class="hidden-visually">Show More Information</span>
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
setVisiblity(visible) {
|
|
104
|
+
const { back, container, control } = this.elements;
|
|
105
|
+
const state = visible ? "open" : "closed";
|
|
106
|
+
back.style.zIndex = visible ? "10" : "1";
|
|
107
|
+
back.style.visibility = visible ? "visible" : "hidden";
|
|
108
|
+
container.setAttribute(this.stateAttr, state);
|
|
109
|
+
back.setAttribute('aria-hidden', visible ? "false" : "true");
|
|
110
|
+
control.setAttribute('aria-expanded', visible ? "true" : "false");
|
|
111
|
+
this.isOpen = visible;
|
|
112
|
+
}
|
|
113
|
+
containerCss() {
|
|
114
|
+
return `
|
|
115
|
+
display: -ms-grid;
|
|
116
|
+
display: grid;
|
|
117
|
+
position: relative;
|
|
118
|
+
-ms-grid-columns: 1fr;
|
|
119
|
+
grid-template-columns: 1fr;
|
|
120
|
+
justify-items: stretch;
|
|
121
|
+
grid-template-areas: "${ this.options.namespace }";
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
`;
|
|
124
|
+
}
|
|
125
|
+
panelCss(zIndex = 1) {
|
|
126
|
+
return `
|
|
127
|
+
grid-area: ${ this.options.namespace };
|
|
128
|
+
z-index: ${ zIndex }
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export default Flipcard;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Preliminary Notes:
|
|
136
|
+
* Considerations for Accessiblity:
|
|
137
|
+
* - https://webaim.org/standards/wcag/checklist
|
|
138
|
+
* - https://www.w3.org/TR/WCAG21/#on-focus
|
|
139
|
+
* - https://a11y-style-guide.com/style-guide/section-cards.html
|
|
140
|
+
* - Reduced Motion
|
|
141
|
+
* - Percievable (interactive)
|
|
142
|
+
* - Final Descision
|
|
143
|
+
* - Use a buttons
|
|
144
|
+
* - Why?
|
|
145
|
+
* - Can't use whole card surface as click
|
|
146
|
+
* * Selections
|
|
147
|
+
* * Other interactions
|
|
148
|
+
* * How to make that make sense to SR
|
|
149
|
+
* * Keyboard focuses and then clicks
|
|
150
|
+
* * Accidental flipping on zoom
|
|
151
|
+
* - Can't use hover
|
|
152
|
+
*
|
|
153
|
+
* - BRAINSTORM START:
|
|
154
|
+
* - Don't use hover or focus (motor control issues)
|
|
155
|
+
* - Needs to use click
|
|
156
|
+
* - Run through screenreader expierence
|
|
157
|
+
* - Hits button (reads title, click to reveal)
|
|
158
|
+
* - Focuses the content button (reads content, backside, click to unreveal)
|
|
159
|
+
* - NO BUTTONS CAN"T HAVE CONTENT, BUTTONS NEED TO STATE THEIR INTENT
|
|
160
|
+
* - Try Again, Run through screenreader expierence
|
|
161
|
+
* - Screen reader encounters flipcard
|
|
162
|
+
* - Headline is read
|
|
163
|
+
* - Button is read (reveal description)
|
|
164
|
+
* - Button is clicked
|
|
165
|
+
* - Content is shown and focused
|
|
166
|
+
* - Button to flip back
|
|
167
|
+
* - For Keybaord users
|
|
168
|
+
* - The accessible buttons can be used or a click handler can be attached to the
|
|
169
|
+
* flipcard and given
|
|
170
|
+
* - Why not always show the content to screenreaders?
|
|
171
|
+
* - How to hide controls from them? (controls can't be hidden)
|
|
172
|
+
* - How to not have events interfere click
|
|
173
|
+
* - Maybe use a single control and make it say "jumpto definition"
|
|
174
|
+
* - Kind of lame
|
|
175
|
+
* - What about going back to focus and then attaching a click handler?
|
|
176
|
+
* - Visual users will see the content on keyboard or mouse or touch
|
|
177
|
+
* - We can reduce the motion with query
|
|
178
|
+
* - Note: WCAG AAA - 1.4.13 Content on Hover or Focus
|
|
179
|
+
* - Need to bind escape
|
|
180
|
+
* - Mouse users and touch will need to click
|
|
181
|
+
* - How does it focus and work on a screenreader?
|
|
182
|
+
* - Cannot use FOCUS!
|
|
183
|
+
* - https://www.w3.org/WAI/WCAG21/Understanding/on-focus.html
|
|
184
|
+
* - What if the user was zoomed? They may never see the title/front
|
|
185
|
+
* - I think it MUST use buttons or a button to flip
|
|
186
|
+
* - Because users need to be able to scroll, interact and select text in a back
|
|
187
|
+
* @example html
|
|
188
|
+
* <div class="flipcard">
|
|
189
|
+
* <h3 class="flipcard__front">
|
|
190
|
+
* Term Name
|
|
191
|
+
* <button class="flipcard__toggle">
|
|
192
|
+
* <span class="hidden-visually">Show Definition</span>
|
|
193
|
+
* </button>
|
|
194
|
+
* </h3>
|
|
195
|
+
* <div class="flipcard__back">
|
|
196
|
+
* Some definiton example lorem ipsum et depsi anu olor.
|
|
197
|
+
* <button class="flipcard__toggle">
|
|
198
|
+
* <span class="hidden-visually">Hide Definition</span>
|
|
199
|
+
* </button>
|
|
200
|
+
* </div>
|
|
201
|
+
* </div>
|
|
202
|
+
*/
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getName } from "../events/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sets up document for grid position classes
|
|
5
|
+
* @param {String} selector The selector for the parent element
|
|
6
|
+
* @param {Object} classes Classes (optional) @see setPositionClasses
|
|
7
|
+
*/
|
|
8
|
+
export function init(selector = "[data-grid]", classes) {
|
|
9
|
+
document.addEventListener(getName("pageModified"), () => setup(selector, classes));
|
|
10
|
+
document.addEventListener(getName("pageResized"), () => setup(selector, classes));
|
|
11
|
+
setup(selector, classes);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Goes through document and finds elements that need to have positioning classes
|
|
16
|
+
* @param {String} selector The selector for the parent element
|
|
17
|
+
* @param {Object} classes Classes (optional) @see setPositionClasses
|
|
18
|
+
*/
|
|
19
|
+
export function setup(selector, classes) {
|
|
20
|
+
document.querySelectorAll(selector).forEach(element => setPositionClasses(element, classes || undefined));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Sets up the positonal classes that would come from the equal
|
|
25
|
+
* height module. Needs to be rerun by user when layout changes
|
|
26
|
+
* or new instances are added to the screen
|
|
27
|
+
* - Used for gutter crops
|
|
28
|
+
* - Used for rule placement
|
|
29
|
+
* - **Devs** Remember that default classes should match sass defaults
|
|
30
|
+
* @param {Node} parent The grid parent <data-grid="">
|
|
31
|
+
* @param {Object} classes Override the default equal heights classes
|
|
32
|
+
*/
|
|
33
|
+
export function setPositionClasses(parent, classes = {
|
|
34
|
+
columnFirst: 'position-column-first',
|
|
35
|
+
columnLast: 'position-column-last',
|
|
36
|
+
rowFirst: 'position-row-first',
|
|
37
|
+
rowLast: 'position-row-last'
|
|
38
|
+
}) {
|
|
39
|
+
const children = [...parent.children];
|
|
40
|
+
const rows = [];
|
|
41
|
+
let lastY;
|
|
42
|
+
// Check element against last
|
|
43
|
+
// If they don't match it's a new row create a new array
|
|
44
|
+
// Then push into the last array in the rows array
|
|
45
|
+
children.forEach((child) => {
|
|
46
|
+
const y = child.getBoundingClientRect().y;
|
|
47
|
+
if (lastY !== y) rows.push([]);
|
|
48
|
+
rows[rows.length - 1].push(child);
|
|
49
|
+
lastY = y;
|
|
50
|
+
child.classList.remove(...Object.values(classes)); // Remove previously set classes
|
|
51
|
+
});
|
|
52
|
+
// Apply Classes
|
|
53
|
+
rows.forEach((row, index) => {
|
|
54
|
+
if (index === 0)
|
|
55
|
+
row.forEach(child => child.classList.add(classes.rowFirst));
|
|
56
|
+
if (index == rows.length - 1)
|
|
57
|
+
row.forEach(child => child.classList.add(classes.rowLast));
|
|
58
|
+
|
|
59
|
+
row.forEach((child, childIndex) => {
|
|
60
|
+
if (childIndex === 0)
|
|
61
|
+
child.classList.add(classes.columnFirst);
|
|
62
|
+
if (childIndex == row.length - 1)
|
|
63
|
+
child.classList.add(classes.columnLast);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Version: 1.0.4
|
|
2
|
+
// Changes:
|
|
3
|
+
// 1.0.4 | The modal library has a bug with multiple modals and using a custom close handler
|
|
4
|
+
// In the future we want to abandon this library but for now it works by setting up our own open and close buttons
|
|
5
|
+
// This is not setup to work with programmatic modals!!
|
|
6
|
+
// 1.0.3 | Added youtube video closing stuff
|
|
7
|
+
// 1.0.3 | Added youtube video closing stuff
|
|
8
|
+
// 1.0.2 | Added custom close handler and checked to make sure resizer doesn't trigger click
|
|
9
|
+
// 1.0.1 | Added optional resizable (allowResize)
|
|
10
|
+
// Todo: - Make the container the content is getting the orginal classes, or don't remove them. And allow user to pass classes via config
|
|
11
|
+
|
|
12
|
+
// Javascript builds strucutre, modal's live in content in simple container.
|
|
13
|
+
// Modal theme and strucutre is added in scripting That way if we change the
|
|
14
|
+
// interface in the future we don't need to change/update markup.
|
|
15
|
+
import MicroModal from 'micromodal';
|
|
16
|
+
import Resizer from './resizer.js';
|
|
17
|
+
import { createElementFromHtml } from '../utils/dom.js';
|
|
18
|
+
import { pauseVideos, prepVideos } from '../helpers/pause-youtube-video.js';
|
|
19
|
+
const classes = {
|
|
20
|
+
open: 'site-modal--open',
|
|
21
|
+
container: "site-modal__container",
|
|
22
|
+
body: "site-modal__body",
|
|
23
|
+
resizer: "site-modal__resizer"
|
|
24
|
+
};
|
|
25
|
+
const triggerAttr = "data-site-modal-trigger";
|
|
26
|
+
export { triggerAttr };
|
|
27
|
+
const triggerSelector = `[${ triggerAttr }]`;
|
|
28
|
+
const defaults = {
|
|
29
|
+
allowResize: true,
|
|
30
|
+
position: "center",
|
|
31
|
+
containerClass: "",
|
|
32
|
+
closeSelector: "[data-site-modal-close]"
|
|
33
|
+
};
|
|
34
|
+
const configMicroModal = {
|
|
35
|
+
openClass: classes.open,
|
|
36
|
+
disableScroll: true,
|
|
37
|
+
openTrigger: 'data-site-modal-trigger',
|
|
38
|
+
closeTrigger: 'data-NOT-USED', // Proxied to avoid this click handler (on keydown, allow click on things underneath)
|
|
39
|
+
onClose: function(modal) {
|
|
40
|
+
pauseVideos(modal);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const wrappers = [];
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// Create a grouping container to grab all modals from content of the
|
|
47
|
+
// page and move to the bottom of the page
|
|
48
|
+
// const container = createContainer();
|
|
49
|
+
|
|
50
|
+
// The [data-site-modal] is used to seperate the libraries' interface
|
|
51
|
+
// and the modal's styling classes, so it can be adjusted or extended
|
|
52
|
+
// in the future
|
|
53
|
+
document.querySelectorAll('[data-site-modal]').forEach((element) => setupModal(element));
|
|
54
|
+
|
|
55
|
+
// Intialize modal library script
|
|
56
|
+
// init();
|
|
57
|
+
attachTriggers();
|
|
58
|
+
|
|
59
|
+
export function attachTriggers(context = document) {
|
|
60
|
+
const flag = 'data-site-modal-trigger-attached';
|
|
61
|
+
context.querySelectorAll(triggerSelector).forEach(trigger => {
|
|
62
|
+
if (!trigger.hasAttribute(flag)) {
|
|
63
|
+
const mid = trigger.getAttribute(triggerAttr);
|
|
64
|
+
if (!mid) {
|
|
65
|
+
console.warn("Unable to get modal trigger id");
|
|
66
|
+
} else {
|
|
67
|
+
trigger.setAttribute(flag, "");
|
|
68
|
+
trigger.addEventListener("click", () => {
|
|
69
|
+
show(mid)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Function to setup each modal
|
|
78
|
+
* - Creates structure
|
|
79
|
+
* - Gets settings from elements data attrite
|
|
80
|
+
* - Moves it to the end of the document
|
|
81
|
+
* - Adds resizer if position (left || right)
|
|
82
|
+
* @param {Node} modal Modal element ie. `[data-site-modal]`
|
|
83
|
+
* @param {Object} settings Custom settings object to merge, same interface as `[data-site-modal]` settings
|
|
84
|
+
*/
|
|
85
|
+
export function setupModal(modal, settings) {
|
|
86
|
+
// Grab things from original element before modifying
|
|
87
|
+
const id = modal.id;
|
|
88
|
+
const originalClasses = modal.getAttribute('class') || '';
|
|
89
|
+
// Grab settings from element and optionally from settings passed
|
|
90
|
+
let data = {};
|
|
91
|
+
if (modal.dataset.siteModal) {
|
|
92
|
+
data = JSON.parse(modal.dataset.siteModal)
|
|
93
|
+
}
|
|
94
|
+
data = Object.assign({}, defaults, data, settings);
|
|
95
|
+
const { allowResize, position } = data;
|
|
96
|
+
const notCenter = position !== "center";
|
|
97
|
+
const hasResizer = notCenter && allowResize;
|
|
98
|
+
const resizerMarkup = hasResizer ? `<div class="${ classes.resizer }"></div>` : '';
|
|
99
|
+
const resizerModifierClass = allowResize ? "resize" : "no-resize";
|
|
100
|
+
const closeAttr = "data-site-modal-close";
|
|
101
|
+
// Remove attributes
|
|
102
|
+
modal.removeAttribute('data-site-modal');
|
|
103
|
+
modal.removeAttribute('id');
|
|
104
|
+
modal.removeAttribute('class');
|
|
105
|
+
// Template for new modal container (modal's body, the original element is
|
|
106
|
+
// appended after as not to lose any listerner's/etc
|
|
107
|
+
const markup = `
|
|
108
|
+
<div
|
|
109
|
+
class="
|
|
110
|
+
site-modal
|
|
111
|
+
site-modal--${ position }
|
|
112
|
+
site-modal--${ resizerModifierClass }
|
|
113
|
+
${ data.containerClass }
|
|
114
|
+
"
|
|
115
|
+
id="${ id }" aria-hidden="true"
|
|
116
|
+
>
|
|
117
|
+
<div class="site-modal__overlay" tabindex="-1" ${ closeAttr }>
|
|
118
|
+
<div class="site-modal__container" role="dialog" aria-modal="true" aria-labelledby="${ id }-title">
|
|
119
|
+
<div class="site-modal__header">
|
|
120
|
+
<h2 class="site-modal__title" id="${ id }-title" tabindex="0">${ data.title }</h2>
|
|
121
|
+
<button class="site-modal__close" aria-label="Close modal" ${ closeAttr }>
|
|
122
|
+
<span class="site-modal__close-icon" aria-hidden="true" ${ closeAttr }></span>
|
|
123
|
+
</button>
|
|
124
|
+
</div>
|
|
125
|
+
<div class="${ classes.body } ${ originalClasses }"></div>
|
|
126
|
+
${ resizerMarkup }
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>`;
|
|
130
|
+
|
|
131
|
+
// Create wrapped modal (with repeatable structure), and insert
|
|
132
|
+
// the original modal content into it
|
|
133
|
+
const select = (container, classKey) => container.querySelector("." + classes[classKey]);
|
|
134
|
+
const wrapper = createElementFromHtml(markup.trim());
|
|
135
|
+
const elements = {
|
|
136
|
+
body: select(wrapper, 'body'),
|
|
137
|
+
resizer: select(wrapper, 'resizer'),
|
|
138
|
+
container: select(wrapper, 'container')
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Move the orginal content into the modal's body
|
|
142
|
+
elements.body.appendChild(modal);
|
|
143
|
+
// Add resizer if not a center positioned modal
|
|
144
|
+
if (hasResizer) {
|
|
145
|
+
new Resizer(elements.container, elements.resizer, {
|
|
146
|
+
fromLeft: position === "right"
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Prep Youtube Videos to be able to close
|
|
151
|
+
prepVideos(wrapper);
|
|
152
|
+
|
|
153
|
+
// Add modal to the end of docuemnt
|
|
154
|
+
wrappers.push(wrapper);
|
|
155
|
+
document.body.appendChild(wrapper);
|
|
156
|
+
// Add our own close handlers to avoide the native
|
|
157
|
+
const closeButtons = wrapper.querySelectorAll(data.closeSelector);
|
|
158
|
+
closeButtons.forEach(b => b.addEventListener('click', ({ target }) => {
|
|
159
|
+
const outsideContainer = !elements.container.contains(target) && target !== elements.container;
|
|
160
|
+
// Last condition is the overlay/backdrop (click outside)
|
|
161
|
+
if (target.matches(`[${ closeAttr }]`) || outsideContainer) {
|
|
162
|
+
close(id);
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Intialize all modals on the page
|
|
168
|
+
* - can be used after AJAX adds content
|
|
169
|
+
*/
|
|
170
|
+
// export function init() {
|
|
171
|
+
// MicroModal.init(configMicroModal);
|
|
172
|
+
// }
|
|
173
|
+
/**
|
|
174
|
+
* Open a modal
|
|
175
|
+
* @param {String} id The id of the modal to open
|
|
176
|
+
*/
|
|
177
|
+
export function show(id, config) {
|
|
178
|
+
const merged = Object.assign({}, configMicroModal, config);
|
|
179
|
+
MicroModal.show(id, merged);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Close a modal
|
|
183
|
+
* @param {String} id The id of the modal to open
|
|
184
|
+
*/
|
|
185
|
+
export function close(id) {
|
|
186
|
+
MicroModal.close(id);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
// function createContainer() {
|
|
192
|
+
// const container = document.createElement('div');
|
|
193
|
+
// container.classList.add('site-modals');
|
|
194
|
+
// document.body.appendChild(container);
|
|
195
|
+
// return container;
|
|
196
|
+
// }
|
|
197
|
+
|
|
198
|
+
// From GITHUB Issues (user remedy)
|
|
199
|
+
// export function refresh() {
|
|
200
|
+
// // Use whatever selector you're using for MicroModal triggers.
|
|
201
|
+
// const modalTrigger = 'data-micromodal-trigger';
|
|
202
|
+
|
|
203
|
+
// // Get all triggers.
|
|
204
|
+
// const modalTriggers = document.querySelectorAll( `[${modalTrigger}]` );
|
|
205
|
+
|
|
206
|
+
// modalTriggers.forEach( trigger => {
|
|
207
|
+
// // Get the attribute to save.
|
|
208
|
+
// const triggerElement = trigger.getAttribute( modalTrigger );
|
|
209
|
+
|
|
210
|
+
// // Remove the attribute briefly to clear memory/existing modals.
|
|
211
|
+
// trigger.removeAttribute( modalTrigger );
|
|
212
|
+
|
|
213
|
+
// // Immediately add it back.
|
|
214
|
+
// trigger.setAttribute( modalTrigger, triggerElement );
|
|
215
|
+
|
|
216
|
+
// // Re-initialize.
|
|
217
|
+
// init();
|
|
218
|
+
// } );
|
|
219
|
+
// }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to be used in overflow scrollers "amount" option. This function will
|
|
3
|
+
* determine how many items can fit in the viewport, taking into account scroll padding left,
|
|
4
|
+
* and will set the scroll amount to paginate between items. Items size can be anything
|
|
5
|
+
* (ie. one per screen vs 3.5 per screen will both work). This seperated from the plugin
|
|
6
|
+
* for tree shaking incase it's unneeded. Currently this is only setup for horizontal scrolling
|
|
7
|
+
*
|
|
8
|
+
* Note: This is setup to return the function, incase configuration is needed in the future
|
|
9
|
+
* it can be passed to the create function
|
|
10
|
+
*
|
|
11
|
+
* @return {Function} A function to be used in overflow scrollers "amount" configuration property
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export default function create() {
|
|
15
|
+
return function pager(instance, dir) {
|
|
16
|
+
const isNext = dir === "next";
|
|
17
|
+
const { track } = instance.elements;
|
|
18
|
+
if (!track.children) return 400;
|
|
19
|
+
const trackStyle = window.getComputedStyle(track);
|
|
20
|
+
// Note we are banking on the scroll padding string to be in "px", not doing any conversions here
|
|
21
|
+
const scrollPaddingRaw = trackStyle.getPropertyValue( 'scroll-padding-left' ).replace( 'auto', '0px' );
|
|
22
|
+
const scrollPadding = parseInt(scrollPaddingRaw, 10);
|
|
23
|
+
|
|
24
|
+
const { scrollLeft, offsetWidth } = track;
|
|
25
|
+
const right = scrollLeft + offsetWidth;
|
|
26
|
+
// Get all slide positions into an array
|
|
27
|
+
const slides = [ ...track.children ].map(element => {
|
|
28
|
+
const { offsetLeft, offsetWidth } = element;
|
|
29
|
+
return {
|
|
30
|
+
element,
|
|
31
|
+
offsetLeft,
|
|
32
|
+
offsetRight: offsetLeft + offsetWidth
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
// Test edges to see what can fit, slide found will be the slide to scroll to
|
|
36
|
+
let slideFound;
|
|
37
|
+
if (isNext) {
|
|
38
|
+
// Find the first item that didn't make it
|
|
39
|
+
slideFound = slides.find(slide => slide.offsetRight >= right);
|
|
40
|
+
} else {
|
|
41
|
+
let slideBeforeIndex = slides.findLastIndex(slide => slide.offsetLeft <= scrollLeft);
|
|
42
|
+
// Find the slides before this slide that can fit, including the slide before
|
|
43
|
+
if (slideBeforeIndex) {
|
|
44
|
+
let slideBefore = slides[slideBeforeIndex];
|
|
45
|
+
let slidesBefore = slides.slice(0, slideBeforeIndex + 1);
|
|
46
|
+
slideFound = slidesBefore.find(slide => {
|
|
47
|
+
const rightEdge = slide.offsetLeft + scrollPadding + offsetWidth;
|
|
48
|
+
return rightEdge >= slideBefore.offsetRight;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (slideFound) {
|
|
53
|
+
return isNext ? slideFound.offsetLeft : slideFound.offsetLeft + scrollPadding;
|
|
54
|
+
} else {
|
|
55
|
+
return 400;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|