forked from jlmakes/scrollreveal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.js
More file actions
34 lines (32 loc) · 840 Bytes
/
clean.js
File metadata and controls
34 lines (32 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import $ from 'tealight'
import each from '../../utils/each'
import logger from '../../utils/logger'
import rinse from '../functions/rinse'
import { applyStyle } from '../functions/style'
export default function clean(target) {
let dirty
try {
each($(target), node => {
const id = node.getAttribute('data-sr-id')
if (id !== null) {
dirty = true
const element = this.store.elements[id]
if (element.callbackTimer) {
window.clearTimeout(element.callbackTimer.clock)
}
applyStyle(element.node, element.styles.inline.generated)
node.removeAttribute('data-sr-id')
delete this.store.elements[id]
}
})
} catch (e) {
return logger.call(this, 'Clean failed.', e.message)
}
if (dirty) {
try {
rinse.call(this)
} catch (e) {
return logger.call(this, 'Clean failed.', e.message)
}
}
}