Skip to content

added new scroll to demo logic - #13

Open
VKR981 wants to merge 13 commits into
codex-team:mainfrom
VKR981:scroll-to-demo-fix
Open

added new scroll to demo logic#13
VKR981 wants to merge 13 commits into
codex-team:mainfrom
VKR981:scroll-to-demo-fix

Conversation

@VKR981

@VKR981 VKR981 commented Aug 15, 2023

Copy link
Copy Markdown

New scroll logic

Editor.webm

Comment thread components/EditorOverview.vue Outdated
}
}

window.addEventListener('DOMNodeInserted',onDomChange)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to bind this event inside the onMounted hook to prevent SSR issues

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it, I placed mobile focus part inside setTimeout because it solves to problems

  1. Virtual keyboard interrupts scroll
  2. Editor is focused before it's initialised

@VKR981
VKR981 marked this pull request as draft August 16, 2023 06:56
@VKR981
VKR981 marked this pull request as ready for review August 18, 2023 02:16
Comment thread components/EditorOverview.vue Outdated
Comment on lines +85 to +105
(document.querySelector('.fake-input') as HTMLElement).focus();

const block: HTMLElement | null = document.querySelector('.ce-paragraph');
const block: HTMLElement | null = document.querySelector('.ce-paragraph');

if (block !== null){
if (block !== null){

block.focus()
}
block.focus()
}
},1000)
}

/**
* Send analytics event
*/
$track(AnalyticEvent.PlayWithDemoClicked)
}


/**
* Scroll the target element to 33% from top of the screen
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have problems with identations

Comment thread components/EditorOverview.vue Outdated
*
* So we use fake invisible input to focus it first, then change focus to our editor
*
* setTimeout is used because the virtual keyboard interrupts scroll

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem and solution is unclear to me. Do you mean mobile devices?

For now, it breaks the focus of editor on mobile devices (tested in Safari), which is working fine in main. Also, scroll works fine in main on mobile safari

@VKR981 VKR981 Aug 22, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure because I tested it on Safari (IOS Simulator), it was working fine, and yes the focus and scroll breaks on Chrome (Android) main.

@VKR981 VKR981 Aug 22, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another solution is to put
`const block: HTMLElement | null = document.querySelector('.ce-paragraph');
if (block !== null){

    block.focus()
  }`

inside onReady callback which is woking on Chrome (Android) and Safari(IOS Simulator).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have kept the changes to a minimum this PR only addresses the scroll issue on web tested on Chrome (Desktop) and Safari (Desktop)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants