-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreact-mmmt-swiper.js
More file actions
77 lines (67 loc) · 2.04 KB
/
Copy pathreact-mmmt-swiper.js
File metadata and controls
77 lines (67 loc) · 2.04 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"use strict";
(function (root, factory) {
if (typeof module !== "undefined" && module.exports) {
module.exports = factory(
require("react/addons"),
require("swiper")
);
} else {
root.ReactSwiper = factory(
root.React,
root.Swiper
);
}
})(this, function (React, Swiper) {
var styles = {
container: {
},
wrapper: {
alignItems: "center"
},
child: {
}
};
var ReactSwiper = React.createClass({
// http://www.idangero.us/swiper/api
propTypes: {
simulateTouch: React.PropTypes.bool,
initialSlide: React.PropTypes.number,
preloadImages: React.PropTypes.bool,
lazyLoading: React.PropTypes.bool,
lazyLoadingInPrevNext: React.PropTypes.bool,
lazyLoadingOnTransitionStart: React.PropTypes.bool
},
componentDidMount: function () {
if (this.isMounted()) {
this.swiper = Swiper(this.getDOMNode(), this.props);
// NOTE: Does not seem that initialSlide works with images
// NOTE: Lazy loading is also not helped
var initialSlide = this.props.initialSlide;
if (initialSlide) {
this.swiper.on("imagesReady", function() {
this.swiper.slideTo(initialSlide);
}.bind(this));
}
}
},
componentDidUpdate: function () {
},
componentWillUnmount: function () {
this.swiper.destroy();
delete this.swiper;
},
shouldComponentUpdate: function (nextProps) {
return (typeof this.props.shouldUpdate !== "undefined") && this.props.shouldUpdate(nextProps);
},
render: function() {
return React.createElement("div", React.__spread({}, this.props, {style: styles.container, className: "swiper-container"}),
React.createElement("div", {style: styles.wrapper, className: "swiper-wrapper"},
React.Children.map(this.props.children, function (child) {
return React.addons.cloneWithProps(child, { style: styles.child, className: "swiper-slide" });
})
)
);
}
});
return ReactSwiper;
});