all files / lib/src/instance/functions/ delegate.js

5% Statements 1/20
0% Branches 0/5
0% Functions 0/6
5.88% Lines 1/17
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                                                                           
import animate from './animate'
 
import { requestAnimationFrame } from '../../polyfills/requestAnimationFrame'
import { getGeometry, getScrolled } from '../../utils/core'
import { each } from '../../utils/generic'
 
 
export default function delegate (event) {
	var this$1 = this;
	if ( event === void 0 ) event = {};
 
	requestAnimationFrame(function () {
		var containers = this$1.store.containers
		var elements = this$1.store.elements
 
		switch (event.type) {
 
			case 'scroll':
				each(containers, function (container) { return container.scroll = getScrolled.call(this$1, container); })
				each(elements, function (element) { return animate.call(this$1, element); })
				break
 
			case 'resize':
			default:
				each(containers, function (container) {
					container.geometry = getGeometry.call(this$1, container, /* isContainer: */ true)
					container.scroll = getScrolled.call(this$1, container)
				})
				each(elements, function (element) {
					element.geometry = getGeometry.call(this$1, element)
					animate.call(this$1, element)
				})
		}
 
		this$1.pristine = false
	})
}