Skip to content

Commit 1c36aa1

Browse files
committed
[css-properties-values-api] Fix example.
1 parent 21c0bd3 commit 1c36aa1

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

css-properties-values-api/Overview.bs

+28-21
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ the following attributes:
290290

291291
Issue(73): Do we need the pseudo attribute on ElementProxy for level 1?
292292

293+
Issue(74): Come up with a better name than ElementProxy. This is more of a computation context.
294+
293295
The {{ApplyDescriptor}} dictionary {#the-applydescriptor-dictionary}
294296
--------------------------------------------------------------------
295297

@@ -422,33 +424,31 @@ Examples {#examples}
422424
Example 1: Polyfill scale, translate, rotate {#example-1}
423425
---------------------------------------------------------
424426

425-
This approach prohibits the direct use of the transform property.
426-
427427
<pre class='lang-markup'>
428428
&lt;script&gt;
429-
["--scale-x", "--scale-y"].forEach(function(prop){
429+
["--scale-x", "--scale-y"].forEach(function(name) {
430430
document.registerProperty({
431-
name: prop,
431+
name: name,
432+
syntax: "&lt;number&gt;",
432433
inherits: false,
433-
initial: 1,
434-
syntax: "&lt;number&gt;"
435-
});
434+
initialValue: "1"
435+
});
436436
});
437437

438438
["--translate-x", "--translate-y"].forEach(function(name) {
439439
document.registerProperty({
440440
name: name,
441-
initial: "0px",
441+
syntax: "&lt;length&gt;",
442442
inherits: false,
443-
syntax: "&lt;length&gt;"
443+
initialValue: "0px"
444444
});
445445
});
446446

447447
document.registerProperty({
448448
name: "--rotate",
449-
initial: "0deg",
450-
syntax: "&lt;angle&gt;"
451-
inherits: false
449+
syntax: "&lt;angle&gt;",
450+
inherits: false,
451+
initialValue: "0deg"
452452
});
453453
&lt;/script&gt;
454454
&lt;style&gt;
@@ -467,15 +467,22 @@ document.registerProperty({
467467
&lt;/style&gt;
468468

469469
&lt;script&gt;
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+
}
479486
});
480487
&lt;/script&gt;
481488
</pre>

0 commit comments

Comments
 (0)