Skip to content

Commit

Permalink
fix: restore original code
Browse files Browse the repository at this point in the history
  • Loading branch information
maiconcarraro committed Oct 7, 2024
1 parent d2284ba commit fb2b9fd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/use-prevent-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,15 @@ function preventScrollMobileSafari() {
}

// Sets a CSS property on an element, and returns a function to revert it to the previous value.
function setStyle(element: HTMLElement, style: string, value: string) {
let cur = element.style.getPropertyValue(style);
element.style.setProperty(style, value);
function setStyle(element: HTMLElement, style: keyof React.CSSProperties, value: string) {
// https://github.com/microsoft/TypeScript/issues/17827#issuecomment-391663310
let elStyle = <any>element.style;

let cur = elStyle[style];
elStyle[style] = value;

return () => {
element.style.setProperty(style, cur);
elStyle[style] = cur;
};
}

Expand Down

0 comments on commit fb2b9fd

Please sign in to comment.