all files / lib/src/instance/methods/ destroy.js

8.33% Statements 1/12
0% Branches 0/2
0% Functions 0/3
8.33% Lines 1/12
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 35 36 37 38 39 40                                                                             
import { each } from '../../utils/generic'
 
 
export default function destroy () {
	var this$1 = this;
 
 
	/**
	 * Remove all generated styles and element ids
	 */
	each(this.store.elements, function (element) {
		element.node.setAttribute('style', element.styles.inline)
		element.node.removeAttribute('data-sr-id')
	})
 
	/**
	 * Remove all event listeners.
	 */
	each(this.store.containers, function (container) {
		if (container.node === document.documentElement) {
			window.removeEventListener('scroll', this$1.delegate)
			window.removeEventListener('resize', this$1.delegate)
		} else {
			container.node.removeEventListener('scroll', this$1.delegate)
			container.node.removeEventListener('resize', this$1.delegate)
		}
	})
 
	/**
	 * Clear all data from the store
	 */
	this.store = {
		containers: {},
		elements: {},
		history: [],
		sequences: {},
	}
}