(parser)
| 684 | } |
| 685 | |
| 686 | function _parseScrollModifiers(parser) { |
| 687 | parser.matchToken("the"); |
| 688 | var verticalPosition = parser.matchAnyToken("top", "middle", "bottom"); |
| 689 | var horizontalPosition = parser.matchAnyToken("left", "center", "right"); |
| 690 | if (verticalPosition || horizontalPosition) { |
| 691 | parser.requireToken("of"); |
| 692 | } |
| 693 | var target = parser.requireElement("unaryExpression"); |
| 694 | |
| 695 | var plusOrMinus = parser.matchAnyOpToken("+", "-"); |
| 696 | var offset; |
| 697 | if (plusOrMinus) { |
| 698 | parser.pushFollow("px"); |
| 699 | try { |
| 700 | offset = parser.requireElement("expression"); |
| 701 | } finally { |
| 702 | parser.popFollow(); |
| 703 | } |
| 704 | } |
| 705 | parser.matchToken("px"); |
| 706 | |
| 707 | var container; |
| 708 | if (parser.matchToken("in")) { |
| 709 | container = parser.requireElement("unaryExpression"); |
| 710 | } |
| 711 | |
| 712 | var smoothness = parser.matchAnyToken("smoothly", "instantly"); |
| 713 | |
| 714 | var scrollOptions = { block: "start", inline: "nearest" }; |
| 715 | |
| 716 | var blockMap = { top: "start", bottom: "end", middle: "center" }; |
| 717 | var inlineMap = { left: "start", center: "center", right: "end" }; |
| 718 | var behaviorMap = { smoothly: "smooth", instantly: "instant" }; |
| 719 | if (verticalPosition) scrollOptions.block = blockMap[verticalPosition.value]; |
| 720 | if (horizontalPosition) scrollOptions.inline = inlineMap[horizontalPosition.value]; |
| 721 | if (smoothness) scrollOptions.behavior = behaviorMap[smoothness.value]; |
| 722 | |
| 723 | return { target, offset, plusOrMinus, scrollOptions, container }; |
| 724 | } |
| 725 | |
| 726 | function _parseSmoothness(parser) { |
| 727 | var smoothness = parser.matchAnyToken("smoothly", "instantly"); |
no test coverage detected