Skip to content

Commit 80dbe9e

Browse files
author
pipeline
committed
feature(EJ2-5519): scrollTop to Action Description in Mobile View
1 parent b0eb221 commit 80dbe9e

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed
Binary file not shown.
9 Bytes
Binary file not shown.
-6 Bytes
Binary file not shown.

src/common/component-content.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ let categoryName: string;
2020
let propBorder: HTMLElement = createElement('div', { className: 'sb-property-border' });
2121
export let sampleNameElement: Element = select('#component-name>.sb-sample-text');
2222

23+
let rightPane: Element = select('.sb-right-pane');
2324
export let sourceTab: Tab;
2425

2526
let mobilePropPane: Element = select('.sb-mobile-prop-pane');
@@ -260,7 +261,8 @@ function processDeviceDependables(): void {
260261
}
261262

262263
export function intialLoadScrollTop(): void {
263-
select('.sb-right-pane').scrollTop = 0;
264+
isMobile = window.matchMedia('(max-width:550px)').matches;
265+
isMobile ? rightPane.scrollTop = 74 : rightPane.scrollTop = 0;
264266
}
265267

266268
export function renderDescriptions(): void {
@@ -286,7 +288,7 @@ export function onComponentLoad(): void {
286288
propBorder.classList.add('sb-hide');
287289
}
288290
let mobileSetting: Element = select('.sb-mobile-setting');
289-
isMobile = window.matchMedia('(max-width:550px)').matches;;
291+
isMobile = window.matchMedia('(max-width:550px)').matches;
290292
if (isMobile && mobileSetting) {
291293
if (propPanel) {
292294
mobileSetting.classList.remove('sb-hide');

src/common/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ export function removeOverlay(): void {
492492
if (!sbBodyOverlay.classList.contains('sb-hide')) {
493493
sbBodyOverlay.classList.add('sb-hide');
494494
}
495-
sbRightPane.scrollTop = 0;
495+
isMobile = window.matchMedia('(max-width:550px)').matches;
496+
if (!isMobile) {
497+
sbRightPane.scrollTop = 0;
498+
}
496499
}
497500

498501
export function sampleOverlay(): void {
@@ -673,6 +676,8 @@ function loadTheme(theme: string): void {
673676
setSelectList();
674677
removeOverlay();
675678
ReactDOM.render(<Content />, document.getElementById('tab-component'));
676-
document.querySelector('.sb-right-pane').scrollTop = 0;
679+
if (!isMobile) {
680+
document.querySelector('.sb-right-pane').scrollTop = 0;
681+
}
677682
});
678683
}

src/common/leftpane.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class LeftPane extends React.Component<{}, {}> {
192192
isPc = window.matchMedia('(min-width:850px)').matches;
193193
sampleOverlay();
194194
let theme: string = location.hash.split('/')[1] || 'material';
195-
if (arg.item && ((isMobile && !select('.sb-mobile-left-pane').classList.contains('sb-hide')) ||
195+
if (arg.item && ((isMobile && !select('.sb-left-pane').classList.contains('sb-hide')) ||
196196
((isTablet || (Browser.isDevice && isPc)) && isLeftPaneOpen()))) {
197197
toggleLeftPane();
198198
}

0 commit comments

Comments
 (0)