Skip to content

Commit f6f2546

Browse files
committed
[BugFix][Harmony] fix the gesture problem of scroll container
when the contentSize < viewSize, needs to pass-through the touch gesture lynx-family/lynx-website#329 issue:m-6746732509 AutoLand:release/3.4 (cherry picked from commit 1122cab0727f06b1736b3b3eb065b6860225bfe6)
1 parent 66479c0 commit f6f2546

File tree

8 files changed

+38
-6
lines changed

8 files changed

+38
-6
lines changed

js_libraries/types/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# CHANGELOG
2+
## 3.5.2
3+
- Add `harmony-scroll-edge-effect` property for scroll container.
24

35
## 3.5.1
46
- Add `frame` element types.

js_libraries/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lynx-js/types",
3-
"version": "3.5.1",
3+
"version": "3.5.2",
44
"description": "",
55
"keywords": [
66
"lynx",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2025 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
5+
import { assertType } from 'vitest';
6+
import { expectType } from 'tsd';
7+
import { IntrinsicElements } from '../../types';
8+
9+
// Props Types Check
10+
let a;
11+
12+
// Props Types Check
13+
{
14+
<list harmony-scroll-edge-effect={false} />;
15+
assertType<boolean | undefined>(a as IntrinsicElements['list']['harmony-scroll-edge-effect']);
16+
}

js_libraries/types/types/common/element/list.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,14 @@ export interface ListProps extends StandardProps {
970970
* @since 3.1
971971
*/
972972
'experimental-batch-render-strategy'?: BatchRenderStrategy;
973+
974+
/**
975+
* When the content size of a component is smaller than the component itself, decide whether to enable scrolling.
976+
* @defaultValue false
977+
* @Harmony
978+
* @since 3.4
979+
*/
980+
'harmony-scroll-edge-effect'?: boolean | undefined;
973981

974982
/**
975983
* Scroll event.

platform/harmony/lynx_harmony/src/main/cpp/ui/ui_list.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void UIList::OnPropUpdate(const std::string& name, const lepus::Value& value) {
127127
} else if (name == list::kEnableScrollBar) {
128128
SetScrollbar(value.Bool());
129129
} else if (name == list::kBounces && value.IsBool()) {
130-
SetBounces(value.Bool());
130+
SetBounces(value.Bool(), true);
131131
} else if (name == list::kNeedVisibleItemInfo && value.IsBool()) {
132132
enable_need_visible_item_info = value.Bool();
133133
} else if (name == list::kExperimentalUpdateStickyForDiff && value.IsBool()) {

platform/harmony/lynx_harmony/src/main/cpp/ui/ui_scroll.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void UIScroll::OnPropUpdate(const std::string& name,
314314
} else if (name == scroll::kEnableScrollBar && value.IsBool()) {
315315
SetScrollbar(value.Bool());
316316
} else if (name == scroll::kBounces && value.IsBool()) {
317-
SetBounces(value.Bool());
317+
SetBounces(value.Bool(), true);
318318
} else if (name == scroll::kLowerThreshold && value.IsNumber()) {
319319
lower_threshold_ = static_cast<int>(value.Number());
320320
} else if (name == scroll::kUpperThreshold && value.IsNumber()) {

platform/harmony/lynx_harmony/src/main/cpp/ui/utils/base_scroll_container.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ BaseScrollContainer::BaseScrollContainer(LynxContext* context, int sign,
1414
: UIView(context, ARKUI_NODE_SCROLL, sign, tag) {
1515
SetNestedScroll(ARKUI_SCROLL_NESTED_MODE_SELF_FIRST);
1616
SetScrollbar(false);
17+
SetBounces(false, true);
1718
overflow_ = {false, false};
1819
}
1920

@@ -90,11 +91,12 @@ void BaseScrollContainer::SetScrollDirection(ArkUI_ScrollDirection direction) {
9091
node_, NODE_SCROLL_SCROLL_DIRECTION, static_cast<int>(direction));
9192
}
9293

93-
void BaseScrollContainer::SetBounces(bool bounces) {
94+
void BaseScrollContainer::SetBounces(bool bounces, bool always_enabled) {
9495
NodeManager::Instance().SetAttributeWithNumberValue(
9596
node_, NODE_SCROLL_EDGE_EFFECT,
9697
static_cast<int32_t>(bounces ? ARKUI_EDGE_EFFECT_SPRING
97-
: ARKUI_EDGE_EFFECT_NONE));
98+
: ARKUI_EDGE_EFFECT_NONE),
99+
static_cast<int32_t>(always_enabled));
98100
}
99101

100102
void BaseScrollContainer::SetEnableScrollInteraction(
@@ -142,6 +144,9 @@ void BaseScrollContainer::OnPropUpdate(const std::string& name,
142144
} else {
143145
SetHorizontal(false);
144146
}
147+
} else if (name == kScrollEdgeEffect && value.IsBool()) {
148+
auto data = value.Bool();
149+
SetBounces(data, data);
145150
} else {
146151
UIView::OnPropUpdate(name, value);
147152
}

platform/harmony/lynx_harmony/src/main/cpp/ui/utils/base_scroll_container.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static constexpr const char* const kNestedScrollForwardOptions = "temporary-nest
1919
static constexpr const char* const kNestedScrollBackWardOptions =
2020
"temporary-nested-scroll-backward";
2121
static constexpr const char* const kScrollOrientation = "scroll-orientation";
22+
static constexpr const char* const kScrollEdgeEffect = "harmony-scroll-edge-effect";
2223

2324
class BaseScrollContainer : public UIView {
2425
public:
@@ -45,7 +46,7 @@ class BaseScrollContainer : public UIView {
4546
void SetEnableScrollInteraction(bool enable_scroll_interaction);
4647
void SetScrollbar(bool enable_scroll_bar);
4748
void SetHorizontal(bool horizontal);
48-
void SetBounces(bool bounces);
49+
void SetBounces(bool bounces, bool always_enabled);
4950
virtual void UpdateContentSize(float width, float height) {
5051
content_width_ = width;
5152
content_height_ = height;

0 commit comments

Comments
 (0)