Completed
Push — master ( f00ccc...4f9f1a )
by Jeroen De
56:57 queued 22:00
created

ElementAnimator.showElement   A

Complexity

Conditions 1
Paths 0

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 0
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
'use strict';
2
3
var objectAssign = require( 'object-assign' ),
4
5
	ElementAnimator = {
6
		el: null,
7
		showElement: function () {
8
			throw new Error( 'This is an abstract class!' );
9
		},
10
		hideElement: function () {
11
			throw new Error( 'This is an abstract class!' );
12
		}
13
	},
14
15
	SlidingElementAnimator = objectAssign( Object.create( ElementAnimator ), {
16
		// internal fields
17
		slideSpeed: 600,
18
19
		showElement: function () {
20
			this.el
21
				.slideDown( this.slideSpeed )
22
				.animate(
23
					{ opacity: 1 },
24
					{ queue: false, duration: this.slideSpeed }
25
				);
26
		},
27
		hideElement: function () {
28
			this.el
29
				.slideUp( this.slideSpeed )
30
				.animate(
31
					{ opacity: 0 },
32
					{ queue: false, duration: this.slideSpeed }
33
				);
34
		}
35
	} ),
36
37
	SimpleElementAnimator = objectAssign( Object.create( ElementAnimator ), {
38
		showElement: function () {
39
			this.el.show();
40
		},
41
		hideElement: function () {
42
			this.el.hide();
43
		}
44
	} );
45
46
module.exports = {
47
	createSimpleElementAnimator: function ( element ) {
48
		return objectAssign(
49
			Object.create( SimpleElementAnimator ),
50
			{ el: element }
51
		);
52
	},
53
54
	createSlidingElementAnimator: function ( element ) {
55
		return objectAssign(
56
			Object.create( SlidingElementAnimator ),
57
			{ el: element }
58
		);
59
	},
60
61
	ElementAnimator: ElementAnimator
62
};
63