Sunday, 1 January 2023

window.scrollTo(x, y) is not working in mobile iOS

Trying to create a webpage that can

  1. move screen to the RIGHT while scrolling UP
  2. move screen to the LEFT while scrolling DOWN

I used the function of window.scrollTo for moving the screen. It works perfect in decktop browser and the desktop Chrome's mobile view. But, the function is not working in mobile even iOS Safari or iOS Chrome. Tried the setTimeout, but still not work. Any suggestions?

Below is the simplified codes that has the same issue.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<body style="margin: 0px; height: 100%; overflow: hidden;"> <!-- disable desktop scrolling -->
    <img style="width: 300%;" src="https://imaging.nikon.com/lineup/dslr/df/img/sample/img_01.jpg">
</body>

<script type="text/javascript">

    // Mobile
    document.body.addEventListener('touchmove', function(e){ 
        handleTouchMove(e);
        
        e.preventDefault(); // disable mobile user interaction
    }, { passive: false });

    var currentX = 0;

    function scrolling(isUp) {
        var movingBy = 10;
        // backward
        if (isUp) {
            currentX -= Math.min(movingBy, currentX);
        // forward
        } else {
            currentX += Math.min(movingBy, $(window).width() * 2 - currentX);
        }
        window.scrollTo(currentX, 0);
    }

    document.addEventListener('touchstart', handleTouchStart, false);  

    var xDown = null;                                                        
    var yDown = null;                                               
                                                                             
    function handleTouchStart(evt) {
        var touches = evt.touches || evt.originalEvent.touches;
        const firstTouch = touches[0];                                      
        xDown = firstTouch.clientX;                                      
        yDown = firstTouch.clientY;                                      
    };                                                
                                                                             
    function handleTouchMove(evt) {
        var xUp = evt.touches[0].clientX;                                    
        var yUp = evt.touches[0].clientY;

        var xDiff = xDown - xUp;
        var yDiff = yDown - yUp;
                                                                             
        if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {     
            // left and right            
        } else {
            // up and down
            scrolling(yDiff <= 0);                                                           
        }

        xDown = xUp;
        yDown = yUp;                                             
    };

    // desktop
    ...
</script>


from window.scrollTo(x, y) is not working in mobile iOS

acquireTokenSilentAsync: The signed in account does not match with the provided account

I am using MSAL for Android and confused about this error:

The signed in account does not match with the provided account.
(Error code current_account_mismatch, from acquireTokenSilentAsync)

This is what I am doing:

  1. Uninstall my own app, install it again

  2. Login via signIn() method of MSAL

  3. Call acquireTokenSilentAsync():

         val parameters = AcquireTokenSilentParameters.Builder()
             .withScopes(scopes.toList())
             .withCallback(authenticationCallback)
             .build()
    
         _msalPublicClient.acquireTokenSilentAsync(parameters)
    

    This call leads to a call of the onError method of the authenticationCallback with

com.microsoft.identity.client.exception.MsalClientException: The signed in account does not match with the provided account.

How can that be fixed? How can the provided account (whatever that is?) be different from the signed in account on a new app installation?



from acquireTokenSilentAsync: The signed in account does not match with the provided account

How to use acquireToken with Jetpack Compose?

How can I use acquireToken - which requires a Fragment to be passed in - with Jetpack Compose, where I don't have a Fragment?

val parameters = AcquireTokenParameters.Builder()
    .withScopes(scopes.toList())
    .withCallback(authenticationCallback)
    .withFragment(<what can I pass in here?>) // <--------- relevant line
    .build()

_msalPublicClient.acquireToken(parameters)

I am on the latest MSAL for Android, version 4.1.0



from How to use acquireToken with Jetpack Compose?