| 21 | ScrollAttributes::ScrollAttributes(AttributeIds& attributeIds) : _attributeIds(attributeIds) {} |
| 22 | |
| 23 | void ScrollAttributes::bind(AttributeHandlerById& attributes) { |
| 24 | AttributesBinderHelper binder(_attributeIds, attributes); |
| 25 | |
| 26 | binder.bindViewNodeBoolean("horizontal", &ViewNode::setHorizontalScroll); |
| 27 | binder.bindViewNodeInt("circularRatio", &ViewNode::setScrollCircularRatio); |
| 28 | |
| 29 | binder.bindViewNodeCallback("onScroll", &ViewNode::setOnScrollCallback); |
| 30 | binder.bindViewNodeCallback("onScrollEnd", &ViewNode::setOnScrollEndCallback); |
| 31 | binder.bindViewNodeCallback("onDragStart", &ViewNode::setOnDragStartCallback); |
| 32 | binder.bindViewNodeCallback("onDragEnding", &ViewNode::setOnDragEndingCallback); |
| 33 | binder.bindViewNodeCallback("onDragEnd", &ViewNode::setOnDragEndCallback); |
| 34 | |
| 35 | binder.bindViewNodeFloat("viewportExtensionTop", &ViewNode::setViewportExtensionTop); |
| 36 | binder.bindViewNodeFloat("viewportExtensionBottom", &ViewNode::setViewportExtensionBottom); |
| 37 | binder.bindViewNodeFloat("viewportExtensionLeft", &ViewNode::setViewportExtensionLeft); |
| 38 | binder.bindViewNodeFloat("viewportExtensionRight", &ViewNode::setViewportExtensionRight); |
| 39 | |
| 40 | binder.bindViewNodeCallback("onContentSizeChange", &ViewNode::setOnContentSizeChangeCallback); |
| 41 | |
| 42 | std::vector<CompositeAttributePart> parts; |
| 43 | parts.emplace_back(_attributeIds.getIdForName("contentOffsetX"), true); |
| 44 | parts.emplace_back(_attributeIds.getIdForName("contentOffsetY"), true); |
| 45 | parts.emplace_back(_attributeIds.getIdForName("contentOffsetAnimated"), true); |
| 46 | |
| 47 | binder.bindComposite( |
| 48 | "contentOffset", |
| 49 | std::move(parts), |
| 50 | [](ViewTransactionScope& viewTransactionScope, ViewNode& viewNode, const Value& value) -> Result<Void> { |
| 51 | const auto* compositeArray = value.getArray(); |
| 52 | if (compositeArray == nullptr || compositeArray->size() != 3) { |
| 53 | return Error("Expected 3 elements in composite attribute"); |
| 54 | } |
| 55 | |
| 56 | auto directionAgnosticContentOffsetX = (*compositeArray)[0].toFloat(); |
| 57 | auto directionAgnosticContentOffsetY = (*compositeArray)[1].toFloat(); |
| 58 | auto animated = (*compositeArray)[2].toBool(); |
| 59 | |
| 60 | if (std::isnan(directionAgnosticContentOffsetX) || std::isnan(directionAgnosticContentOffsetY)) { |
| 61 | return Error("Can't set a scroll content offset with NaN value"); |
| 62 | } |
| 63 | |
| 64 | viewNode.setScrollContentOffset(viewTransactionScope, |
| 65 | Point(directionAgnosticContentOffsetX, directionAgnosticContentOffsetY), |
| 66 | animated); |
| 67 | |
| 68 | return Void(); |
| 69 | }, |
| 70 | [](ViewTransactionScope& viewTransactionScope, ViewNode& viewNode) { |
| 71 | viewNode.setScrollContentOffset(viewTransactionScope, Point(), false); |
| 72 | }); |
| 73 | |
| 74 | binder.bindViewNodeFloat("staticContentWidth", &ViewNode::setScrollStaticContentWidth); |
| 75 | binder.bindViewNodeFloat("staticContentHeight", &ViewNode::setScrollStaticContentHeight); |
| 76 | |
| 77 | binder.bindViewNodeBoolean("maintainScrollAnchor", &ViewNode::setMaintainScrollAnchor); |
| 78 | binder.bindViewNodeBoolean("preserveScrollPosition", &ViewNode::setPreserveScrollPosition); |
| 79 | binder.bindViewNodeBoolean("nativeStickyEnabled", &ViewNode::setNativeStickyEnabled); |
| 80 | binder.bindViewNodeFloat("nativeStickyCover", &ViewNode::setNativeStickyCover); |
nothing calls this directly
no test coverage detected