WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #49025, comment 2


Ignore:
Timestamp:
01/14/2020 11:18:45 AM (6 weeks ago)
Author:
raQai
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #49025, comment 2

    initial v1  
    1919                                if ('' !== target.hash && -1 !== targetHref.indexOf(url)) {
    2020                                        setTimeout(function () {
    21                                                 var fakeEl = document.createElement('a');
    22 
    23                                                 fakeEl.href = targetHref;
    24                                                 fakeEl.click();
    25                                         }, 550);
     21                                                document.getElementById(target.hash.substr(1)).scrollIntoView()
     22                                        }, 700);
    2623                                }
    2724                        }
     
    2926        },
    3027}}}
     28
     29**Edit1**
     30After further testing (especially on mobile devices) I figured the timeout of 550 ms is not enough for some browser/device combinations to wait for the menu to be closed. Changing this value to 700ms solved this issue on my test phones.
     31
     32I also prefer `#scrollIntoView` instead of creating a fake element using `#createElement`.