1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 |
|
5 | var _dom = require('element-ui/lib/utils/dom');
|
6 |
|
7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8 |
|
9 | var Transition = function () {
|
10 | function Transition() {
|
11 | _classCallCheck(this, Transition);
|
12 | }
|
13 |
|
14 | Transition.prototype.beforeEnter = function beforeEnter(el) {
|
15 | (0, _dom.addClass)(el, 'collapse-transition');
|
16 | if (!el.dataset) el.dataset = {};
|
17 |
|
18 | el.dataset.oldPaddingTop = el.style.paddingTop;
|
19 | el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
20 |
|
21 | el.style.height = '0';
|
22 | el.style.paddingTop = 0;
|
23 | el.style.paddingBottom = 0;
|
24 | };
|
25 |
|
26 | Transition.prototype.enter = function enter(el) {
|
27 | el.dataset.oldOverflow = el.style.overflow;
|
28 | if (el.scrollHeight !== 0) {
|
29 | el.style.height = el.scrollHeight + 'px';
|
30 | el.style.paddingTop = el.dataset.oldPaddingTop;
|
31 | el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
32 | } else {
|
33 | el.style.height = '';
|
34 | el.style.paddingTop = el.dataset.oldPaddingTop;
|
35 | el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
36 | }
|
37 |
|
38 | el.style.overflow = 'hidden';
|
39 | };
|
40 |
|
41 | Transition.prototype.afterEnter = function afterEnter(el) {
|
42 |
|
43 | (0, _dom.removeClass)(el, 'collapse-transition');
|
44 | el.style.height = '';
|
45 | el.style.overflow = el.dataset.oldOverflow;
|
46 | };
|
47 |
|
48 | Transition.prototype.beforeLeave = function beforeLeave(el) {
|
49 | if (!el.dataset) el.dataset = {};
|
50 | el.dataset.oldPaddingTop = el.style.paddingTop;
|
51 | el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
52 | el.dataset.oldOverflow = el.style.overflow;
|
53 |
|
54 | el.style.height = el.scrollHeight + 'px';
|
55 | el.style.overflow = 'hidden';
|
56 | };
|
57 |
|
58 | Transition.prototype.leave = function leave(el) {
|
59 | if (el.scrollHeight !== 0) {
|
60 |
|
61 | (0, _dom.addClass)(el, 'collapse-transition');
|
62 | el.style.height = 0;
|
63 | el.style.paddingTop = 0;
|
64 | el.style.paddingBottom = 0;
|
65 | }
|
66 | };
|
67 |
|
68 | Transition.prototype.afterLeave = function afterLeave(el) {
|
69 | (0, _dom.removeClass)(el, 'collapse-transition');
|
70 | el.style.height = '';
|
71 | el.style.overflow = el.dataset.oldOverflow;
|
72 | el.style.paddingTop = el.dataset.oldPaddingTop;
|
73 | el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
74 | };
|
75 |
|
76 | return Transition;
|
77 | }();
|
78 |
|
79 | exports.default = {
|
80 | name: 'ElCollapseTransition',
|
81 | functional: true,
|
82 | render: function render(h, _ref) {
|
83 | var children = _ref.children;
|
84 |
|
85 | var data = {
|
86 | on: new Transition()
|
87 | };
|
88 |
|
89 | return h('transition', data, children);
|
90 | }
|
91 | }; |
\ | No newline at end of file |