In chorme horizontal scroll work , but in safari browser its not work

29 Views Asked by At

here is my code this code not work on safari.

targetPosition i set the scroll value, for example , 11 , 22, 33 , where i scroll

  function ScrollToActiveTab(item, id, useraction) {
    if (item !== null && item !== undefined && useraction) {
      dispatch(addCurrentMenu(item));
    }
  
    requestAnimationFrame(() => {
      // Ensure this runs after any pending layout changes
      var scrollableDiv = document.getElementById('scrollableDiv');
      let tempId = 'targetId-' + id;
      var targetElement = document.getElementById(tempId);
  
      if (targetElement) {
        var targetPosition = targetElement.offsetLeft + targetElement.clientWidth / 2 - window.innerWidth / 2;
  
        // Perform the scroll
        scrollableDiv.scrollLeft = targetPosition;
      }
    });
  }

Please guide my why ° scrollableDiv.scrollLeft = targetPosition;° not work on safari. Thanks

i want work scrollableDiv.scrollLeft = targetPosition , in safari also see attachment , i have a menu list once i click i update tragetPosition

menu Tab

0

There are 0 best solutions below