15 lines
338 B
JavaScript
15 lines
338 B
JavaScript
import isSmoothScrollSupported from '@utils/isSmoothScrollSupported';
|
|
|
|
export default () => {
|
|
return id => e => {
|
|
if (isSmoothScrollSupported()) {
|
|
e.preventDefault();
|
|
document.querySelector('#' + id).scrollIntoView({
|
|
behavior: 'smooth',
|
|
block: 'start',
|
|
inline: 'nearest',
|
|
});
|
|
}
|
|
};
|
|
};
|