0.0.3 • Published 4 years ago
backtop.js v0.0.3
backtop.js
Use Javascript to return to the top of the page or scroll to the specified HTML element
# npm
npm i backtop.js --save
import backtop from 'backtop.js';
document.querySelector('#button').addEventListener('click', () => {
backtop({
type: 'smooth',
element: document.querySelector('#title'); // 不传 HTML 节点时默认返回网页顶部
});
});
type?: 'smooth' | 'instant'
defaultsmooth
element?: HTMLElement
speed?: number
onStart?: () => {}
onBack?: () => {}
onEnd?: () => {}