Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Dynamic Enabling / Disabling without External Feature Detection #77

Merged

Conversation

asos-dominicjomaa
Copy link
Contributor

@asos-dominicjomaa asos-dominicjomaa commented Apr 22, 2022

Detail

The library before any manual enabling performs a feature detection to check whether the webkit like scroll behaviour property even works, effectively checking if the library will be used at all or not:

var testDiv = document.createElement('div');
document.documentElement.appendChild(testDiv);
testDiv.style.WebkitOverflowScrolling = 'touch';
var isScrollSupported = 'getComputedStyle' in window && window.getComputedStyle(testDiv)['-webkit-overflow-scrolling'] === 'touch';
document.documentElement.removeChild(testDiv);

This works well for situations where you only need this enabled once, but in our use case we need to be able to disable or enable iNoBounce only when a particular overlay is opened, which means this feature detection on the libraries IIFE construction is ignored. This coupled with the 0.1.6 version of the library seems to break Android scrolling entirely. The change here is to expose a boolean that can be rechecked when ever the consumer wishes to enable / disable the iNoBounce behaviour without worrying it will affect non-ios like devices.

As an example this might be used like this:

[SHOW_FILTER_OVERLAY]: state => {
    if (iNoBounce.isScrollSupported) {
      iNoBounce.enable();
    }

    return { ...state, isFilterOverlayVisible: true };
},
[HIDE_FILTER_OVERLAY]: state => {
    if (iNoBounce.isScrollSupported) {
      iNoBounce.disable();
    }

   return { ...state, isFilterOverlayVisible: false };
},

@asos-dominicjomaa
Copy link
Contributor Author

@lazd would love your thoughts on this!

@Eth-a-n
Copy link

Eth-a-n commented Apr 25, 2022

This will super handy, looks great !

@lazd
Copy link
Owner

lazd commented Apr 25, 2022

LGTM, thanks!

@lazd lazd merged commit ec49324 into lazd:master Apr 25, 2022
@lazd
Copy link
Owner

lazd commented Apr 25, 2022

Released in 0.2.1!

@asos-dominicjomaa
Copy link
Contributor Author

@lazd amazing turn around, thanks for the approval!

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