chnobli 0.1.3 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chnobli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "author": "Sören Meier <info@soerenmeier.ch>",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -144,8 +144,8 @@ export class TransformXY extends Property {
144
144
  }
145
145
 
146
146
  getValue(target) {
147
- const x = target.getTransformValue('translateX');
148
- const y = target.getTransformValue('translateY');
147
+ const x = target.getTransformValue('x');
148
+ const y = target.getTransformValue('y');
149
149
 
150
150
  const def = this.defaultValue();
151
151
 
@@ -156,13 +156,13 @@ export class TransformXY extends Property {
156
156
  }
157
157
 
158
158
  setValue(target, val) {
159
- target.setTransformValue('translateX', val.x.withDefaultUnit('px'));
160
- target.setTransformValue('translateY', val.y.withDefaultUnit('px'));
159
+ target.setTransformValue('x', val.x.withDefaultUnit('px'));
160
+ target.setTransformValue('y', val.y.withDefaultUnit('px'));
161
161
  }
162
162
 
163
163
  removeValue(target) {
164
- target.removeTransformValue('translateX');
165
- target.removeTransformValue('translateY');
164
+ target.removeTransformValue('x');
165
+ target.removeTransformValue('y');
166
166
  }
167
167
  }
168
168
 
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
2
2
  import TestTicker from '../timing/testticker.js';
3
3
  import TestResponsiveEvent from '../responsive/testevent.js';
4
4
  import { animate, timeline } from '../chnobli.js';
5
- import { responsive } from '../utils/utils.js';
5
+ import { responsive, curve } from '../utils/utils.js';
6
6
  import { el } from '../target/testdomnode.js';
7
7
  import { timeout } from 'fire/util.js';
8
8
 
@@ -147,4 +147,32 @@ describe('properties', () => {
147
147
  respEv.resize();
148
148
  expect(div.style.width).toBe('33.333px');
149
149
  });
150
+
151
+ it('xy', () => {
152
+ const ticker = new TestTicker;
153
+
154
+ const div = el();
155
+ const tl = timeline()
156
+ .add(div, {
157
+ xy: curve([
158
+ { x: 0, y: 10 },
159
+ { x: 100, y: 10 },
160
+ { x: 50, y: 20 }
161
+ ]),
162
+ duration: 10
163
+ });
164
+
165
+ tl.play();
166
+ ticker.run(0);
167
+ expect(div.style.transform)
168
+ .toBe('translate3d(0.000px,10.000px,0.000px)');
169
+
170
+ ticker.run(5);
171
+ expect(div.style.transform)
172
+ .toBe('translate3d(100.000px,10.000px,0.000px)');
173
+
174
+ ticker.run();
175
+ expect(div.style.transform)
176
+ .toBe('translate3d(50.000px,20.000px,0.000px)');
177
+ });
150
178
  });