PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, October 15, 2022

[FIXED] How to know `scrollIntoView` will do nothing?

 October 15, 2022     dom, dom-events, html, javascript     No comments   

Issue

Assume we want to call these 2 function in this specific order:

  1. scrollIntoView
  2. an user-defined function foo to be called after scrollIntoView finishes (possible scrolling)

Assume we have added an event 'scroll' callback to call foo. Now, the problem is that if the target DOM element is already in view, scrollIntoView will not scroll. In that case, event 'scroll' won't occur.

How do we have foo called, whenever the asynchronous function scrollIntoView finishes scrolling or doesn't need to scroll at all?

In other words, how do we know function scrollIntoView will visually do nothing?

This question is similar to How to know scroll to element is done in Javascript?.


Solution

Check if element is in view https://stackoverflow.com/a/125106/19617075 and perform scrollIntoView or foo based on that.



Answered By - Taras
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing