Skip to content

Commit 276d044

Browse files
committed
replace local utilities with tealight
1 parent 74bd433 commit 276d044

20 files changed

Lines changed: 32 additions & 468 deletions

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"url": "https://github.com/jlmakes/scrollreveal/issues"
3232
},
3333
"dependencies": {
34-
"rematrix": "^0.2.1"
34+
"rematrix": "^0.2.1",
35+
"tealight": "^0.1.0"
3536
},
3637
"devDependencies": {
3738
"chai": "^4.1.2",

src/instance/constructor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import sync from './methods/sync'
99
import delegate from './functions/delegate'
1010

1111
import { isMobile, transformSupported, transitionSupported } from '../utils/browser'
12-
import { getNode, logger } from '../utils/core'
13-
import { deepAssign } from '../utils/generic'
12+
import { logger } from '../utils/core'
13+
import { deepAssign, getNode } from 'tealight'
1414

1515
import { version } from '../../package.json'
1616

src/instance/functions/delegate.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import animate from './animate'
22
import sequence from './sequence'
33

4-
import { mathSign } from '../../polyfills/mathSign'
5-
import { requestAnimationFrame } from '../../polyfills/requestAnimationFrame'
4+
import { each, mathSign, raf } from 'tealight'
65
import { getGeometry, getScrolled, isElementVisible } from '../../utils/core'
7-
import { each } from '../../utils/generic'
86

97
export default function delegate (event = { type: 'init' }, elements = this.store.elements) {
10-
requestAnimationFrame(() => {
8+
raf(() => {
119
const stale = event.type === 'init' || event.type === 'resize'
1210

1311
each(this.store.containers, container => {

src/instance/functions/initialize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { each } from '../../utils/generic'
1+
import { each } from 'tealight'
22
import rinse from './rinse'
33

44
export default function initialize () {

src/instance/functions/rinse.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { each } from '../../utils/generic'
2-
import { getNodes } from '../../utils/core'
1+
import { each, getNodes } from 'tealight'
32

43
export default function rinse () {
54
const struct = () => ({

src/instance/functions/sequence.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import animate from './animate'
2-
import { each, nextUniqueId } from '../../utils/generic'
2+
import { each } from 'tealight'
3+
import { nextUniqueId } from '../../utils/generic'
34

45
export default function sequence (element, pristine = this.pristine) {
56
const seq = this.store.sequences[element.sequence.id]

src/instance/methods/clean.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { each } from '../../utils/generic'
2-
import { getNodes, logger } from '../../utils/core'
1+
import { each, getNodes } from 'tealight'
2+
import { logger } from '../../utils/core'
33
import rinse from '../functions/rinse'
44

55
export default function clean (target) {

src/instance/methods/destroy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { each } from '../../utils/generic'
1+
import { each } from 'tealight'
22

33
export default function destroy () {
44
/**

src/instance/methods/reveal.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import style from '../functions/style'
33
import initialize from '../functions/initialize'
44
import { Sequence } from '../functions/sequence'
55

6-
import { getNode, getNodes, logger } from '../../utils/core'
7-
import { deepAssign, each, nextUniqueId } from '../../utils/generic'
6+
import { deepAssign, each, getNode, getNodes } from 'tealight'
7+
import { logger } from '../../utils/core'
8+
import { nextUniqueId } from '../../utils/generic'
89
import { isMobile } from '../../utils/browser'
910

1011
export default function reveal (target, options, interval, sync) {
@@ -63,9 +64,9 @@ export default function reveal (target, options, interval, sync) {
6364
const config = deepAssign({}, element.config || this.defaults, options)
6465

6566
/**
66-
* Verify the current device passes our platform configuration,
67-
* and cache the result for the rest of the loop.
68-
*/
67+
* Verify the current device passes our platform configuration,
68+
* and cache the result for the rest of the loop.
69+
*/
6970
let disabled
7071
{
7172
if (disabled == null) {
@@ -115,10 +116,10 @@ export default function reveal (target, options, interval, sync) {
115116
}, [])
116117

117118
/**
118-
* Modifying the DOM via setAttribute needs to be handled
119-
* separately from reading computed styles in the map above
120-
* for the browser to batch DOM changes (limiting reflows)
121-
*/
119+
* Modifying the DOM via setAttribute needs to be handled
120+
* separately from reading computed styles in the map above
121+
* for the browser to batch DOM changes (limiting reflows)
122+
*/
122123
each(elements, element => {
123124
this.store.elements[element.id] = element
124125
element.node.setAttribute('data-sr-id', element.id)
@@ -144,16 +145,16 @@ export default function reveal (target, options, interval, sync) {
144145
}
145146

146147
/**
147-
* If reveal wasn't invoked by sync, we want to
148-
* make sure to add this call to the history.
149-
*/
148+
* If reveal wasn't invoked by sync, we want to
149+
* make sure to add this call to the history.
150+
*/
150151
if (!sync) {
151152
this.store.history.push({ target, options, interval })
152153

153154
/**
154-
* Push initialization to the event queue, giving
155-
* multiple reveal calls time to be interpreted.
156-
*/
155+
* Push initialization to the event queue, giving
156+
* multiple reveal calls time to be interpreted.
157+
*/
157158
if (this.initTimeout) {
158159
window.clearTimeout(this.initTimeout)
159160
}

src/instance/methods/sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import initialize from '../functions/initialize'
22
import reveal from './reveal'
33

4-
import { each } from '../../utils/generic'
4+
import { each } from 'tealight'
55

66
/**
77
* Re-runs the reveal method for each record stored in history,

0 commit comments

Comments
 (0)