|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +function convertScrollToOptions(options) { |
| 4 | + return options.value0 && Object.assign({}, options.value0, { behavior: options.value0.constructor.name.toLowerCase() }); |
| 5 | +} |
| 6 | + |
| 7 | +exports.getClientRects = function (element) { |
| 8 | + return function () { |
| 9 | + return element.getClientRects(); |
| 10 | + }; |
| 11 | +}; |
| 12 | + |
| 13 | +exports.getBoundingClientRect = function (element) { |
| 14 | + return function () { |
| 15 | + return element.getBoundingClientRect(); |
| 16 | + }; |
| 17 | +}; |
| 18 | + |
| 19 | +exports.scrollIntoView = function (element) { |
| 20 | + return function (scrollIntoViewOptions) { |
| 21 | + return function () { |
| 22 | + if (scrollIntoViewOptions.value0) { |
| 23 | + element.scrollIntoView({ |
| 24 | + block: scrollIntoViewOptions.value0.block.constructor.name.toLowerCase(), |
| 25 | + inline: scrollIntoViewOptions.value0.inline.constructor.name.toLowerCase() |
| 26 | + }); |
| 27 | + } else { |
| 28 | + element.scrollIntoView(); |
| 29 | + } |
| 30 | + }; |
| 31 | + }; |
| 32 | +}; |
| 33 | + |
| 34 | +exports.scroll = function (element) { |
| 35 | + return function (scrollToOptions) { |
| 36 | + return function () { |
| 37 | + element.scrollIntoView(convertScrollToOptions(scrollToOptions)); |
| 38 | + }; |
| 39 | + }; |
| 40 | +}; |
| 41 | + |
| 42 | +exports.scrollTo = function (element) { |
| 43 | + return function (scrollToOptions) { |
| 44 | + return function () { |
| 45 | + element.scrollTo(convertScrollToOptions(scrollToOptions)); |
| 46 | + }; |
| 47 | + }; |
| 48 | +}; |
| 49 | + |
| 50 | +exports.scrollBy = function (element) { |
| 51 | + return function (scrollToOptions) { |
| 52 | + return function () { |
| 53 | + element.scrollBy(convertScrollToOptions(scrollToOptions)); |
| 54 | + }; |
| 55 | + }; |
| 56 | +}; |
| 57 | + |
| 58 | +function getter(property) { |
| 59 | + return function (element) { |
| 60 | + return function () { |
| 61 | + return element[property]; |
| 62 | + }; |
| 63 | + }; |
| 64 | +} |
| 65 | + |
| 66 | +exports.scrollTop = getter("scrollTop"); |
| 67 | +exports.scrollLeft = getter("scrollLeft"); |
| 68 | +exports.scrollWidth = getter("scrollWidth"); |
| 69 | +exports.scrollHeight = getter("scrollHeight"); |
| 70 | +exports.clientTop = getter("clientTop"); |
| 71 | +exports.clientLeft = getter("clientLeft"); |
| 72 | +exports.clientWidth = getter("clientWidth"); |
| 73 | +exports.clientHeight = getter("clientHeight"); |
0 commit comments