@@ -290,6 +290,8 @@ the following attributes:
290
290
291
291
Issue(73): Do we need the pseudo attribute on ElementProxy for level 1?
292
292
293
+ Issue(74): Come up with a better name than ElementProxy. This is more of a computation context.
294
+
293
295
The {{ApplyDescriptor}} dictionary {#the-applydescriptor-dictionary}
294
296
--------------------------------------------------------------------
295
297
@@ -422,33 +424,31 @@ Examples {#examples}
422
424
Example 1: Polyfill scale, translate, rotate {#example-1}
423
425
---------------------------------------------------------
424
426
425
- This approach prohibits the direct use of the transform property.
426
-
427
427
<pre class='lang-markup'>
428
428
<script>
429
- ["--scale-x", "--scale-y"] .forEach(function(prop) {
429
+ ["--scale-x", "--scale-y"] .forEach(function(name) {
430
430
document.registerProperty({
431
- name: prop,
431
+ name: name,
432
+ syntax: "<number>",
432
433
inherits: false,
433
- initial: 1,
434
- syntax: "<number>"
435
- });
434
+ initialValue: "1"
435
+ });
436
436
});
437
437
438
438
["--translate-x", "--translate-y"] .forEach(function(name) {
439
439
document.registerProperty({
440
440
name: name,
441
- initial : "0px ",
441
+ syntax : "<length> ",
442
442
inherits: false,
443
- syntax : "<length> "
443
+ initialValue : "0px "
444
444
});
445
445
});
446
446
447
447
document.registerProperty({
448
448
name: "--rotate",
449
- initial : "0deg ",
450
- syntax: "<angle>"
451
- inherits: false
449
+ syntax : "<angle> ",
450
+ inherits: false,
451
+ initialValue: "0deg"
452
452
});
453
453
</script>
454
454
<style>
@@ -467,15 +467,22 @@ document.registerProperty({
467
467
</style>
468
468
469
469
<script>
470
- this.registerApplyHook({
471
- apply: function(el) {
472
- el.outputStyle.transform = 'translate(' + el.style.get('--translate-x' ) + ', ' + el.style.get('--translate-y' ) +
473
- ') rotate(' + el.style.get('--rotate' ) +
474
- ') scale(' + el.style.get('--scale-x' ) + ', ' + el.style.get('--scale-y' ) + ')' +
475
- el.style.get('transform' );
476
- },
477
- inputProperties: ["--translate-*", "--scale-*", "--rotate", "transform"] ,
478
- outputProperties: ["transform"]
470
+ this.registerApplyHook("transform-properties", class {
471
+ apply(el) {
472
+ el.outputStyle.set('transform' , new TransformValue(
473
+ [
474
+ new Translation(el.inputStyle.get('--translate-x' ),
475
+ el.inputStyle.get('--translate-y' )),
476
+ new Rotation(el.inputStyle.get('--rotate' )),
477
+ new Scale(el.inputStyle.get('--scale-x' ),
478
+ el.inputStyle.get('--scale-y' ))
479
+ ].concat(el.inputStyle.get('transform' ))));
480
+ }}, {
481
+ inputProperties: ["--translate-x", "--translate-y",
482
+ "--scale-x", "--scale-y",
483
+ "--rotate", "transform"],
484
+ outputProperties: ["transform"]
485
+ }
479
486
});
480
487
</script>
481
488
</pre>
0 commit comments