motimeline 2.7.4 → 2.8.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/README.md +16 -1
- package/dist/moTimeline.cjs +3 -3
- package/dist/moTimeline.css +2 -2
- package/dist/moTimeline.js +91 -74
- package/dist/moTimeline.umd.js +3 -3
- package/package.json +1 -1
- package/src/moTimeline.css +21 -3
- package/src/moTimeline.js +28 -2
package/README.md
CHANGED
|
@@ -105,6 +105,10 @@ import 'motimeline/dist/moTimeline.css';
|
|
|
105
105
|
| `showCounterStyle` | string | `'counter'` | `'counter'` — sequential item number (1, 2, 3…). `'image'` — image from `data-mo-icon` on the `<li>`; falls back to a built-in flat SVG dot if the attribute is absent. `'none'` — badge element is created (preserving center-line spacing) but rendered with `opacity: 0`. |
|
|
106
106
|
| `cardBorderRadius` | string | `'8px'` | Border radius of the themed card and its banner image top corners. Sets `--mo-card-border-radius` on the container. Any valid CSS length is accepted (e.g. `'0'`, `'16px'`, `'1rem'`). |
|
|
107
107
|
| `avatarSize` | string | `'50px'` | Width and height of the circular avatar image. Sets `--mo-avatar-size` on the container. Any valid CSS length is accepted (e.g. `'40px'`, `'4rem'`). |
|
|
108
|
+
| `cardMargin` | string | `'0.5rem 1.25rem 0.5rem 0.5rem'` | Margin of left-column themed cards. The larger right value creates space toward the center line. Sets `--mo-card-margin` on the container. |
|
|
109
|
+
| `cardMarginInverted` | string | `'0.5rem 0.5rem 0.5rem 1.25rem'` | Margin of right-column (inverted) themed cards. The larger left value creates space toward the center line. Sets `--mo-card-margin-inverted` on the container. |
|
|
110
|
+
| `cardMarginFullWidth` | string | `'0.5rem'` | Margin of full-width themed cards. Sets `--mo-card-margin-fullwidth` on the container. |
|
|
111
|
+
| `randomFullWidth` | number \| boolean | `0` | `0`/`false` = off. A number `0–1` sets the probability that each item is randomly promoted to full-width during init. `true` = 33% chance. Items can also be set manually by adding the `mo-fullwidth` class to the `<li>`. |
|
|
108
112
|
|
|
109
113
|
---
|
|
110
114
|
|
|
@@ -327,7 +331,10 @@ async function fetchPage(page) {
|
|
|
327
331
|
--mo-badge-font-size: 12px;
|
|
328
332
|
--mo-arrow-color: #dde1e7;
|
|
329
333
|
--mo-card-border-radius: 8px;
|
|
330
|
-
--mo-avatar-size:
|
|
334
|
+
--mo-avatar-size: 50px;
|
|
335
|
+
--mo-card-margin: 0.5rem 1.25rem 0.5rem 0.5rem;
|
|
336
|
+
--mo-card-margin-inverted: 0.5rem 0.5rem 0.5rem 1.25rem;
|
|
337
|
+
--mo-card-margin-fullwidth: 0.5rem;
|
|
331
338
|
}
|
|
332
339
|
```
|
|
333
340
|
|
|
@@ -357,6 +364,14 @@ No framework option needed. Wrap the `<ul>` inside a Bootstrap `.container`:
|
|
|
357
364
|
|
|
358
365
|
## Changelog
|
|
359
366
|
|
|
367
|
+
### v2.8.0
|
|
368
|
+
- New: full-width items — add `mo-fullwidth` class to any `<li>` to make it span both columns (two-column mode only). Badge and arrow are hidden automatically; card margin collapses to equal sides via `--mo-card-margin-fullwidth`
|
|
369
|
+
- New option `randomFullWidth` (number 0–1 or boolean) — randomly promotes items to full-width during init (`true` = 33% probability)
|
|
370
|
+
- New option `cardMarginFullWidth` (string, default `'0.5rem'`) — controls the themed card margin for full-width items
|
|
371
|
+
|
|
372
|
+
### v2.7.5
|
|
373
|
+
- New options `cardMargin` (default `'0.5rem 1.25rem 0.5rem 0.5rem'`) and `cardMarginInverted` (default `'0.5rem 0.5rem 0.5rem 1.25rem'`) — control themed card margins via `--mo-card-margin` and `--mo-card-margin-inverted`
|
|
374
|
+
|
|
360
375
|
### v2.7.4
|
|
361
376
|
- Fix: wrong column placement when adjacent left and right items share the same bottom y-coordinate ([#3](https://github.com/MattOpen/moTimeline/issues/3)) — adds a 1 px tolerance to the column algorithm to absorb `offsetHeight`/`offsetTop` rounding mismatches
|
|
362
377
|
|
package/dist/moTimeline.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
* moTimeline v2.
|
|
1
|
+
"use strict";var E=Object.defineProperty;var _=(n,e,t)=>e in n?E(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var p=(n,e,t)=>_(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});/*!
|
|
2
|
+
* moTimeline v2.8.0
|
|
3
3
|
* Responsive two-column timeline layout library
|
|
4
4
|
* https://github.com/MattOpen/moTimeline
|
|
5
5
|
* MIT License
|
|
6
|
-
*/const
|
|
6
|
+
*/const l=new WeakMap,v={columnCount:{xs:1,sm:2,md:2,lg:2},showBadge:!1,showArrow:!1,theme:!1,showCounterStyle:"counter",cardBorderRadius:"8px",avatarSize:"50px",cardMargin:"0.5rem 1.25rem 0.5rem 0.5rem",cardMarginInverted:"0.5rem 0.5rem 0.5rem 1.25rem",cardMarginFullWidth:"0.5rem",randomFullWidth:0},b="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";function w(){const n=window.innerWidth;return n<600?"xs":n<992?"sm":n<1200?"md":"lg"}function C(n,e=100){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>n(...s),e)}}function m(n){return n?{o:n.offsetTop,h:n.offsetHeight,gppu:n.offsetTop+n.offsetHeight}:{o:0,h:0,gppu:0}}function y(n,e){const t=[];let s=n.previousElementSibling;for(;s;)(!e||s.matches(e))&&t.push(s),s=s.previousElementSibling;return t}const c=class c{constructor(e,t={}){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("moTimeline: element not found");this.element=e,this.settings=Object.assign({},v,t),this.settings.columnCount=Object.assign({},v.columnCount,t.columnCount),this._resizeHandler=C(()=>this.refresh(),100),this._initialized=!1,this.init()}init(){const e=this.element;if(l.has(e)){this.refresh();return}const t=Object.assign({},this.settings,{lastItemIdx:0});l.set(e,t),c.instances.add(this),e.classList.add("mo-timeline"),t.theme&&e.classList.add("mo-theme"),e.style.setProperty("--mo-card-border-radius",t.cardBorderRadius),e.style.setProperty("--mo-avatar-size",t.avatarSize),e.style.setProperty("--mo-card-margin",t.cardMargin),e.style.setProperty("--mo-card-margin-inverted",t.cardMarginInverted),e.style.setProperty("--mo-card-margin-fullwidth",t.cardMarginFullWidth),this._initialized=!0,window.addEventListener("resize",this._resizeHandler),Array.from(e.children).length>0&&this._initItems()}refresh(){c.instances.forEach(e=>{const t=e.element,s=l.get(t);s&&(s.col=s.columnCount[w()],e._setDivider(),Array.from(t.children).forEach(o=>{e._setPostPosition(o)}))})}initNewItems(){this._initItems()}addItems(e){typeof e=="string"&&(e=JSON.parse(e)),e.forEach(t=>this.element.appendChild(this._createItemElement(t))),this._initItems()}destroy(){window.removeEventListener("resize",this._resizeHandler),l.delete(this.element),c.instances.delete(this),this.element.style.removeProperty("--mo-card-border-radius"),this.element.style.removeProperty("--mo-avatar-size"),this.element.style.removeProperty("--mo-card-margin"),this.element.style.removeProperty("--mo-card-margin-inverted"),this.element.style.removeProperty("--mo-card-margin-fullwidth"),this.element.classList.remove("mo-timeline","mo-theme","mo-twocol"),Array.from(this.element.children).forEach(e=>{e.classList.remove("mo-item","js-mo-item","mo-inverted","js-mo-inverted","mo-offset","mo-fullwidth","js-mo-fullwidth"),e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach(t=>t.remove())})}_getData(){return l.get(this.element)}_setDivider(){const e=this._getData();e&&(e.col=e.columnCount[w()],this.element.classList.toggle("mo-twocol",e.col>1))}_initItems(){const e=this.element,t=this._getData();if(!t)return;const s=t.lastItemIdx,o=Array.from(e.children),r=o.slice(s);if(r.length!==0){if(r.forEach((i,a)=>{i.id||(i.id="moT"+crypto.randomUUID()+"_"+(a+s)),i.classList.add("mo-item","js-mo-item")}),this._setDivider(),t.randomFullWidth){const i=t.randomFullWidth===!0?.33:t.randomFullWidth;r.forEach(a=>{!a.classList.contains("mo-fullwidth")&&Math.random()<i&&a.classList.add("mo-fullwidth","js-mo-fullwidth")})}r.forEach((i,a)=>{t.showBadge&&this._createBadge(i,a+s+1),t.showArrow&&this._createArrow(i)}),t.lastItemIdx=o.length,l.set(e,t),this.refresh(),r.forEach(i=>{i.querySelectorAll("img").forEach(a=>{a.complete||a.addEventListener("load",this._resizeHandler,{once:!0})})})}}_setPostPosition(e){if(e.classList.contains("mo-fullwidth")){e.classList.remove("mo-inverted","js-mo-inverted","mo-offset");return}const t=this._getLeftOrRight(e);t&&(e.classList.toggle("mo-inverted",t.lr>0),e.classList.toggle("js-mo-inverted",t.lr>0),e.classList.toggle("mo-offset",t.badge_offset>0))}_getLeftOrRight(e){if(!e)return null;const t=this._getData();if(!t)return null;const s=t.col,o=y(e,".js-mo-inverted")[0]||null,r=y(e,".js-mo-item:not(.js-mo-inverted)")[0]||null,i=m(r),a=m(o),u=m(e);let h=0,f=0;if(s>1){i.gppu>u.o+1&&(h=1),a.gppu>i.gppu&&(h=0);const g=e.previousElementSibling;g&&Math.abs(u.o-m(g).o)<40&&(f=1)}return{lr:h,badge_offset:f}}_createBadge(e,t){const s=this._getData(),o=document.createElement("span");if(o.className="mo-badge js-mo-badge",s.showCounterStyle==="none")o.style.opacity="0";else if(s.showCounterStyle==="image"){const r=document.createElement("img");r.className="mo-badge-icon",r.alt="",r.src=e.dataset.moIcon||b,o.appendChild(r)}else o.textContent=t;e.prepend(o)}_createItemElement(e){const t=document.createElement("li");e.icon&&(t.dataset.moIcon=e.icon);const s=document.createElement("div");if(s.className="mo-card",e.banner){const r=document.createElement("div");r.className="mo-card-image";const i=document.createElement("img");if(i.className="mo-banner",i.src=e.banner,i.alt="",r.appendChild(i),e.avatar){const a=document.createElement("img");a.className="mo-avatar",a.src=e.avatar,a.alt="",r.appendChild(a)}s.appendChild(r)}const o=document.createElement("div");if(o.className="mo-card-body",e.title){const r=document.createElement("h3");r.textContent=e.title,o.appendChild(r)}if(e.meta){const r=document.createElement("p");r.className="mo-meta",r.textContent=e.meta,o.appendChild(r)}if(e.text){const r=document.createElement("p");r.textContent=e.text,o.appendChild(r)}return s.appendChild(o),t.appendChild(s),t}_createArrow(e){const t=document.createElement("span");t.className="mo-arrow js-mo-arrow",e.prepend(t)}};p(c,"instances",new Set);let d=c;exports.MoTimeline=d;exports.default=d;
|
package/dist/moTimeline.css
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* moTimeline v2.
|
|
3
|
-
*/:root{--mo-line-color: #dde1e7;--mo-badge-bg: #4f46e5;--mo-badge-color: #fff;--mo-badge-size: 26px;--mo-badge-font-size: 12px;--mo-arrow-color: #dde1e7}.mo-timeline{display:block;list-style:none;margin:0;padding:0;position:relative;width:100%}.mo-timeline:after{content:"";display:table;clear:both}.mo-timeline.mo-twocol:before{background-color:var(--mo-line-color);bottom:0;content:"";left:50%;margin-left:-1.5px;position:absolute;top:0;width:3px;z-index:0}.mo-timeline>.mo-item{box-sizing:border-box;display:block;float:left;position:relative;width:50%}.mo-timeline:not(.mo-twocol)>.mo-item{float:none;width:100%}.mo-timeline>.mo-item.mo-inverted{float:right}.mo-badge{align-items:center;background:var(--mo-badge-bg);border-radius:50%;color:var(--mo-badge-color);display:flex;font-size:var(--mo-badge-font-size);font-weight:700;height:var(--mo-badge-size);justify-content:center;min-width:var(--mo-badge-size);overflow:hidden;position:absolute;top:18px;z-index:2}.mo-badge .mo-badge-icon{border-radius:50%;height:100%;object-fit:cover;width:100%}.mo-timeline.mo-twocol>.mo-item:not(.mo-inverted) .mo-badge{left:auto;right:calc(var(--mo-badge-size) / -2)}.mo-timeline.mo-twocol>.mo-item.mo-inverted .mo-badge{left:calc(var(--mo-badge-size) / -2);right:auto}.mo-timeline.mo-twocol>.mo-item.mo-offset .mo-badge{top:calc(18px + var(--mo-badge-size) + 10px)}.mo-timeline.mo-twocol>.mo-item.mo-offset .mo-arrow{top:calc(26px + var(--mo-badge-size) + 10px)}.mo-timeline:not(.mo-twocol)>.mo-item .mo-badge{display:none}.mo-arrow{border:8px solid transparent;display:block;height:0;position:absolute;top:26px;width:0;z-index:1}.mo-timeline.mo-twocol>.mo-item:not(.mo-inverted) .mo-arrow{border-left:8px solid var(--mo-arrow-color);border-right:none;left:auto;right:0}.mo-timeline.mo-twocol>.mo-item.mo-inverted .mo-arrow{border-right:8px solid var(--mo-arrow-color);border-left:none;left:0;right:auto}.mo-timeline:not(.mo-twocol)>.mo-item .mo-arrow{display:none}.mo-theme{--mo-arrow-color: #fff}.mo-theme>.mo-item .mo-card{background:#fff;border-radius:var(--mo-card-border-radius, 8px);box-shadow:0 2px 14px #0000001a;margin
|
|
2
|
+
* moTimeline v2.8.0 — CSS
|
|
3
|
+
*/:root{--mo-line-color: #dde1e7;--mo-badge-bg: #4f46e5;--mo-badge-color: #fff;--mo-badge-size: 26px;--mo-badge-font-size: 12px;--mo-arrow-color: #dde1e7}.mo-timeline{display:block;list-style:none;margin:0;padding:0;position:relative;width:100%}.mo-timeline:after{content:"";display:table;clear:both}.mo-timeline.mo-twocol:before{background-color:var(--mo-line-color);bottom:0;content:"";left:50%;margin-left:-1.5px;position:absolute;top:0;width:3px;z-index:0}.mo-timeline>.mo-item{box-sizing:border-box;display:block;float:left;position:relative;width:50%}.mo-timeline:not(.mo-twocol)>.mo-item{float:none;width:100%}.mo-timeline>.mo-item.mo-inverted{float:right}.mo-timeline.mo-twocol>.mo-item.mo-fullwidth{clear:both;float:none;width:100%}.mo-theme>.mo-item.mo-fullwidth .mo-card{margin:var(--mo-card-margin-fullwidth, .5rem)}.mo-timeline.mo-twocol>.mo-item.mo-fullwidth .mo-badge,.mo-timeline.mo-twocol>.mo-item.mo-fullwidth .mo-arrow{display:none}.mo-badge{align-items:center;background:var(--mo-badge-bg);border-radius:50%;color:var(--mo-badge-color);display:flex;font-size:var(--mo-badge-font-size);font-weight:700;height:var(--mo-badge-size);justify-content:center;min-width:var(--mo-badge-size);overflow:hidden;position:absolute;top:18px;z-index:2}.mo-badge .mo-badge-icon{border-radius:50%;height:100%;object-fit:cover;width:100%}.mo-timeline.mo-twocol>.mo-item:not(.mo-inverted) .mo-badge{left:auto;right:calc(var(--mo-badge-size) / -2)}.mo-timeline.mo-twocol>.mo-item.mo-inverted .mo-badge{left:calc(var(--mo-badge-size) / -2);right:auto}.mo-timeline.mo-twocol>.mo-item.mo-offset .mo-badge{top:calc(18px + var(--mo-badge-size) + 10px)}.mo-timeline.mo-twocol>.mo-item.mo-offset .mo-arrow{top:calc(26px + var(--mo-badge-size) + 10px)}.mo-timeline:not(.mo-twocol)>.mo-item .mo-badge{display:none}.mo-arrow{border:8px solid transparent;display:block;height:0;position:absolute;top:26px;width:0;z-index:1}.mo-timeline.mo-twocol>.mo-item:not(.mo-inverted) .mo-arrow{border-left:8px solid var(--mo-arrow-color);border-right:none;left:auto;right:0}.mo-timeline.mo-twocol>.mo-item.mo-inverted .mo-arrow{border-right:8px solid var(--mo-arrow-color);border-left:none;left:0;right:auto}.mo-timeline:not(.mo-twocol)>.mo-item .mo-arrow{display:none}.mo-theme{--mo-arrow-color: #fff}.mo-theme>.mo-item .mo-card{background:#fff;border-radius:var(--mo-card-border-radius, 8px);box-shadow:0 2px 14px #0000001a;margin:var(--mo-card-margin, .5rem 1.25rem .5rem .5rem);position:relative}.mo-theme>.mo-item.mo-inverted .mo-card{margin:var(--mo-card-margin-inverted, .5rem .5rem .5rem 1.25rem)}.mo-theme>.mo-item .mo-banner{border-radius:var(--mo-card-border-radius, 8px) var(--mo-card-border-radius, 8px) 0 0;display:block;max-height:240px;object-fit:cover;width:100%}.mo-theme>.mo-item .mo-card-image{overflow:visible;position:relative}.mo-theme>.mo-item .mo-avatar{border:3px solid #fff;border-radius:50%;bottom:calc(var(--mo-avatar-size, 50px) * -.44);box-shadow:0 2px 8px #0000002e;height:var(--mo-avatar-size, 50px);object-fit:cover;position:absolute;right:14px;width:var(--mo-avatar-size, 50px);z-index:1}.mo-theme>.mo-item .mo-card-body{padding:1.75rem 1rem 1rem}.mo-theme>.mo-item .mo-card-body h3{font-size:1rem;font-weight:700;margin:0 0 .3rem}.mo-theme>.mo-item .mo-card-body .mo-meta{color:#9ca3af;font-size:.75rem;margin-bottom:.5rem}.mo-theme>.mo-item .mo-card-body p{color:#6b7280;font-size:.875rem;line-height:1.55;margin:0}.mo-theme.mo-twocol>.mo-item:not(.mo-inverted) .mo-arrow{border-left-color:var(--mo-arrow-color);right:12px}.mo-theme.mo-twocol>.mo-item.mo-inverted .mo-arrow{border-right-color:var(--mo-arrow-color);left:12px}.mo-theme .mo-badge{background:#fff;border:2px solid var(--mo-line-color);box-shadow:0 2px 6px #0000001a;color:#374151}
|
package/dist/moTimeline.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var _ = (n, e, t) => e in n ? E(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var g = (n, e, t) => _(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
/*!
|
|
5
|
-
* moTimeline v2.
|
|
5
|
+
* moTimeline v2.8.0
|
|
6
6
|
* Responsive two-column timeline layout library
|
|
7
7
|
* https://github.com/MattOpen/moTimeline
|
|
8
8
|
* MIT License
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const l = /* @__PURE__ */ new WeakMap(), p = {
|
|
11
11
|
columnCount: { xs: 1, sm: 2, md: 2, lg: 2 },
|
|
12
12
|
showBadge: !1,
|
|
13
13
|
showArrow: !1,
|
|
@@ -15,51 +15,56 @@ const c = /* @__PURE__ */ new WeakMap(), g = {
|
|
|
15
15
|
showCounterStyle: "counter",
|
|
16
16
|
// 'counter' | 'image' | 'none'
|
|
17
17
|
cardBorderRadius: "8px",
|
|
18
|
-
avatarSize: "50px"
|
|
19
|
-
|
|
18
|
+
avatarSize: "50px",
|
|
19
|
+
cardMargin: "0.5rem 1.25rem 0.5rem 0.5rem",
|
|
20
|
+
cardMarginInverted: "0.5rem 0.5rem 0.5rem 1.25rem",
|
|
21
|
+
cardMarginFullWidth: "0.5rem",
|
|
22
|
+
randomFullWidth: 0
|
|
23
|
+
// 0 = off; 0–1 = probability per item; true = 0.33
|
|
24
|
+
}, b = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";
|
|
20
25
|
function v() {
|
|
21
|
-
const
|
|
22
|
-
return
|
|
26
|
+
const n = window.innerWidth;
|
|
27
|
+
return n < 600 ? "xs" : n < 992 ? "sm" : n < 1200 ? "md" : "lg";
|
|
23
28
|
}
|
|
24
|
-
function
|
|
29
|
+
function C(n, e = 100) {
|
|
25
30
|
let t;
|
|
26
|
-
return (...
|
|
27
|
-
clearTimeout(t), t = setTimeout(() =>
|
|
31
|
+
return (...s) => {
|
|
32
|
+
clearTimeout(t), t = setTimeout(() => n(...s), e);
|
|
28
33
|
};
|
|
29
34
|
}
|
|
30
|
-
function m(
|
|
31
|
-
return
|
|
32
|
-
o:
|
|
33
|
-
h:
|
|
34
|
-
gppu:
|
|
35
|
+
function m(n) {
|
|
36
|
+
return n ? {
|
|
37
|
+
o: n.offsetTop,
|
|
38
|
+
h: n.offsetHeight,
|
|
39
|
+
gppu: n.offsetTop + n.offsetHeight
|
|
35
40
|
} : { o: 0, h: 0, gppu: 0 };
|
|
36
41
|
}
|
|
37
|
-
function w(
|
|
42
|
+
function w(n, e) {
|
|
38
43
|
const t = [];
|
|
39
|
-
let
|
|
40
|
-
for (;
|
|
41
|
-
(!e ||
|
|
44
|
+
let s = n.previousElementSibling;
|
|
45
|
+
for (; s; )
|
|
46
|
+
(!e || s.matches(e)) && t.push(s), s = s.previousElementSibling;
|
|
42
47
|
return t;
|
|
43
48
|
}
|
|
44
|
-
const
|
|
49
|
+
const c = class c {
|
|
45
50
|
constructor(e, t = {}) {
|
|
46
51
|
if (typeof e == "string" && (e = document.querySelector(e)), !e) throw new Error("moTimeline: element not found");
|
|
47
|
-
this.element = e, this.settings = Object.assign({},
|
|
52
|
+
this.element = e, this.settings = Object.assign({}, p, t), this.settings.columnCount = Object.assign({}, p.columnCount, t.columnCount), this._resizeHandler = C(() => this.refresh(), 100), this._initialized = !1, this.init();
|
|
48
53
|
}
|
|
49
54
|
init() {
|
|
50
55
|
const e = this.element;
|
|
51
|
-
if (
|
|
56
|
+
if (l.has(e)) {
|
|
52
57
|
this.refresh();
|
|
53
58
|
return;
|
|
54
59
|
}
|
|
55
60
|
const t = Object.assign({}, this.settings, { lastItemIdx: 0 });
|
|
56
|
-
|
|
61
|
+
l.set(e, t), c.instances.add(this), e.classList.add("mo-timeline"), t.theme && e.classList.add("mo-theme"), e.style.setProperty("--mo-card-border-radius", t.cardBorderRadius), e.style.setProperty("--mo-avatar-size", t.avatarSize), e.style.setProperty("--mo-card-margin", t.cardMargin), e.style.setProperty("--mo-card-margin-inverted", t.cardMarginInverted), e.style.setProperty("--mo-card-margin-fullwidth", t.cardMarginFullWidth), this._initialized = !0, window.addEventListener("resize", this._resizeHandler), Array.from(e.children).length > 0 && this._initItems();
|
|
57
62
|
}
|
|
58
63
|
refresh() {
|
|
59
|
-
|
|
60
|
-
const t = e.element,
|
|
61
|
-
|
|
62
|
-
e._setPostPosition(
|
|
64
|
+
c.instances.forEach((e) => {
|
|
65
|
+
const t = e.element, s = l.get(t);
|
|
66
|
+
s && (s.col = s.columnCount[v()], e._setDivider(), Array.from(t.children).forEach((o) => {
|
|
67
|
+
e._setPostPosition(o);
|
|
63
68
|
}));
|
|
64
69
|
});
|
|
65
70
|
}
|
|
@@ -79,13 +84,13 @@ const l = class l {
|
|
|
79
84
|
typeof e == "string" && (e = JSON.parse(e)), e.forEach((t) => this.element.appendChild(this._createItemElement(t))), this._initItems();
|
|
80
85
|
}
|
|
81
86
|
destroy() {
|
|
82
|
-
window.removeEventListener("resize", this._resizeHandler),
|
|
83
|
-
e.classList.remove("mo-item", "js-mo-item", "mo-inverted", "js-mo-inverted", "mo-offset"), e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach((t) => t.remove());
|
|
87
|
+
window.removeEventListener("resize", this._resizeHandler), l.delete(this.element), c.instances.delete(this), this.element.style.removeProperty("--mo-card-border-radius"), this.element.style.removeProperty("--mo-avatar-size"), this.element.style.removeProperty("--mo-card-margin"), this.element.style.removeProperty("--mo-card-margin-inverted"), this.element.style.removeProperty("--mo-card-margin-fullwidth"), this.element.classList.remove("mo-timeline", "mo-theme", "mo-twocol"), Array.from(this.element.children).forEach((e) => {
|
|
88
|
+
e.classList.remove("mo-item", "js-mo-item", "mo-inverted", "js-mo-inverted", "mo-offset", "mo-fullwidth", "js-mo-fullwidth"), e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach((t) => t.remove());
|
|
84
89
|
});
|
|
85
90
|
}
|
|
86
91
|
// ─── Private ────────────────────────────────────────────────────────────────
|
|
87
92
|
_getData() {
|
|
88
|
-
return
|
|
93
|
+
return l.get(this.element);
|
|
89
94
|
}
|
|
90
95
|
_setDivider() {
|
|
91
96
|
const e = this._getData();
|
|
@@ -94,18 +99,30 @@ const l = class l {
|
|
|
94
99
|
_initItems() {
|
|
95
100
|
const e = this.element, t = this._getData();
|
|
96
101
|
if (!t) return;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const s = t.lastItemIdx, o = Array.from(e.children), r = o.slice(s);
|
|
103
|
+
if (r.length !== 0) {
|
|
104
|
+
if (r.forEach((i, a) => {
|
|
105
|
+
i.id || (i.id = "moT" + crypto.randomUUID() + "_" + (a + s)), i.classList.add("mo-item", "js-mo-item");
|
|
106
|
+
}), this._setDivider(), t.randomFullWidth) {
|
|
107
|
+
const i = t.randomFullWidth === !0 ? 0.33 : t.randomFullWidth;
|
|
108
|
+
r.forEach((a) => {
|
|
109
|
+
!a.classList.contains("mo-fullwidth") && Math.random() < i && a.classList.add("mo-fullwidth", "js-mo-fullwidth");
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
r.forEach((i, a) => {
|
|
113
|
+
t.showBadge && this._createBadge(i, a + s + 1), t.showArrow && this._createArrow(i);
|
|
114
|
+
}), t.lastItemIdx = o.length, l.set(e, t), this.refresh(), r.forEach((i) => {
|
|
115
|
+
i.querySelectorAll("img").forEach((a) => {
|
|
116
|
+
a.complete || a.addEventListener("load", this._resizeHandler, { once: !0 });
|
|
117
|
+
});
|
|
105
118
|
});
|
|
106
|
-
}
|
|
119
|
+
}
|
|
107
120
|
}
|
|
108
121
|
_setPostPosition(e) {
|
|
122
|
+
if (e.classList.contains("mo-fullwidth")) {
|
|
123
|
+
e.classList.remove("mo-inverted", "js-mo-inverted", "mo-offset");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
109
126
|
const t = this._getLeftOrRight(e);
|
|
110
127
|
t && (e.classList.toggle("mo-inverted", t.lr > 0), e.classList.toggle("js-mo-inverted", t.lr > 0), e.classList.toggle("mo-offset", t.badge_offset > 0));
|
|
111
128
|
}
|
|
@@ -113,63 +130,63 @@ const l = class l {
|
|
|
113
130
|
if (!e) return null;
|
|
114
131
|
const t = this._getData();
|
|
115
132
|
if (!t) return null;
|
|
116
|
-
const
|
|
133
|
+
const s = t.col, o = w(e, ".js-mo-inverted")[0] || null, r = w(e, ".js-mo-item:not(.js-mo-inverted)")[0] || null, i = m(r), a = m(o), h = m(e);
|
|
117
134
|
let d = 0, f = 0;
|
|
118
|
-
if (
|
|
119
|
-
|
|
135
|
+
if (s > 1) {
|
|
136
|
+
i.gppu > h.o + 1 && (d = 1), a.gppu > i.gppu && (d = 0);
|
|
120
137
|
const u = e.previousElementSibling;
|
|
121
138
|
u && Math.abs(h.o - m(u).o) < 40 && (f = 1);
|
|
122
139
|
}
|
|
123
140
|
return { lr: d, badge_offset: f };
|
|
124
141
|
}
|
|
125
142
|
_createBadge(e, t) {
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
else if (
|
|
130
|
-
const
|
|
131
|
-
|
|
143
|
+
const s = this._getData(), o = document.createElement("span");
|
|
144
|
+
if (o.className = "mo-badge js-mo-badge", s.showCounterStyle === "none")
|
|
145
|
+
o.style.opacity = "0";
|
|
146
|
+
else if (s.showCounterStyle === "image") {
|
|
147
|
+
const r = document.createElement("img");
|
|
148
|
+
r.className = "mo-badge-icon", r.alt = "", r.src = e.dataset.moIcon || b, o.appendChild(r);
|
|
132
149
|
} else
|
|
133
|
-
|
|
134
|
-
e.prepend(
|
|
150
|
+
o.textContent = t;
|
|
151
|
+
e.prepend(o);
|
|
135
152
|
}
|
|
136
153
|
_createItemElement(e) {
|
|
137
154
|
const t = document.createElement("li");
|
|
138
155
|
e.icon && (t.dataset.moIcon = e.icon);
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
const
|
|
146
|
-
|
|
156
|
+
const s = document.createElement("div");
|
|
157
|
+
if (s.className = "mo-card", e.banner) {
|
|
158
|
+
const r = document.createElement("div");
|
|
159
|
+
r.className = "mo-card-image";
|
|
160
|
+
const i = document.createElement("img");
|
|
161
|
+
if (i.className = "mo-banner", i.src = e.banner, i.alt = "", r.appendChild(i), e.avatar) {
|
|
162
|
+
const a = document.createElement("img");
|
|
163
|
+
a.className = "mo-avatar", a.src = e.avatar, a.alt = "", r.appendChild(a);
|
|
147
164
|
}
|
|
148
|
-
|
|
165
|
+
s.appendChild(r);
|
|
149
166
|
}
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
const
|
|
153
|
-
|
|
167
|
+
const o = document.createElement("div");
|
|
168
|
+
if (o.className = "mo-card-body", e.title) {
|
|
169
|
+
const r = document.createElement("h3");
|
|
170
|
+
r.textContent = e.title, o.appendChild(r);
|
|
154
171
|
}
|
|
155
172
|
if (e.meta) {
|
|
156
|
-
const
|
|
157
|
-
|
|
173
|
+
const r = document.createElement("p");
|
|
174
|
+
r.className = "mo-meta", r.textContent = e.meta, o.appendChild(r);
|
|
158
175
|
}
|
|
159
176
|
if (e.text) {
|
|
160
|
-
const
|
|
161
|
-
|
|
177
|
+
const r = document.createElement("p");
|
|
178
|
+
r.textContent = e.text, o.appendChild(r);
|
|
162
179
|
}
|
|
163
|
-
return
|
|
180
|
+
return s.appendChild(o), t.appendChild(s), t;
|
|
164
181
|
}
|
|
165
182
|
_createArrow(e) {
|
|
166
183
|
const t = document.createElement("span");
|
|
167
184
|
t.className = "mo-arrow js-mo-arrow", e.prepend(t);
|
|
168
185
|
}
|
|
169
186
|
};
|
|
170
|
-
|
|
171
|
-
let
|
|
187
|
+
g(c, "instances", /* @__PURE__ */ new Set());
|
|
188
|
+
let y = c;
|
|
172
189
|
export {
|
|
173
|
-
|
|
174
|
-
|
|
190
|
+
y as MoTimeline,
|
|
191
|
+
y as default
|
|
175
192
|
};
|
package/dist/moTimeline.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
* moTimeline v2.
|
|
1
|
+
(function(l,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(l=typeof globalThis<"u"?globalThis:l||self,n(l.MoTimeline={}))})(this,function(l){"use strict";var C=Object.defineProperty;var I=(l,n,d)=>n in l?C(l,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[n]=d;var E=(l,n,d)=>I(l,typeof n!="symbol"?n+"":n,d);/*!
|
|
2
|
+
* moTimeline v2.8.0
|
|
3
3
|
* Responsive two-column timeline layout library
|
|
4
4
|
* https://github.com/MattOpen/moTimeline
|
|
5
5
|
* MIT License
|
|
6
|
-
*/const
|
|
6
|
+
*/const n=new WeakMap,d={columnCount:{xs:1,sm:2,md:2,lg:2},showBadge:!1,showArrow:!1,theme:!1,showCounterStyle:"counter",cardBorderRadius:"8px",avatarSize:"50px",cardMargin:"0.5rem 1.25rem 0.5rem 0.5rem",cardMarginInverted:"0.5rem 0.5rem 0.5rem 1.25rem",cardMarginFullWidth:"0.5rem",randomFullWidth:0},_="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";function g(){const c=window.innerWidth;return c<600?"xs":c<992?"sm":c<1200?"md":"lg"}function b(c,e=100){let t;return(...r)=>{clearTimeout(t),t=setTimeout(()=>c(...r),e)}}function h(c){return c?{o:c.offsetTop,h:c.offsetHeight,gppu:c.offsetTop+c.offsetHeight}:{o:0,h:0,gppu:0}}function p(c,e){const t=[];let r=c.previousElementSibling;for(;r;)(!e||r.matches(e))&&t.push(r),r=r.previousElementSibling;return t}const m=class m{constructor(e,t={}){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("moTimeline: element not found");this.element=e,this.settings=Object.assign({},d,t),this.settings.columnCount=Object.assign({},d.columnCount,t.columnCount),this._resizeHandler=b(()=>this.refresh(),100),this._initialized=!1,this.init()}init(){const e=this.element;if(n.has(e)){this.refresh();return}const t=Object.assign({},this.settings,{lastItemIdx:0});n.set(e,t),m.instances.add(this),e.classList.add("mo-timeline"),t.theme&&e.classList.add("mo-theme"),e.style.setProperty("--mo-card-border-radius",t.cardBorderRadius),e.style.setProperty("--mo-avatar-size",t.avatarSize),e.style.setProperty("--mo-card-margin",t.cardMargin),e.style.setProperty("--mo-card-margin-inverted",t.cardMarginInverted),e.style.setProperty("--mo-card-margin-fullwidth",t.cardMarginFullWidth),this._initialized=!0,window.addEventListener("resize",this._resizeHandler),Array.from(e.children).length>0&&this._initItems()}refresh(){m.instances.forEach(e=>{const t=e.element,r=n.get(t);r&&(r.col=r.columnCount[g()],e._setDivider(),Array.from(t.children).forEach(o=>{e._setPostPosition(o)}))})}initNewItems(){this._initItems()}addItems(e){typeof e=="string"&&(e=JSON.parse(e)),e.forEach(t=>this.element.appendChild(this._createItemElement(t))),this._initItems()}destroy(){window.removeEventListener("resize",this._resizeHandler),n.delete(this.element),m.instances.delete(this),this.element.style.removeProperty("--mo-card-border-radius"),this.element.style.removeProperty("--mo-avatar-size"),this.element.style.removeProperty("--mo-card-margin"),this.element.style.removeProperty("--mo-card-margin-inverted"),this.element.style.removeProperty("--mo-card-margin-fullwidth"),this.element.classList.remove("mo-timeline","mo-theme","mo-twocol"),Array.from(this.element.children).forEach(e=>{e.classList.remove("mo-item","js-mo-item","mo-inverted","js-mo-inverted","mo-offset","mo-fullwidth","js-mo-fullwidth"),e.querySelectorAll(".js-mo-badge, .js-mo-arrow").forEach(t=>t.remove())})}_getData(){return n.get(this.element)}_setDivider(){const e=this._getData();e&&(e.col=e.columnCount[g()],this.element.classList.toggle("mo-twocol",e.col>1))}_initItems(){const e=this.element,t=this._getData();if(!t)return;const r=t.lastItemIdx,o=Array.from(e.children),s=o.slice(r);if(s.length!==0){if(s.forEach((i,a)=>{i.id||(i.id="moT"+crypto.randomUUID()+"_"+(a+r)),i.classList.add("mo-item","js-mo-item")}),this._setDivider(),t.randomFullWidth){const i=t.randomFullWidth===!0?.33:t.randomFullWidth;s.forEach(a=>{!a.classList.contains("mo-fullwidth")&&Math.random()<i&&a.classList.add("mo-fullwidth","js-mo-fullwidth")})}s.forEach((i,a)=>{t.showBadge&&this._createBadge(i,a+r+1),t.showArrow&&this._createArrow(i)}),t.lastItemIdx=o.length,n.set(e,t),this.refresh(),s.forEach(i=>{i.querySelectorAll("img").forEach(a=>{a.complete||a.addEventListener("load",this._resizeHandler,{once:!0})})})}}_setPostPosition(e){if(e.classList.contains("mo-fullwidth")){e.classList.remove("mo-inverted","js-mo-inverted","mo-offset");return}const t=this._getLeftOrRight(e);t&&(e.classList.toggle("mo-inverted",t.lr>0),e.classList.toggle("js-mo-inverted",t.lr>0),e.classList.toggle("mo-offset",t.badge_offset>0))}_getLeftOrRight(e){if(!e)return null;const t=this._getData();if(!t)return null;const r=t.col,o=p(e,".js-mo-inverted")[0]||null,s=p(e,".js-mo-item:not(.js-mo-inverted)")[0]||null,i=h(s),a=h(o),v=h(e);let u=0,w=0;if(r>1){i.gppu>v.o+1&&(u=1),a.gppu>i.gppu&&(u=0);const y=e.previousElementSibling;y&&Math.abs(v.o-h(y).o)<40&&(w=1)}return{lr:u,badge_offset:w}}_createBadge(e,t){const r=this._getData(),o=document.createElement("span");if(o.className="mo-badge js-mo-badge",r.showCounterStyle==="none")o.style.opacity="0";else if(r.showCounterStyle==="image"){const s=document.createElement("img");s.className="mo-badge-icon",s.alt="",s.src=e.dataset.moIcon||_,o.appendChild(s)}else o.textContent=t;e.prepend(o)}_createItemElement(e){const t=document.createElement("li");e.icon&&(t.dataset.moIcon=e.icon);const r=document.createElement("div");if(r.className="mo-card",e.banner){const s=document.createElement("div");s.className="mo-card-image";const i=document.createElement("img");if(i.className="mo-banner",i.src=e.banner,i.alt="",s.appendChild(i),e.avatar){const a=document.createElement("img");a.className="mo-avatar",a.src=e.avatar,a.alt="",s.appendChild(a)}r.appendChild(s)}const o=document.createElement("div");if(o.className="mo-card-body",e.title){const s=document.createElement("h3");s.textContent=e.title,o.appendChild(s)}if(e.meta){const s=document.createElement("p");s.className="mo-meta",s.textContent=e.meta,o.appendChild(s)}if(e.text){const s=document.createElement("p");s.textContent=e.text,o.appendChild(s)}return r.appendChild(o),t.appendChild(r),t}_createArrow(e){const t=document.createElement("span");t.className="mo-arrow js-mo-arrow",e.prepend(t)}};E(m,"instances",new Set);let f=m;l.MoTimeline=f,l.default=f,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
package/src/moTimeline.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* moTimeline v2.
|
|
2
|
+
* moTimeline v2.8.0 — CSS
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/* ── CSS custom properties (easy override) ─────────────────── */
|
|
@@ -64,6 +64,24 @@
|
|
|
64
64
|
float: right;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/* Full-width item — spans both columns (two-column mode only) */
|
|
68
|
+
.mo-timeline.mo-twocol > .mo-item.mo-fullwidth {
|
|
69
|
+
clear: both;
|
|
70
|
+
float: none;
|
|
71
|
+
width: 100%;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Full-width card: equal margin on both sides (no center-line gap) */
|
|
75
|
+
.mo-theme > .mo-item.mo-fullwidth .mo-card {
|
|
76
|
+
margin: var(--mo-card-margin-fullwidth, 0.5rem);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Hide badge & arrow for full-width items — no center-line interaction */
|
|
80
|
+
.mo-timeline.mo-twocol > .mo-item.mo-fullwidth .mo-badge,
|
|
81
|
+
.mo-timeline.mo-twocol > .mo-item.mo-fullwidth .mo-arrow {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
67
85
|
/* ── Badge — circle sitting ON the center line ──────────────── */
|
|
68
86
|
|
|
69
87
|
.mo-badge {
|
|
@@ -165,12 +183,12 @@
|
|
|
165
183
|
background: #fff;
|
|
166
184
|
border-radius: var(--mo-card-border-radius, 8px);
|
|
167
185
|
box-shadow: 0 2px 14px rgba(0, 0, 0, .10);
|
|
168
|
-
margin: 0.5rem 1.25rem 0.5rem 0.5rem;
|
|
186
|
+
margin: var(--mo-card-margin, 0.5rem 1.25rem 0.5rem 0.5rem);
|
|
169
187
|
position: relative;
|
|
170
188
|
}
|
|
171
189
|
|
|
172
190
|
.mo-theme > .mo-item.mo-inverted .mo-card {
|
|
173
|
-
margin: 0.5rem 0.5rem 0.5rem 1.25rem;
|
|
191
|
+
margin: var(--mo-card-margin-inverted, 0.5rem 0.5rem 0.5rem 1.25rem);
|
|
174
192
|
}
|
|
175
193
|
|
|
176
194
|
/* Banner image — top corners rounded to match card, no overflow:hidden needed on card */
|
package/src/moTimeline.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* moTimeline v2.
|
|
2
|
+
* moTimeline v2.8.0
|
|
3
3
|
* Responsive two-column timeline layout library
|
|
4
4
|
* https://github.com/MattOpen/moTimeline
|
|
5
5
|
* MIT License
|
|
@@ -18,6 +18,10 @@ const DEFAULTS = {
|
|
|
18
18
|
showCounterStyle: 'counter', // 'counter' | 'image' | 'none'
|
|
19
19
|
cardBorderRadius: '8px',
|
|
20
20
|
avatarSize: '50px',
|
|
21
|
+
cardMargin: '0.5rem 1.25rem 0.5rem 0.5rem',
|
|
22
|
+
cardMarginInverted: '0.5rem 0.5rem 0.5rem 1.25rem',
|
|
23
|
+
cardMarginFullWidth: '0.5rem',
|
|
24
|
+
randomFullWidth: 0, // 0 = off; 0–1 = probability per item; true = 0.33
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
const DEFAULT_BADGE_ICON = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='11' fill='%234f46e5'/><circle cx='12' cy='12' r='4.5' fill='white'/></svg>";
|
|
@@ -92,6 +96,9 @@ export class MoTimeline {
|
|
|
92
96
|
if (data.theme) el.classList.add('mo-theme');
|
|
93
97
|
el.style.setProperty('--mo-card-border-radius', data.cardBorderRadius);
|
|
94
98
|
el.style.setProperty('--mo-avatar-size', data.avatarSize);
|
|
99
|
+
el.style.setProperty('--mo-card-margin', data.cardMargin);
|
|
100
|
+
el.style.setProperty('--mo-card-margin-inverted', data.cardMarginInverted);
|
|
101
|
+
el.style.setProperty('--mo-card-margin-fullwidth', data.cardMarginFullWidth);
|
|
95
102
|
|
|
96
103
|
this._initialized = true;
|
|
97
104
|
window.addEventListener('resize', this._resizeHandler);
|
|
@@ -141,9 +148,12 @@ export class MoTimeline {
|
|
|
141
148
|
MoTimeline.instances.delete(this);
|
|
142
149
|
this.element.style.removeProperty('--mo-card-border-radius');
|
|
143
150
|
this.element.style.removeProperty('--mo-avatar-size');
|
|
151
|
+
this.element.style.removeProperty('--mo-card-margin');
|
|
152
|
+
this.element.style.removeProperty('--mo-card-margin-inverted');
|
|
153
|
+
this.element.style.removeProperty('--mo-card-margin-fullwidth');
|
|
144
154
|
this.element.classList.remove('mo-timeline', 'mo-theme', 'mo-twocol');
|
|
145
155
|
Array.from(this.element.children).forEach((child) => {
|
|
146
|
-
child.classList.remove('mo-item', 'js-mo-item', 'mo-inverted', 'js-mo-inverted', 'mo-offset');
|
|
156
|
+
child.classList.remove('mo-item', 'js-mo-item', 'mo-inverted', 'js-mo-inverted', 'mo-offset', 'mo-fullwidth', 'js-mo-fullwidth');
|
|
147
157
|
child.querySelectorAll('.js-mo-badge, .js-mo-arrow').forEach((b) => b.remove());
|
|
148
158
|
});
|
|
149
159
|
}
|
|
@@ -182,6 +192,16 @@ export class MoTimeline {
|
|
|
182
192
|
|
|
183
193
|
this._setDivider();
|
|
184
194
|
|
|
195
|
+
// Random full-width assignment
|
|
196
|
+
if (data.randomFullWidth) {
|
|
197
|
+
const prob = data.randomFullWidth === true ? 0.33 : data.randomFullWidth;
|
|
198
|
+
newItems.forEach((item) => {
|
|
199
|
+
if (!item.classList.contains('mo-fullwidth') && Math.random() < prob) {
|
|
200
|
+
item.classList.add('mo-fullwidth', 'js-mo-fullwidth');
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
185
205
|
// Badges / arrows
|
|
186
206
|
newItems.forEach((item, i) => {
|
|
187
207
|
if (data.showBadge) {
|
|
@@ -209,6 +229,12 @@ export class MoTimeline {
|
|
|
209
229
|
}
|
|
210
230
|
|
|
211
231
|
_setPostPosition(el) {
|
|
232
|
+
// Full-width items span both columns — skip column assignment
|
|
233
|
+
if (el.classList.contains('mo-fullwidth')) {
|
|
234
|
+
el.classList.remove('mo-inverted', 'js-mo-inverted', 'mo-offset');
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
212
238
|
const result = this._getLeftOrRight(el);
|
|
213
239
|
if (!result) return;
|
|
214
240
|
|