I am trying to use a CSS filter to blur the image. In all browsers, the blur filter results in a blur that goes beyond the image beyond any value that you set the blur (expected). But I want the edges to be defined (and the image has a window shadow), so I wrap the image with another div with overflow
set to hidden
. This works in all browsers.
However, due to some restrictions for the application, I need to update the size of the wrapper using JavaScript when loading and resizing. This works in all browsers except Safari. Changing the size of the wrapper element randomly causes a drawing error, where the filter begins to go beyond the bounds of the wrapper. This is not always the case, but it seems to increase the likelihood of using MobileSafari and / or depending on the size of the DOM.
Here is a violin with a small demonstration. Using Safari, resize the window several times and you will get an error. Sometimes he will redraw and correct himself, sometimes it will not. (Use Chrome or Firefox, and it will work fine.)
( Screenshot blurring the shielding .)
It should be noted that unlike this script, in the application I set only the new width and height when they change, and Safari still fluctuates between blurring and does not slip away, even when the width and height are NOT set during the resize event.
Things I tried (which didn't work):
- Delay in calculating and setting the width of the wrapper until the resize event completes with
clearTimeout
/ setTimeout
- Reset and reset
overflow: hidden
on the wrapper and image using JavaScript after resizing - Call
window.getComputedStyle(wrapper)
(both on the image and on the parent) - All kinds of frauds to move the wrapper to the composite element (for example,
translateZ(0)
transforms), which stops some blur overflow, but not enough. ( Screenshot .) Setting a timer to turn off conversion simply returns the page to complete blur. - Setting
white-space: nowrap
on the wrapper - Setting width and height using
document.styleSheets[x].cssRules[x].style.setProperty()
, not object.style.width
/ height
- rounding pixel values ββto multiples of 2/5/10 (yes, I'm desperate)
I am pretty stuck right now and would really appreciate any help you can provide. Thanks!
source share