@inc2734/unitone-css 0.42.5 → 0.42.6
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/dist/app.js +1 -1
- package/package.json +1 -1
- package/src/app.js +32 -38
package/dist/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var
|
|
1
|
+
!function(){"use strict";var e={};function t(e,t){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,t){if(e){if("string"==typeof e)return n(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){o&&(e=o);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,l=!0,a=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return l=e.done,e},e:function(e){a=!0,u=e},f:function(){try{l||null==o.return||o.return()}finally{if(a)throw u}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}e.d=function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},e.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o=new ResizeObserver((function(e){var n,o,r,i,u=t(e);try{for(u.s();!(n=u.n()).done;){o=n.value.target,void 0,void 0,r=parseFloat(window.getComputedStyle(document.documentElement).getPropertyValue("font-size")),i=parseFloat(window.getComputedStyle(o).getPropertyValue("font-size")),o.style.setProperty("--unitone--fluid-font-size-magnification",i/r)}}catch(e){u.e(e)}finally{u.f()}}));document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll('[data-unitone-layout~="-fluid-typography"]').forEach((function(e){o.observe(e)}))}));var r=function(e){var t,n,o=null===(t=[].slice.call(e.children))||void 0===t?void 0:t[0];o&&[].slice.call(e.children).forEach((function(e){var t,r=o.getBoundingClientRect(),i=null===(t=n)||void 0===t?void 0:t.getBoundingClientRect(),u=e.getBoundingClientRect(),l=(e.getAttribute("data-unitone-layout")||"").split(" ");r.top<u.top?l.includes("-linewrap")||l.push("-linewrap"):l=l.filter((function(e){return"-linewrap"!==e})),o===e||null!=i&&i.top&&i.top<u.top?l.includes("-bol")||l.push("-bol"):l=l.filter((function(e){return"-bol"!==e})),e.setAttribute("data-unitone-layout",l.join(" ")),n=e}))},i=new ResizeObserver((function(e){var n,o=t(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;r(i.target)}}catch(e){o.e(e)}finally{o.f()}}));document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll('[data-unitone-layout*="-divider:"]').forEach((function(e){i.observe(e)}))}));var u=function(e){var t;e.parentNode,e.style.columnCount="",[].slice.call(e.children).reverse().some((function(e){if(!["absolute","fixed"].includes(getComputedStyle(e).position))return t=e,!0})),t&&function n(o){e.style.columnCount=o;var r=e.getBoundingClientRect().top+e.getBoundingClientRect().height,i=t.getBoundingClientRect().top+t.getBoundingClientRect().height,u=e.getBoundingClientRect().left,l=t.getBoundingClientRect().left;(r<i||u>l)&&n(o+1)}(1)};document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll('[data-unitone-layout~="vertical-writing"]').forEach((function(e){!function(e){var n=0,o=new ResizeObserver((function(e){var o,r=t(e);try{for(r.s();!(o=r.n()).done;){var i,l=o.value,a=null===(i=l.borderBoxSize)||void 0===i?void 0:i[0].blockSize;a!==n&&(n=a,u(l.target))}}catch(e){r.e(e)}finally{r.f()}}));o.unobserve(e),o.observe(e)}(e)}))}))}();
|
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -67,13 +67,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
const
|
|
70
|
+
const setColumnCountForVertical = (target) => {
|
|
71
71
|
const parent = target.parentNode;
|
|
72
|
-
parent.style.height = '';
|
|
73
72
|
target.style.columnCount = '';
|
|
74
73
|
|
|
75
|
-
const targetRect = target.getBoundingClientRect();
|
|
76
|
-
|
|
77
74
|
let lastChild;
|
|
78
75
|
[].slice
|
|
79
76
|
.call(target.children)
|
|
@@ -88,46 +85,43 @@ const setHeightForVertical = (target) => {
|
|
|
88
85
|
if (!lastChild) {
|
|
89
86
|
return;
|
|
90
87
|
}
|
|
91
|
-
const childrenMinX = lastChild.getBoundingClientRect().left;
|
|
92
|
-
const preRowCount = Math.ceil(
|
|
93
|
-
(childrenMinX * -1 + targetRect.left + targetRect.width) / targetRect.width,
|
|
94
|
-
);
|
|
95
|
-
const preHeight = `calc(${preRowCount} * ${getComputedStyle(target).getPropertyValue(
|
|
96
|
-
'--unitone--max-height',
|
|
97
|
-
)} + ${preRowCount - 1} * ${getComputedStyle(target).getPropertyValue(
|
|
98
|
-
'--unitone--column-gap',
|
|
99
|
-
)} )`;
|
|
100
|
-
|
|
101
|
-
parent.style.height = preHeight;
|
|
102
|
-
if (targetRect.left > childrenMinX) {
|
|
103
|
-
target.style.columnCount = 2;
|
|
104
|
-
}
|
|
105
88
|
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
89
|
+
const setColumnCount = (columnCount) => {
|
|
90
|
+
target.style.columnCount = columnCount;
|
|
91
|
+
const targetY = target.getBoundingClientRect().top + target.getBoundingClientRect().height;
|
|
92
|
+
const lastChildY =
|
|
93
|
+
lastChild.getBoundingClientRect().top + lastChild.getBoundingClientRect().height;
|
|
94
|
+
|
|
95
|
+
const targetX = target.getBoundingClientRect().left;
|
|
96
|
+
const lastChildX = lastChild.getBoundingClientRect().left;
|
|
97
|
+
|
|
98
|
+
if (targetY < lastChildY || targetX > lastChildX) {
|
|
99
|
+
setColumnCount(columnCount + 1);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
setColumnCount(1);
|
|
120
103
|
};
|
|
121
104
|
|
|
122
|
-
export const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
105
|
+
export const verticalsResizeObserve = (target) => {
|
|
106
|
+
let prevWidth = 0;
|
|
107
|
+
|
|
108
|
+
const observer = new ResizeObserver((entries) => {
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
const width = entry.borderBoxSize?.[0].blockSize;
|
|
111
|
+
if (width !== prevWidth) {
|
|
112
|
+
prevWidth = width;
|
|
113
|
+
setColumnCountForVertical(entry.target);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
observer.unobserve(target);
|
|
119
|
+
observer.observe(target);
|
|
120
|
+
};
|
|
127
121
|
|
|
128
122
|
document.addEventListener('DOMContentLoaded', () => {
|
|
129
123
|
const verticals = document.querySelectorAll('[data-unitone-layout~="vertical-writing"]');
|
|
130
124
|
verticals.forEach((target) => {
|
|
131
|
-
|
|
125
|
+
verticalsResizeObserve(target);
|
|
132
126
|
});
|
|
133
127
|
});
|