Havret / material-components-react

Material Components for React
https://havret.github.io/material-components-react/
MIT License
2 stars 0 forks source link

Checkbox - Ripple radius is too big #41

Closed Havret closed 6 years ago

Havret commented 6 years ago

Ripple radius for the checkbox is too big.

Expected:

image

Actual:

image

Havret commented 6 years ago

https://github.com/material-components/material-components-web/pull/2216

englishextra commented 6 years ago

2018-03-12_231553

I have solved that via setTimeout. Though I understand the problem lies in Element.getBoundingClientRect() which has always been quite tricky

var rippleTimer;
var rippleHandler = function(){
    clearTimeout(rippleTimer);
    [].forEach.call(document.getElementsByClassName("mdc-button"), function(surface) {
        mdc.ripple.MDCRipple.attachTo(surface);
    });
    [].forEach.call(document.getElementsByClassName("mdc-icon-toggle"), function(iconToggle) {
        mdc.iconToggle.MDCIconToggle.attachTo(iconToggle);
    });
    [].forEach.call(document.getElementsByClassName("mdc-ripple-surface"), function(surface) {
        mdc.ripple.MDCRipple.attachTo(surface);
    });
    [].forEach.call(document.getElementsByClassName("mdc-card__primary-action"), function(el) {
        mdc.ripple.MDCRipple.attachTo(el);
    });
};
rippleTimer = setTimeout(rippleHandler, 400);

37328509-82e8c234-26ab-11e8-8d01-e6f0492f645a