Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-129000: Apply voice intent only when scroll is possible #2888

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The following is a curated list of changes in the Enact ui module, newest change
### Changed

- `ui/Transition` prop `duration` to support any valid CSS value for `slide` and `fade` `type`
- `ui/useScroll` to manage internal state `isScrollVertically` and `isScrollHorizontally`

## [3.4.11] - 2020-12-11

Expand Down
21 changes: 18 additions & 3 deletions packages/ui/useScroll/useScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ const useScrollBase = (props) => {

const [isHorizontalScrollbarVisible, setIsHorizontalScrollbarVisible] = useState(horizontalScrollbar === 'visible');
const [isVerticalScrollbarVisible, setIsVerticalScrollbarVisible] = useState(verticalScrollbar === 'visible');
const [isScrollVertically, setIsScrollVertically] = useState(false);
const [isScrollHorizontally, setIsScrollHorizontally] = useState(false);

const mutableRef = useRef({
overscrollEnabled: !!(props.applyOverscrollEffect),
Expand Down Expand Up @@ -343,6 +345,13 @@ const useScrollBase = (props) => {
};
});

useEffect(() => {
const bounds = getScrollBounds();
setIsScrollVertically(canScrollVertically(bounds));
setIsScrollHorizontally(canScrollHorizontally(bounds));
}, []); // eslint-disable-line react-hooks/exhaustive-deps


// scrollMode 'translate' [[
// TODO: consider replacing forceUpdate() by storing bounds in state rather than a non-
// state member.
Expand Down Expand Up @@ -1561,7 +1570,9 @@ const useScrollBase = (props) => {
return {
scrollContentWrapper: noScrollByDrag ? 'div' : TouchableDiv,
isHorizontalScrollbarVisible,
isVerticalScrollbarVisible
isVerticalScrollbarVisible,
isScrollVertically,
isScrollHorizontally
};
};

Expand Down Expand Up @@ -1611,7 +1622,9 @@ const useScroll = (props) => {
const {
scrollContentWrapper,
isHorizontalScrollbarVisible,
isVerticalScrollbarVisible
isVerticalScrollbarVisible,
isScrollVertically,
isScrollHorizontally
} = useScrollBase({
...props,
assignProperties,
Expand All @@ -1637,7 +1650,9 @@ const useScroll = (props) => {
scrollContentWrapper,
scrollContentHandle,
isHorizontalScrollbarVisible,
isVerticalScrollbarVisible
isVerticalScrollbarVisible,
isScrollVertically,
isScrollHorizontally
};
};

Expand Down