svelte-tv 1.0.2 → 1.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.
@@ -129,6 +129,33 @@ const EFFECT_SHADER_KEYS = [
129
129
  'borderLeft',
130
130
  'shadow',
131
131
  ];
132
+ function getBoxValue(value, index, defaultValue = 0) {
133
+ if (value === undefined)
134
+ return defaultValue;
135
+ if (typeof value === 'number')
136
+ return value;
137
+ const len = value.length;
138
+ const result = len === 2
139
+ ? index % 2 === 0
140
+ ? value[0]
141
+ : value[1]
142
+ : len === 3
143
+ ? index === 0
144
+ ? value[0]
145
+ : index === 2
146
+ ? value[2]
147
+ : value[1]
148
+ : value[index];
149
+ return result ?? defaultValue;
150
+ }
151
+ function getPadding(node) {
152
+ return {
153
+ top: node.paddingTop ?? getBoxValue(node.padding, 0),
154
+ right: node.paddingRight ?? getBoxValue(node.padding, 1),
155
+ bottom: node.paddingBottom ?? getBoxValue(node.padding, 2),
156
+ left: node.paddingLeft ?? getBoxValue(node.padding, 3),
157
+ };
158
+ }
132
159
  const parseAndAssignShaderProps = (prefix, obj, props = {}) => {
133
160
  if (!obj)
134
161
  return;
@@ -1069,8 +1096,13 @@ export class ElementNode {
1069
1096
  const props = node.lng;
1070
1097
  const parentWidth = parent.w || 0;
1071
1098
  const parentHeight = parent.h || 0;
1072
- props.x = props.x || 0;
1073
- props.y = props.y || 0;
1099
+ const parentPadding = parent.display === 'flex' ? undefined : getPadding(parent);
1100
+ if (props.x === undefined) {
1101
+ props.x = parentPadding?.left ?? 0;
1102
+ }
1103
+ if (props.y === undefined) {
1104
+ props.y = parentPadding?.top ?? 0;
1105
+ }
1074
1106
  props.parent = parent.lng;
1075
1107
  if (this.right || this.right === 0) {
1076
1108
  props.x = parentWidth - this.right;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-tv",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Svelte speed for every screen 🚀✨",
5
5
  "type": "module",
6
6
  "exports": {
@@ -40,8 +40,11 @@
40
40
  "lint:fix": "prettier --write \"**/*.{svelte,ts,js,json,md}\"",
41
41
  "test": "vitest",
42
42
  "build:playground": "vite build playground --config ./vite.config.ts",
43
+ "build:playground:lab": "vite build playground-lab --config ./playground-lab/vite.config.ts",
43
44
  "preview": "vite preview playground --config ./vite.config.ts --host 0.0.0.0 --port 4173 --strictPort",
44
- "dev": "vite dev playground --config ./vite.config.ts --host 0.0.0.0 --port 5173 --strictPort"
45
+ "preview:lab": "vite preview playground-lab --config ./playground-lab/vite.config.ts --host 0.0.0.0 --port 4175 --strictPort",
46
+ "dev": "vite dev playground --config ./vite.config.ts --host 0.0.0.0 --port 5173",
47
+ "dev:lab": "vite dev playground-lab --config ./playground-lab/vite.config.ts --host 0.0.0.0 --port 5175 --strictPort"
45
48
  },
46
49
  "keywords": [
47
50
  "svelte",