@@ -497,6 +497,7 @@ enum Edge { "start", "end" };
497
497
dictionary ElementBasedOffset {
498
498
Element target;
499
499
Edge edge = "start";
500
+ double threshold = 0.0;
500
501
};
501
502
</pre>
502
503
@@ -505,17 +506,18 @@ dictionary ElementBasedOffset {
505
506
506
507
: <dfn dict-member for=ElementBasedOffset>target</dfn>
507
508
:: The target whose intersection with {{source}} 's [=scrolling box=] determines
508
- the concrete scroll offset.
509
+ the concrete scroll offset.
509
510
510
511
: <dfn dict-member for=ElementBasedOffset>edge</dfn>
511
- :: The edge of {{source}} 's [=scrolling box=] which the target should
512
- intersect with.
513
-
514
- </div>
512
+ :: The edge of {{source}} 's [=scrolling box=] in the direction specified by
513
+ the {{orientation}} which the target should intersect with.
515
514
515
+ : <dfn dict-member for=ElementBasedOffset>threshold</dfn>
516
+ :: A double in the range of [0.0, 1.0] that represent the precentage
517
+ of the target that is expected to be visible in {{source}} 's [=scrollport=]
518
+ at the intersection offset.
516
519
517
- Issue: TODO: Add threshold value that allows authors to control how much of the
518
- target should become visible within scrollport.
520
+ </div>
519
521
520
522
521
523
The procedure to <dfn>resolve a element-based offset</dfn> given
@@ -550,17 +552,48 @@ The procedure to <dfn>resolve a element-based offset</dfn> given
550
552
with the <var> target box</var> 's start edge in the axis and direction
551
553
determined by {{orientation}} .
552
554
555
+ 1. Let <var> threshold amount</var> be the result of evaluating the following
556
+ expression where <var> target dimension</var> is <var> target box</var> 's dimension in the axis
557
+ determined by {{orientation}} .
558
+ <blockquote>
559
+ <code><var> threshold amount</var> = {{threshold}} × <var> target dimension</var></code>
560
+ </blockquote>
561
+
562
+
563
+ 1. Adjust <var> scroll offset</var> by <var> threshold amount</var> as follow:
564
+ <div class="switch">
565
+
566
+ : If <var> offset</var> 's {{edge}} is ' start',
567
+ :: <var> scroll offset</var> = <var> scroll offset</var> - <var> threshold amount</var> .
568
+
569
+ : Otherwise (<var> offset</var> 's {{edge}} is ' end'),
570
+ :: <var> scroll offset</var> = <var> scroll offset</var> + <var> threshold amount</var> .
571
+
572
+ </div>
573
+
553
574
1. Clamp the value of <var> scroll offset</var> to be within the {{source}} 's
554
575
scroll range.
555
576
556
577
1. The [=effective scroll offset=] is <var> scroll offset</var>
557
578
558
579
580
+ <div class="note">
581
+ Note: With threshold 0.0, the algorithm selects the effective scroll offset such
582
+ that the target is adjacent to the [=scrollport=] at the given edge but not yet
583
+ visible. The upcoming threshold value will allow authors to control the amount
584
+ of target that needs to be visible in [=scrollport=] . In particular threshold
585
+ value 1.0 ensure that target is fully visible (as long as [=scrollport=] is
586
+ large enough).
587
+
588
+ <figure>
589
+ <img src="img/example-element-based-threshold.svg" width="600"
590
+ alt="Example usage of element-based offset.">
591
+ <figcaption>
592
+ Threshold controls how much of target should be visible in [=scrollport=] .
593
+ </figcaption>
594
+ </figure>
559
595
560
- Note: The current algorithm selects the effective scroll offset such that the
561
- target is adjacent to the scrollport but not yet visible. The upcoming threshold
562
- value will allow authors to control the amount of target that needs to be
563
- visible.
596
+ </div>
564
597
565
598
<div class="example">
566
599
Here is a basic example showing how element-based offsets can be used to declare
0 commit comments