UNPKG

3.98 kBJavaScriptView Raw
1var _class, _temp;
2
3function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
4
5function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
10
11import React, { Component } from 'react';
12import PropTypes from 'prop-types';
13import Page from './../Page';
14import Instance from './instance.js';
15
16var PagePull = (_temp = _class = function (_Component) {
17 _inherits(PagePull, _Component);
18
19 function PagePull(props, context) {
20 _classCallCheck(this, PagePull);
21
22 var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
23
24 _this.componentDidMount = function () {
25 var instance = new Instance(_this.$el, {
26 drag: true,
27 transition: _this.props.transition || 'push',
28 onShowedLeft: _this.props.onShowedLeft,
29 onShowedRight: _this.props.onShowedRight
30 });
31 _this.instance = instance;
32 };
33
34 return _this;
35 }
36
37 PagePull.prototype.render = function render() {
38 var _this2 = this;
39
40 var _props = this.props,
41 lSide = _props.lSide,
42 lSideStyle = _props.lSideStyle,
43 lSideClassName = _props.lSideClassName,
44 rSide = _props.rSide,
45 rSideStyle = _props.rSideStyle,
46 rSideClassName = _props.rSideClassName,
47 drag = _props.drag,
48 children = _props.children,
49 transition = _props.transition,
50 others = _objectWithoutProperties(_props, ['lSide', 'lSideStyle', 'lSideClassName', 'rSide', 'rSideStyle', 'rSideClassName', 'drag', 'children', 'transition']);
51
52 return React.createElement(
53 'div',
54 { className: 'page-pull', ref: function ref(el) {
55 _this2.$el = el;
56 } },
57 React.createElement(
58 Page,
59 others,
60 children,
61 React.createElement('div', { className: 'mask' })
62 ),
63 lSide && React.createElement(
64 'aside',
65 { className: 'page-side-left' + (lSideClassName ? ' ' + lSideClassName : ''), style: lSideStyle, 'data-transition': transition, ref: function ref(el) {
66 _this2.$lSide = el;
67 } },
68 lSide
69 ),
70 rSide && React.createElement(
71 'aside',
72 { className: 'page-side-right' + (rSideClassName ? ' ' + rSideClassName : ''), style: rSideStyle, 'data-transition': transition, ref: function ref(el) {
73 _this2.$rSide = el;
74 } },
75 rSide
76 )
77 );
78 };
79
80 return PagePull;
81}(Component), _class.defaultProps = {
82 drag: true,
83 transition: 'push'
84}, _temp);
85export { PagePull as default };
86PagePull.propTypes = process.env.NODE_ENV !== "production" ? {
87 // Page
88 children: PropTypes.node,
89 // Side 侧边栏
90 drag: PropTypes.bool,
91 lSide: PropTypes.node, // 左侧边栏
92 lSideStyle: PropTypes.object,
93 lSideClassName: PropTypes.string,
94 rSide: PropTypes.node, // 右侧边栏
95 rSideStyle: PropTypes.object,
96 rSideClassName: PropTypes.string,
97 transition: PropTypes.string, // 过渡动画, push | reveal
98 onShowedLeft: PropTypes.func,
99 onShowedRight: PropTypes.func
100} : {};
\No newline at end of file