Skip to content

Commit b39aa08

Browse files
committed
refactor sequence instantiation
1 parent b60535e commit b39aa08

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
### Changed
2020
- **Breaking:** The `reveal()` method no longer accepts an `interval` parameter. Instead, sequence intervals are now defined with `options.interval`.
21-
- **Breaking:** The `reveal()` method will not accept sequence intervals less than 16 milliseconds.
2221
- **Breaking:** The instance method `isSupported()` is now static.
2322
- **Breaking:** `options.distance` supports only `em` `px` and `%` values.
2423
- **Breaking:** ScrollReveal methods are no longer chainable.

src/instance/functions/sequence.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ export default function sequence(element, pristine = this.pristine) {
6464
}
6565

6666
export function Sequence(interval) {
67-
if (Math.abs(interval) < 16) {
68-
throw new RangeError('Sequence interval must be at least 16.')
69-
} else {
70-
this.id = nextUniqueId()
71-
this.interval = Math.abs(interval)
72-
this.members = []
73-
this.models = {}
74-
this.blocked = {
75-
head: false,
76-
foot: false
77-
}
67+
const i = Math.abs(interval)
68+
if (i === 0) {
69+
return null
70+
}
71+
this.id = nextUniqueId()
72+
this.interval = Math.max(i, 16)
73+
this.members = []
74+
this.models = {}
75+
this.blocked = {
76+
head: false,
77+
foot: false
7878
}
7979
}
8080

src/instance/methods/reveal.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import tealight from 'tealight'
22

3+
import defaults from '../defaults'
4+
35
import clean from '../methods/clean'
46

57
import style from '../functions/style'
@@ -14,13 +16,9 @@ import nextUniqueId from '../../utils/next-unique-id'
1416

1517
export default function reveal(target, options = {}, syncing = false) {
1618
const containerBuffer = []
17-
let sequence
19+
const sequence = new Sequence(options.interval || defaults.interval)
1820

1921
try {
20-
if (options.interval) {
21-
sequence = new Sequence(options.interval)
22-
}
23-
2422
const nodes = tealight(target)
2523
if (!nodes.length) {
2624
throw new Error('Invalid reveal target.')

0 commit comments

Comments
 (0)