695 lines
23 KiB
JavaScript

(window.webpackJsonp = window.webpackJsonp || []).push([
[5],
{
'1Ywk': function(D, l, p) {
'use strict';
p('9d8Q'), p('NtQs');
},
'9d8Q': function(D, l, p) {},
'9m3q': function(D, l, p) {},
'9m51': function(D, l, p) {
'use strict';
p('1Ywk'), p('9m3q');
},
NtQs: function(D, l, p) {},
Yec7: function(D, l, p) {
'use strict';
Object.defineProperty(l, '__esModule', { value: !0 }), (l.default = void 0);
var d = h(p('q1tI')),
O = v(p('TSYQ')),
P = v(p('l/UJ')),
w = v(p('sFww'));
function v(o) {
return o && o.__esModule ? o : { default: o };
}
function g() {
if (typeof WeakMap != 'function') return null;
var o = new WeakMap();
return (
(g = function() {
return o;
}),
o
);
}
function h(o) {
if (o && o.__esModule) return o;
if (o === null || (m(o) !== 'object' && typeof o != 'function')) return { default: o };
var n = g();
if (n && n.has(o)) return n.get(o);
var r = {},
e = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var t in o)
if (Object.prototype.hasOwnProperty.call(o, t)) {
var a = e ? Object.getOwnPropertyDescriptor(o, t) : null;
a && (a.get || a.set) ? Object.defineProperty(r, t, a) : (r[t] = o[t]);
}
return (r.default = o), n && n.set(o, r), r;
}
function m(o) {
return (
typeof Symbol == 'function' && typeof Symbol.iterator == 'symbol'
? (m = function(r) {
return typeof r;
})
: (m = function(r) {
return r &&
typeof Symbol == 'function' &&
r.constructor === Symbol &&
r !== Symbol.prototype
? 'symbol'
: typeof r;
}),
m(o)
);
}
function S(o, n, r) {
return (
n in o
? Object.defineProperty(o, n, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0,
})
: (o[n] = r),
o
);
}
function X(o, n) {
if (!(o instanceof n)) throw new TypeError('Cannot call a class as a function');
}
function I(o, n) {
for (var r = 0; r < n.length; r++) {
var e = n[r];
(e.enumerable = e.enumerable || !1),
(e.configurable = !0),
'value' in e && (e.writable = !0),
Object.defineProperty(o, e.key, e);
}
}
function x(o, n, r) {
return n && I(o.prototype, n), r && I(o, r), o;
}
function T(o, n) {
return n && (m(n) === 'object' || typeof n == 'function') ? n : R(o);
}
function R(o) {
if (o === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return o;
}
function M(o) {
return (
(M = Object.setPrototypeOf
? Object.getPrototypeOf
: function(r) {
return r.__proto__ || Object.getPrototypeOf(r);
}),
M(o)
);
}
function Y(o, n) {
if (typeof n != 'function' && n !== null)
throw new TypeError('Super expression must either be null or a function');
(o.prototype = Object.create(n && n.prototype, {
constructor: { value: o, writable: !0, configurable: !0 },
})),
n && C(o, n);
}
function C(o, n) {
return (
(C =
Object.setPrototypeOf ||
function(e, t) {
return (e.__proto__ = t), e;
}),
C(o, n)
);
}
var E = (function(o) {
Y(n, o);
function n(r) {
var e;
return (
X(this, n),
(e = T(this, M(n).call(this, r))),
(e.carouselItems = void 0),
(e.moveInterval = void 0),
(e.translateX = 0),
(e.translateY = 0),
(e.onSlideTo = function(t) {
e.onMoveTo(t, e.props.animationDuration);
}),
(e.onJumpTo = function(t) {
e.onMoveTo(t, 0);
}),
(e.onMoveTo = function(t, a) {
var i = e.carouselItems,
s = e.props,
u = s.loop,
f = s.children,
c = s.onChange,
_ = f.length,
b = e.state.activeIndex;
(e.translateX = -i.offsetWidth * (t + u)),
(e.translateY = -i.offsetHeight * (t + u)),
e.doTransition({ x: e.translateX, y: e.translateY }, a),
t > _ - 1 ? (t = 0) : t < 0 && (t = _ - 1);
var y = b !== t;
e.setState({ activeIndex: t, activeIndexChanged: y }),
typeof c == 'function' && y && c(t);
}),
(e.onDragStart = function() {
var t = e.props,
a = t.swipeable,
i = t.children;
if (!a) return !1;
var s = e.state.activeIndex,
u = i.length;
s <= 0 ? e.onJumpTo(0) : s >= u - 1 && e.onJumpTo(u - 1), e.pauseAutoPlay();
}),
(e.onDragMove = function(t, a) {
var i = a.offsetX,
s = a.offsetY,
u = e.props.swipeable;
if (!u) return !1;
var f = Math.abs(i),
c = Math.abs(s);
if (e.isDirectionX() && (f < 5 || (f >= 5 && c >= 1.73 * f))) return !1;
if (!e.isDirectionX() && (c < 5 || (c >= 5 && f >= 1.73 * c))) return !1;
if (!e.props.loop) {
if (
e.isLastIndex() &&
((e.isDirectionX() && i < 0) || (!e.isDirectionX() && s < 0))
)
return !1;
if (
e.isFirstIndex() &&
((e.isDirectionX() && i > 0) || (!e.isDirectionX() && s > 0))
)
return !1;
}
return (
t.preventDefault(),
e.doTransition({ x: e.translateX + i, y: e.translateY + s }, 0),
!0
);
}),
(e.onDragEnd = function(t, a) {
var i = a.offsetX,
s = a.offsetY,
u = a.startTime,
f = e.props.swipeable;
if (!f) return !1;
if (!i && !s) return;
var c = e.props,
_ = c.moveDistanceRatio,
b = c.moveTimeSpan,
y = e.state.activeIndex,
W = e.carouselItems,
q = new Date().getTime() - u.getTime(),
L = e.isDirectionX() ? Math.abs(i / W.offsetWidth) : Math.abs(s / W.offsetHeight);
if (L >= _ || q <= b) {
var U =
(e.isDirectionX() && i > 0) || (!e.isDirectionX() && s > 0) ? 'prev' : 'next';
y = U === 'next' ? y + 1 : y - 1;
}
e.onSlideTo(y), e.startAutoPlay();
}),
(e.startAutoPlay = function() {
var t = e.props,
a = t.direction,
i = t.loop,
s = t.autoPlay,
u = t.autoPlayIntervalTime;
e.moveInterval =
s &&
setInterval(function() {
var f = e.state.activeIndex,
c = ['left', 'up'].indexOf(a) > -1;
if (((f = c ? f + 1 : f - 1), !i && (c ? e.isLastIndex() : e.isFirstIndex()))) {
e.pauseAutoPlay();
return;
}
e.onSlideTo(f);
}, u);
}),
(e.pauseAutoPlay = function() {
e.moveInterval && clearInterval(e.moveInterval);
}),
(e.parseItems = function(t) {
if (t.children.length === 0) return;
var a = [].concat(t.children),
i = a[0],
s = a[a.length - 1];
t.loop && (a.push(i), a.unshift(s));
var u = d.default.Children.map(a, function(f, c) {
return (0,
d.cloneElement)(f, { key: c, className: (0, O.default)(''.concat(t.prefixCls, '__item'), f.props.className) });
});
return u;
}),
(e.resize = function() {
e.onJumpTo(e.state.activeIndex);
}),
(e.doTransition = function(t, a) {
var i = e.carouselItems,
s = 0,
u = 0;
e.isDirectionX() ? (s = t.x) : (u = t.y),
(i.style.WebkitTransformDuration = ''.concat(a, 'ms')),
(i.style.transitionDuration = ''.concat(a, 'ms')),
(i.style.WebkitTransform = 'translate3d('.concat(s, 'px, ').concat(u, 'px, 0)')),
(i.style.transform = 'translate3d('.concat(s, 'px, ').concat(u, 'px, 0)'));
}),
(e.transitionEnd = function() {
var t = e.props.onChangeEnd,
a = e.state,
i = a.activeIndex,
s = a.activeIndexChanged,
u = e.carouselItems;
(e.translateX = -u.offsetWidth * (i + e.props.loop)),
(e.translateY = -u.offsetHeight * (i + e.props.loop)),
e.doTransition({ x: e.translateX, y: e.translateY }, 0),
typeof t == 'function' && s && t(i);
}),
(e.isLastIndex = function() {
return e.state.activeIndex >= e.props.children.length - 1;
}),
(e.isFirstIndex = function() {
return e.state.activeIndex <= 0;
}),
(e.isDirectionX = function() {
return ['left', 'right'].indexOf(e.props.direction) > -1;
}),
(e.renderPaginationItem = function(t, a) {
var i = e.props.prefixCls,
s = (0, O.default)(
''.concat(i, '__pagination__item'),
S({}, ''.concat(i, '__pagination__item--active'), a === e.state.activeIndex),
);
return d.default.createElement('div', {
key: 'pagination-'.concat(a),
className: s,
onClick: function() {
return e.onSlideTo(a);
},
});
}),
(e.renderPagination = function() {
var t = e.props,
a = t.prefixCls,
i = t.showPagination,
s = t.children;
return (
i &&
d.default.createElement(
'div',
{ className: ''.concat(a, '__pagination') },
d.Children.map(s, e.renderPaginationItem),
)
);
}),
(e.state = { activeIndex: r.activeIndex, activeIndexChanged: !1 }),
e
);
}
return (
x(n, [
{
key: 'componentDidMount',
value: function() {
var e = this.props.activeIndex;
P.default.on(window, 'resize', this.resize), this.startAutoPlay(), this.onJumpTo(e);
},
},
{
key: 'componentDidUpdate',
value: function(e) {
var t = this.props.activeIndex;
t !== e.activeIndex && this.onSlideTo(t);
},
},
{
key: 'componentWillUnmount',
value: function() {
this.pauseAutoPlay(),
P.default.off(window, 'resize', this.resize),
P.default.off(this.carouselItems, 'webkitTransitionEnd', this.transitionEnd),
P.default.off(this.carouselItems, 'transitionend', this.transitionEnd);
},
},
{
key: 'render',
value: function() {
var e = this,
t = this.props,
a = t.prefixCls,
i = t.className,
s = t.height,
u = t.style,
f = this.parseItems(this.props),
c = {},
_ = this.isDirectionX() ? 'horizontal' : 'vertical',
b = (0, O.default)(a, i, ''.concat(a, '--').concat(_));
this.isDirectionX() || (c.height = s);
var y = d.default.createElement(
'div',
{
ref: function(q) {
e.carouselItems = q;
},
className: ''.concat(a, '__items'),
onTransitionEnd: this.transitionEnd,
style: c,
},
f,
);
return d.default.createElement(
'div',
{ className: b, style: u },
d.default.createElement(
w.default,
{
onDragStart: this.onDragStart,
onDragMove: this.onDragMove,
onDragEnd: this.onDragEnd,
},
y,
),
this.renderPagination(),
);
},
},
]),
n
);
})(d.Component);
(l.default = E),
(E.defaultProps = {
prefixCls: 'za-carousel',
direction: 'left',
height: 160,
loop: !1,
activeIndex: 0,
animationDuration: 300,
swipeable: !0,
autoPlay: !1,
autoPlayIntervalTime: 3e3,
moveDistanceRatio: 0.5,
moveTimeSpan: 300,
showPagination: !0,
});
},
'l/UJ': function(D, l, p) {
'use strict';
Object.defineProperty(l, '__esModule', { value: !0 }), (l.default = void 0);
var d = !1;
try {
var O = Object.defineProperty({}, 'passive', {
get: function() {
return (d = !0), !0;
},
});
window.addEventListener('test', function() {}, O);
} catch (w) {}
var P = {
on: function(v, g, h) {
var m = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : { passive: !1 };
v.addEventListener
? v.addEventListener(g, h, d ? m : !1)
: v.attachEvent('on '.concat(g), function() {
h.call(v);
});
},
off: function(v, g, h) {
var m = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : { passive: !1 };
v.removeEventListener
? v.removeEventListener(g, h, d ? m : !1)
: v.detachEvent('off '.concat(g), h);
},
once: function(v, g, h) {
for (
var m =
arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : { passive: !1 },
S = g.split(' '),
X = function x(T) {
return T.target.removeEventListener(T.type, x, d ? m : !1), h(T);
},
I = S.length - 1;
I >= 0;
I -= 1
)
this.on(v, S[I], X);
},
};
l.default = P;
},
mZhq: function(D, l, p) {
'use strict';
},
sFww: function(D, l, p) {
'use strict';
Object.defineProperty(l, '__esModule', { value: !0 }),
Object.defineProperty(l, 'DragProps', {
enumerable: !0,
get: function() {
return P.default;
},
}),
Object.defineProperty(l, 'DragEvent', {
enumerable: !0,
get: function() {
return P.DragEvent;
},
}),
Object.defineProperty(l, 'DragState', {
enumerable: !0,
get: function() {
return P.DragState;
},
}),
(l.default = void 0);
var d = p('q1tI'),
O = g(p('l/UJ')),
P = v(p('mZhq'));
function w() {
if (typeof WeakMap != 'function') return null;
var n = new WeakMap();
return (
(w = function() {
return n;
}),
n
);
}
function v(n) {
if (n && n.__esModule) return n;
if (n === null || (h(n) !== 'object' && typeof n != 'function')) return { default: n };
var r = w();
if (r && r.has(n)) return r.get(n);
var e = {},
t = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var a in n)
if (Object.prototype.hasOwnProperty.call(n, a)) {
var i = t ? Object.getOwnPropertyDescriptor(n, a) : null;
i && (i.get || i.set) ? Object.defineProperty(e, a, i) : (e[a] = n[a]);
}
return (e.default = n), r && r.set(n, e), e;
}
function g(n) {
return n && n.__esModule ? n : { default: n };
}
function h(n) {
return (
typeof Symbol == 'function' && typeof Symbol.iterator == 'symbol'
? (h = function(e) {
return typeof e;
})
: (h = function(e) {
return e &&
typeof Symbol == 'function' &&
e.constructor === Symbol &&
e !== Symbol.prototype
? 'symbol'
: typeof e;
}),
h(n)
);
}
function m(n, r) {
var e = Object.keys(n);
if (Object.getOwnPropertySymbols) {
var t = Object.getOwnPropertySymbols(n);
r &&
(t = t.filter(function(a) {
return Object.getOwnPropertyDescriptor(n, a).enumerable;
})),
e.push.apply(e, t);
}
return e;
}
function S(n) {
for (var r = 1; r < arguments.length; r++) {
var e = arguments[r] != null ? arguments[r] : {};
r % 2
? m(Object(e), !0).forEach(function(t) {
X(n, t, e[t]);
})
: Object.getOwnPropertyDescriptors
? Object.defineProperties(n, Object.getOwnPropertyDescriptors(e))
: m(Object(e)).forEach(function(t) {
Object.defineProperty(n, t, Object.getOwnPropertyDescriptor(e, t));
});
}
return n;
}
function X(n, r, e) {
return (
r in n
? Object.defineProperty(n, r, {
value: e,
enumerable: !0,
configurable: !0,
writable: !0,
})
: (n[r] = e),
n
);
}
function I(n, r) {
if (!(n instanceof r)) throw new TypeError('Cannot call a class as a function');
}
function x(n, r) {
for (var e = 0; e < r.length; e++) {
var t = r[e];
(t.enumerable = t.enumerable || !1),
(t.configurable = !0),
'value' in t && (t.writable = !0),
Object.defineProperty(n, t.key, t);
}
}
function T(n, r, e) {
return r && x(n.prototype, r), e && x(n, e), n;
}
function R(n, r) {
return r && (h(r) === 'object' || typeof r == 'function') ? r : M(n);
}
function M(n) {
if (n === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return n;
}
function Y(n) {
return (
(Y = Object.setPrototypeOf
? Object.getPrototypeOf
: function(e) {
return e.__proto__ || Object.getPrototypeOf(e);
}),
Y(n)
);
}
function C(n, r) {
if (typeof r != 'function' && r !== null)
throw new TypeError('Super expression must either be null or a function');
(n.prototype = Object.create(r && r.prototype, {
constructor: { value: n, writable: !0, configurable: !0 },
})),
r && E(n, r);
}
function E(n, r) {
return (
(E =
Object.setPrototypeOf ||
function(t, a) {
return (t.__proto__ = a), t;
}),
E(n, r)
);
}
var o = (function(n) {
C(r, n);
function r() {
var e, t;
I(this, r);
for (var a = arguments.length, i = new Array(a), s = 0; s < a; s++) i[s] = arguments[s];
return (
(t = R(this, (e = Y(r)).call.apply(e, [this].concat(i)))),
(t.currentX = void 0),
(t.currentY = void 0),
(t.dragState = Object.create(null)),
(t.onTouchStart = function(u) {
if (((t.dragState.startTime = new Date()), !u.touches))
(t.dragState.startX = u.clientX),
(t.dragState.startY = u.clientY),
O.default.on(document.body, 'mousemove', t.onTouchMove),
O.default.on(document.body, 'mouseup', t.onTouchEnd);
else {
var f = u.touches[0];
(t.dragState.startX = f.pageX), (t.dragState.startY = f.pageY);
}
var c = S({}, t.dragState),
_ = t.props.onDragStart;
typeof _ == 'function' && _(u, c);
}),
(t.onTouchMove = function(u) {
if (!t.isDragStart) return !1;
if (!u.touches) (t.currentX = u.clientX), (t.currentY = u.clientY);
else {
var f = u.touches[0];
(t.currentX = f.pageX), (t.currentY = f.pageY);
}
var c = t.currentX - t.dragState.startX,
_ = t.currentY - t.dragState.startY,
b = S({}, t.dragState, { offsetX: c, offsetY: _ }),
y = t.props.onDragMove;
if (typeof y == 'function' && !y(u, b)) return;
t.dragState = b;
}),
(t.onTouchEnd = function(u) {
if (!t.isDragStart) return !1;
u &&
!u.touches &&
(O.default.off(document.body, 'mousemove', t.onTouchMove),
O.default.off(document.body, 'mouseup', t.onTouchEnd));
var f = t.props.onDragEnd;
typeof f == 'function' && f(u, t.dragState), (t.dragState = Object.create(null));
}),
t
);
}
return (
T(r, [
{
key: 'render',
value: function() {
var t = this.props.children;
return (0, d.cloneElement)(t, {
onTouchStart: this.onTouchStart,
onTouchMove: this.onTouchMove,
onTouchEnd: this.onTouchEnd,
onMouseDown: this.onTouchStart,
onMouseMove: this.onTouchMove,
onMouseUp: this.onTouchEnd,
});
},
},
{
key: 'isDragStart',
get: function() {
return this.dragState.startX !== void 0 && this.dragState.startY !== void 0;
},
},
]),
r
);
})(d.PureComponent);
l.default = o;
},
},
]);
//# sourceMappingURL=5.js.map