Skip to content

Commit 5962157

Browse files
authored
Merge branch 'master' into feature/prevent-scroll-on-canceled-event
2 parents 559e3e4 + 6abdee5 commit 5962157

File tree

8 files changed

+57
-63
lines changed

8 files changed

+57
-63
lines changed

.github/main.workflow

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
workflow "Release" {
2-
on = "release"
3-
resolves = ["Publish to NPM"]
1+
workflow "publish on release" {
2+
on = "push"
3+
resolves = ["publish"]
44
}
55

6-
action "Publish to NPM" {
7-
uses = "actions/npm@e7aaefed7c9f2e83d493ff810f17fa5ccd7ed437"
8-
runs = "npm publish"
9-
}
6+
action "publish" {
7+
uses = "actions/npm@master"
8+
args = "publish"
9+
secrets = ["NPM_AUTH_TOKEN"]
10+
}

README.md

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Smooth Scroll [![Build Status](https://travis-ci.org/cferdinandi/smooth-scroll.svg)](https://travis-ci.org/cferdinandi/smooth-scroll)
22
A lightweight script to animate scrolling to anchor links. Smooth Scroll works great with [Gumshoe](https://github.com/cferdinandi/gumshoe).
33

4-
[View the Demo](https://codepen.io/cferdinandi/pen/wQzrdM)
4+
**[View the Demo on CodePen →](https://codepen.io/cferdinandi/pen/wQzrdM)**
5+
6+
[Getting Started](#getting-started) | [Scroll Speed](#scroll-speed) | [Easing Options](#easing-options) | [API](#api) | [What's new?](#whats-new) | [Known Issues](#known-issues) | [Browser Compatibility](#browser-compatibility) | [License](#license)
7+
8+
*__Quick aside:__ you might not need this library. There's [a native CSS way to handle smooth scrolling](https://gomakethings.com/smooth-scrolling-links-with-only-css/) that might fit your needs.*
59

610

711
<hr>
@@ -39,13 +43,21 @@ You can also use the [jsDelivr CDN](https://cdn.jsdelivr.net/gh/cferdinandi/smoo
3943
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll/dist/smooth-scroll.polyfills.min.js"></script>
4044

4145
<!-- Get minor updates and patch fixes within a major version -->
42-
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@14/dist/smooth-scroll.polyfills.min.js"></script>
46+
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@15/dist/smooth-scroll.polyfills.min.js"></script>
4347

4448
<!-- Get patch fixes within a minor version -->
45-
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@14.0/dist/smooth-scroll.polyfills.min.js"></script>
49+
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@15.0/dist/smooth-scroll.polyfills.min.js"></script>
4650

4751
<!-- Get a specific version -->
48-
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/[email protected]/dist/smooth-scroll.polyfills.min.js"></script>
52+
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/[email protected]/dist/smooth-scroll.polyfills.min.js"></script>
53+
```
54+
55+
**NPM**
56+
57+
You can also use NPM (or your favorite package manager).
58+
59+
```bash
60+
npm install smooth-scroll
4961
```
5062

5163
### 2. Add the markup to your HTML.
@@ -153,13 +165,13 @@ var scroll = new SmoothScroll('a[href*="#"]', {
153165

154166

155167

156-
## Options and Settings
168+
## API
157169

158170
Smooth Scroll includes smart defaults and works right out of the box. But if you want to customize things, it also has a robust API that provides multiple ways for you to adjust the default options and settings.
159171

160-
### Global Settings
172+
### Options and Settings
161173

162-
You can pass options and callbacks into Smooth Scroll through the `init()` function:
174+
You can pass options and callbacks into Smooth Scroll when instantiating.
163175

164176
```javascript
165177
var scroll = new SmoothScroll('a[href*="#"]', {
@@ -246,7 +258,7 @@ document.addEventListener('scrollCancel', logScrollEvent, false);
246258

247259
### Methods
248260

249-
You can also call Smooth Scroll's methods in your own scripts.
261+
Smooth Scroll also exposes several public methods.
250262

251263
#### animateScroll()
252264
Animate scrolling to an anchor.
@@ -296,16 +308,8 @@ scroll.cancelScroll();
296308

297309
***Note:*** *This does not handle focus management. The user will stop in place, and focus will remain on the anchor link that triggered the scroll.*
298310

299-
#### init()
300-
Initialize Smooth Scroll. This is called automatically when you setup your `new SmoothScroll` object, but can be used to reinitialize your instance.
301-
302-
```javascript
303-
var scroll = new SmoothScroll();
304-
scroll.init('.some-selector');
305-
```
306-
307311
#### destroy()
308-
Destroy the current `smoothScroll.init()`. This is called automatically during the `init` function to remove any existing initializations.
312+
Destroy the current initialization. This is called automatically in the `init` method to remove any existing initializations.
309313

310314
```javascript
311315
var scroll = new SmoothScroll();
@@ -333,34 +337,21 @@ If you have multiple fixed headers, pass in the last one in the markup.
333337

334338

335339

336-
## Working with the Source Files
337-
338-
If you would prefer, you can work with the development code in the `src` directory using the included [Gulp build system](http://gulpjs.com/). This compiles, lints, and minifies code.
339-
340-
### Dependencies
341-
Make sure these are installed first.
342-
343-
* [Node.js](http://nodejs.org)
344-
* [Gulp](http://gulpjs.com) `sudo npm install -g gulp`
345-
346-
### Quick Start
347-
348-
1. In bash/terminal/command line, `cd` into your project directory.
349-
2. Run `npm install` to install required files.
350-
3. When it's done installing, run one of the task runners to get going:
351-
* `gulp` manually compiles files.
352-
* `gulp watch` automatically compiles files when changes are made and applies changes using [LiveReload](http://livereload.com/).
340+
## What's new?
353341

342+
Scroll duration now varies based on distance traveled. If you want to maintain the old scroll animation duration behavior, set the `speedAsDuration` option to `true`.
354343

355344

356345

357-
## Migrating to Smooth Scroll 15 from Older Versions
346+
## Known Issues
358347

359-
Scroll duration now varies based on distance traveled. If you want to maintain the old scroll animation duration behavior, set the `speedAsDuration` option to `true`.
348+
### Reduce Motion Settings
360349

350+
This isn't really an "issue" so-much as a question I get a lot.
361351

352+
Smooth Scroll respects [the `Reduce Motion` setting](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion) available in certain operating systems. In browsers that surface that setting, Smooth Scroll will not run and will revert to the default "jump to location" anchor link behavior.
362353

363-
## Known Issues
354+
I've decided to respect user preferences of developer desires here. This is *not* a configurable setting.
364355

365356
### `<body>` styling
366357

@@ -384,6 +375,8 @@ Smooth Scroll works in all modern browsers, and IE 9 and above.
384375

385376
Smooth Scroll is built with modern JavaScript APIs, and uses progressive enhancement. If the JavaScript file fails to load, or if your site is viewed on older and less capable browsers, anchor links will jump the way they normally would.
386377

378+
*__Note:__ Smooth Scroll will not run&mdash;even in supported browsers&mdash;if users have `Reduce Motion` enabled. [Learn more in the "Known Issues" section.](#reduce-motion-settings)*
379+
387380
### Polyfills
388381

389382
Support back to IE9 requires polyfills for `closest()`, `requestAnimationFrame()`, and `CustomEvent()`. Without them, support starts with Edge.

dist/smooth-scroll.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v15.2.1
2+
* smooth-scroll v16.0.1
33
* Animate scrolling to anchor links
44
* (c) 2019 Chris Ferdinandi
55
* MIT License
@@ -503,8 +503,8 @@
503503
// Don't run if the user prefers reduced motion
504504
if (reduceMotion(settings)) return;
505505

506-
// Don't run if right-click or command/control + click
507-
if (event.button !== 0 || event.metaKey || event.ctrlKey) return;
506+
// Don't run if right-click or command/control + click or shift + click
507+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey) return;
508508

509509
// Check if event.target has closest() method
510510
// By @totegi - https://github.com/cferdinandi/smooth-scroll/pull/401/
@@ -589,7 +589,7 @@
589589
* Initialize Smooth Scroll
590590
* @param {Object} options User settings
591591
*/
592-
smoothScroll.init = function (options) {
592+
var init = function () {
593593

594594
// feature test
595595
if (!supports()) throw 'Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.';
@@ -616,7 +616,7 @@
616616
// Initialize plugin
617617
//
618618

619-
smoothScroll.init(options);
619+
init();
620620

621621

622622
//

dist/smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/smooth-scroll.polyfills.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v15.2.1
2+
* smooth-scroll v16.0.1
33
* Animate scrolling to anchor links
44
* (c) 2019 Chris Ferdinandi
55
* MIT License
@@ -573,8 +573,8 @@ if (window.Element && !Element.prototype.closest) {
573573
// Don't run if the user prefers reduced motion
574574
if (reduceMotion(settings)) return;
575575

576-
// Don't run if right-click or command/control + click
577-
if (event.button !== 0 || event.metaKey || event.ctrlKey) return;
576+
// Don't run if right-click or command/control + click or shift + click
577+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey) return;
578578

579579
// Check if event.target has closest() method
580580
// By @totegi - https://github.com/cferdinandi/smooth-scroll/pull/401/
@@ -659,7 +659,7 @@ if (window.Element && !Element.prototype.closest) {
659659
* Initialize Smooth Scroll
660660
* @param {Object} options User settings
661661
*/
662-
smoothScroll.init = function (options) {
662+
var init = function () {
663663

664664
// feature test
665665
if (!supports()) throw 'Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.';
@@ -686,7 +686,7 @@ if (window.Element && !Element.prototype.closest) {
686686
// Initialize plugin
687687
//
688688

689-
smoothScroll.init(options);
689+
init();
690690

691691

692692
//

0 commit comments

Comments
 (0)