Skip to content

Commit fe58a1a

Browse files
committed
Remove dependency on scroll-to
1 parent 2983a32 commit fe58a1a

8 files changed

+1370
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
build

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# scroll-to-element
22

3-
Smooth scrolls to element of the specified selector or element reference with optional offset, scroll-positon, easing, and duration via [scroll-to](https://www.npmjs.com/package/scroll-to). Takes into account document height for elements low on the page.
3+
Smooth scrolls to element of the specified selector or element reference with optional offset, scroll-positon, easing, and duration. Takes into account document height for elements low on the page.
44

55
[![NPM](https://nodei.co/npm/scroll-to-element.png)](https://nodei.co/npm/scroll-to-element/)
66

example.js examples/example.js

File renamed without changes.

examples/index.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>ScrollToElement</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<script src="../build/scrollToElement.js"></script>
9+
</head>
10+
<body>
11+
<button id="scroll-button" style="position: absolute;">Click to Scroll</button>
12+
<div style="padding-top: 1000px;"></div>
13+
<div id="scroll-to-element" >Scroll To Here</div>
14+
</body>
15+
<script>
16+
const button = document.querySelector('#scroll-button')
17+
button.addEventListener('click', e => {
18+
scrollToElement('#scroll-to-element')
19+
})
20+
</script>
21+
</html>

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var scroll = require('scroll-to');
1+
var scroll = require('./scroll-to');
22

33
function calculateScrollOffset(elem, additionalOffset, alignment) {
44
var body = document.body,

0 commit comments

Comments
 (0)