@markdy/renderer-dom 0.5.0 → 0.5.1
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/index.d.ts +2 -0
- package/dist/index.js +28 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ interface PlayerOptions {
|
|
|
26
26
|
autoplay?: boolean;
|
|
27
27
|
/** Loop the animation when it reaches the end. Defaults to true. */
|
|
28
28
|
loop?: boolean;
|
|
29
|
+
/** Show a small "Powered by Markdy" badge below the animation. Defaults to true. */
|
|
30
|
+
copyright?: boolean;
|
|
29
31
|
}
|
|
30
32
|
interface Player {
|
|
31
33
|
play(): void;
|
package/dist/index.js
CHANGED
|
@@ -637,7 +637,7 @@ function buildAction(ev, el, s, baseOpts, delayMs, durMs, ast, states, scene, as
|
|
|
637
637
|
|
|
638
638
|
// src/player.ts
|
|
639
639
|
function createPlayer(opts) {
|
|
640
|
-
const { container, code, assets: assetOverrides = {}, autoplay = true, loop = true } = opts;
|
|
640
|
+
const { container, code, assets: assetOverrides = {}, autoplay = true, loop = true, copyright = true } = opts;
|
|
641
641
|
const ast = parse(code);
|
|
642
642
|
const viewport = document.createElement("div");
|
|
643
643
|
Object.assign(viewport.style, {
|
|
@@ -647,6 +647,32 @@ function createPlayer(opts) {
|
|
|
647
647
|
overflow: "hidden"
|
|
648
648
|
});
|
|
649
649
|
container.appendChild(viewport);
|
|
650
|
+
let badge = null;
|
|
651
|
+
if (copyright) {
|
|
652
|
+
badge = document.createElement("a");
|
|
653
|
+
badge.href = "https://markdy.com";
|
|
654
|
+
badge.target = "_blank";
|
|
655
|
+
badge.rel = "noopener noreferrer";
|
|
656
|
+
badge.textContent = "Powered by Markdy";
|
|
657
|
+
Object.assign(badge.style, {
|
|
658
|
+
display: "block",
|
|
659
|
+
textAlign: "right",
|
|
660
|
+
fontSize: "10px",
|
|
661
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
662
|
+
color: "#999",
|
|
663
|
+
textDecoration: "none",
|
|
664
|
+
padding: "3px 6px 0",
|
|
665
|
+
opacity: "0.7",
|
|
666
|
+
transition: "opacity 0.2s"
|
|
667
|
+
});
|
|
668
|
+
badge.addEventListener("mouseenter", () => {
|
|
669
|
+
badge.style.opacity = "1";
|
|
670
|
+
});
|
|
671
|
+
badge.addEventListener("mouseleave", () => {
|
|
672
|
+
badge.style.opacity = "0.7";
|
|
673
|
+
});
|
|
674
|
+
container.appendChild(badge);
|
|
675
|
+
}
|
|
650
676
|
const scene = document.createElement("div");
|
|
651
677
|
Object.assign(scene.style, {
|
|
652
678
|
position: "absolute",
|
|
@@ -760,6 +786,7 @@ function createPlayer(opts) {
|
|
|
760
786
|
player.pause();
|
|
761
787
|
for (const anim of allAnims) anim.cancel();
|
|
762
788
|
resizeObserver.disconnect();
|
|
789
|
+
if (badge?.parentNode === container) container.removeChild(badge);
|
|
763
790
|
if (viewport.parentNode === container) container.removeChild(viewport);
|
|
764
791
|
}
|
|
765
792
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Web Animations API renderer for MarkdyScript scenes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@markdy/core": "0.5.
|
|
46
|
+
"@markdy/core": "0.5.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.5.1",
|