t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.84k forks source link

will-change CSS property causes blurriness of objects #959

Open JohnHKoh opened 3 years ago

JohnHKoh commented 3 years ago

Currently, the swal-modal class uses the CSS property will-change. https://github.com/t4t5/sweetalert/blob/82c8869761c138f1fba7771a818e40f1aab35be6/src/sweetalert.css#L42

While this could help browsers perform optimizations, it also has undesirable side-effects. As of Chrome 53, will-change will prevent re-rasterization of objects during or after a transform, which can cause blurry objects and text. Read more about the issue here:

The following screenshots are from https://sweetalert.js.org/ and were taken on Chrome 88.0.4324.190. The first image is with the will-change property applied. The second image is when I overwrote the property with will-change: unset;. Take note of the subtle differences.

image

image

The second image is noticeably sharper. You may also be able to see the differences easier by toggling the CSS property in the Chrome DevTools menu.

The will-change property should be removed, or there should be an option to disable this property. In fact, maybe a better solution would be to allow modifications to the default CSS, as mentioned in https://github.com/t4t5/sweetalert/issues/913.

pietos commented 3 years ago

The following workaround solved it for me:

.swal-overlay--show-modal .swal-modal { will-change: unset !important; }

Androz2091 commented 3 years ago

I used the same thing.

.swal-modal {
  will-change: unset;
}

worked perfectly with React.