@egjs/react-flicking
Advanced tools
Comparing version 4.10.8 to 4.10.9
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/egjs-flicking/tree/master/packages/react-flicking | ||
version: 4.10.8 | ||
version: 4.10.9 | ||
*/ | ||
@@ -18,3 +18,3 @@ 'use strict'; | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -33,4 +33,4 @@ | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function (d, b) { | ||
@@ -44,14 +44,10 @@ extendStatics = Object.setPrototypeOf || { | ||
}; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
@@ -63,9 +59,6 @@ } | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
@@ -75,5 +68,3 @@ }; | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
@@ -86,4 +77,4 @@ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; | ||
var c = arguments.length, | ||
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, | ||
d; | ||
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, | ||
d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
@@ -98,3 +89,2 @@ return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
@@ -108,3 +98,2 @@ function fulfilled(value) { | ||
} | ||
function rejected(value) { | ||
@@ -117,7 +106,5 @@ try { | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -128,14 +115,14 @@ }); | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
f, | ||
y, | ||
t, | ||
g; | ||
return g = { | ||
@@ -148,3 +135,2 @@ next: verb(0), | ||
}), g; | ||
function verb(n) { | ||
@@ -155,10 +141,7 @@ return function (v) { | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
@@ -169,3 +152,2 @@ case 0: | ||
break; | ||
case 4: | ||
@@ -177,3 +159,2 @@ _.label++; | ||
}; | ||
case 5: | ||
@@ -184,10 +165,6 @@ _.label++; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
@@ -198,3 +175,2 @@ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
@@ -204,3 +180,2 @@ _.label = op[1]; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
@@ -211,18 +186,11 @@ _.label = t[1]; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
@@ -235,3 +203,2 @@ } catch (e) { | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
@@ -281,23 +248,15 @@ return { | ||
var ReactRenderer = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var ReactRenderer = /*#__PURE__*/function (_super) { | ||
__extends(ReactRenderer, _super); | ||
function ReactRenderer(options) { | ||
var _this = _super.call(this, options) || this; | ||
_this._reactFlicking = options.reactFlicking; | ||
return _this; | ||
} // eslint-disable-next-line @typescript-eslint/require-await | ||
} | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
var __proto = ReactRenderer.prototype; | ||
__proto.render = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var flicking, reactFlicking, strategy; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -310,10 +269,6 @@ flicking = VanillaFlicking.getFlickingAttached(this._flicking); | ||
strategy.renderPanels(flicking); | ||
return [2 | ||
/*return*/ | ||
, new Promise(function (resolve) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
reactFlicking.renderEmitter.once("render", function () { | ||
_this._rendering = false; | ||
_this._afterRender(); | ||
resolve(); | ||
@@ -326,9 +281,6 @@ }); | ||
}; | ||
__proto.forceRenderAllPanels = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var reactFlicking; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -339,12 +291,6 @@ switch (_a.label) { | ||
this._rendering = true; | ||
return [4 | ||
/*yield*/ | ||
, _super.prototype.forceRenderAllPanels.call(this)]; | ||
return [4 /*yield*/, _super.prototype.forceRenderAllPanels.call(this)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 | ||
/*return*/ | ||
, new Promise(function (resolve) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
reactFlicking.renderEmitter.once("render", function () { | ||
@@ -360,9 +306,6 @@ _this._rendering = false; | ||
}; | ||
__proto.destroy = function () { | ||
_super.prototype.destroy.call(this); | ||
this._reactFlicking.renderEmitter.off("render"); | ||
}; | ||
__proto._collectPanels = function () { | ||
@@ -374,18 +317,12 @@ var flicking = VanillaFlicking.getFlickingAttached(this._flicking); | ||
}; | ||
__proto._createPanel = function (externalComponent, options) { | ||
return this._strategy.createPanel(externalComponent, options); | ||
}; | ||
return ReactRenderer; | ||
}(VanillaFlicking.ExternalRenderer); | ||
var StrictPanel = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var StrictPanel = /*#__PURE__*/function (_super) { | ||
__extends(StrictPanel, _super); | ||
function StrictPanel() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._hide = false; | ||
@@ -395,3 +332,2 @@ _this._elRef = React.createRef(); | ||
} | ||
var __proto = StrictPanel.prototype; | ||
@@ -412,15 +348,11 @@ Object.defineProperty(__proto, "nativeElement", { | ||
}); | ||
__proto.render = function () { | ||
return this._hide ? React.createElement(React.Fragment, null) : this._getElement(); | ||
}; | ||
__proto.show = function () { | ||
this._hide = false; | ||
}; | ||
__proto.hide = function () { | ||
this._hide = true; | ||
}; | ||
__proto._getElement = function () { | ||
@@ -431,18 +363,12 @@ return React.cloneElement(React.Children.only(this.props.children), { | ||
}; | ||
return StrictPanel; | ||
}(React.Component); | ||
var NonStrictPanel = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var NonStrictPanel = /*#__PURE__*/function (_super) { | ||
__extends(NonStrictPanel, _super); | ||
function NonStrictPanel() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._hide = false; | ||
return _this; | ||
} | ||
var __proto = NonStrictPanel.prototype; | ||
@@ -463,15 +389,11 @@ Object.defineProperty(__proto, "nativeElement", { | ||
}); | ||
__proto.render = function () { | ||
return this._hide ? React.createElement(React.Fragment, null) : this.props.children; | ||
}; | ||
__proto.show = function () { | ||
this._hide = false; | ||
}; | ||
__proto.hide = function () { | ||
this._hide = true; | ||
}; | ||
return NonStrictPanel; | ||
@@ -488,9 +410,6 @@ }(React.Component); | ||
var ReactElementProvider = | ||
/*#__PURE__*/ | ||
function () { | ||
var ReactElementProvider = /*#__PURE__*/function () { | ||
function ReactElementProvider(el) { | ||
this._el = el; | ||
} | ||
var __proto = ReactElementProvider.prototype; | ||
@@ -511,27 +430,18 @@ Object.defineProperty(__proto, "element", { | ||
}); | ||
__proto.show = function () { | ||
this._el.show(); | ||
}; | ||
__proto.hide = function () { | ||
this._el.hide(); | ||
}; | ||
return ReactElementProvider; | ||
}(); | ||
var Flicking = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var Flicking = /*#__PURE__*/function (_super) { | ||
__extends(Flicking, _super); | ||
function Flicking(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this._panels = []; | ||
_this._renderEmitter = new Component(); | ||
var children = _this._getChildren(); | ||
_this._panels = _this._createPanelRefs(props, children); | ||
@@ -541,3 +451,2 @@ _this._prevChildren = children; | ||
} | ||
var __proto = Flicking.prototype; | ||
@@ -560,3 +469,2 @@ Object.defineProperty(__proto, "reactPanels", { | ||
}); | ||
__proto.componentDidMount = function () { | ||
@@ -575,5 +483,3 @@ var props = this.props; | ||
this._vanillaFlicking = flicking; | ||
var children = this._getChildren(); | ||
this._jsxDiffer = new ListDiffer(children, function (panel) { | ||
@@ -584,7 +490,4 @@ return panel.key; | ||
this._prevChildren = children; | ||
this._bindEvents(); | ||
this._checkPlugins(); | ||
if (props.status) { | ||
@@ -594,9 +497,6 @@ flicking.setStatus(props.status); | ||
}; | ||
__proto.componentWillUnmount = function () { | ||
var _a; | ||
(_a = this._vanillaFlicking) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
}; | ||
__proto.shouldComponentUpdate = function (nextProps) { | ||
@@ -606,6 +506,4 @@ var vanillaFlicking = this._vanillaFlicking; | ||
if (!vanillaFlicking || !vanillaFlicking.initialized) return false; | ||
var children = nextProps.children, | ||
restProps = __rest(nextProps, ["children"]); | ||
restProps = __rest(nextProps, ["children"]); | ||
for (var key in restProps) { | ||
@@ -616,22 +514,16 @@ if (prevProps[key] !== nextProps[key]) { | ||
} | ||
var prevChildren = this._prevChildren; | ||
var nextChildren = this._getChildren(children); | ||
if (nextProps.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) return true; | ||
return false; | ||
}; | ||
__proto.beforeRender = function () { | ||
var vanillaFlicking = this._vanillaFlicking; | ||
var props = this.props; | ||
var prevChildren = this._prevChildren; // Ignore updates before init, they will be updated after "ready" event's force update | ||
var prevChildren = this._prevChildren; | ||
// Ignore updates before init, they will be updated after "ready" event's force update | ||
// Also, prevent updates when another update is already queued. | ||
// This usually happens when render() called twice without calling componentDidMount, like in the case of React.StrictMode. | ||
if (!vanillaFlicking || !vanillaFlicking.initialized || this._diffResult) return; | ||
var nextChildren = this._getChildren(props.children); | ||
if (props.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) { | ||
@@ -643,3 +535,2 @@ this._panels = this._createPanelRefs(props, nextChildren); | ||
}; | ||
__proto.componentDidUpdate = function () { | ||
@@ -649,12 +540,9 @@ var flicking = this._vanillaFlicking; | ||
var diffResult = this._diffResult; | ||
this._checkPlugins(); | ||
renderEmitter.trigger("render"); | ||
flicking.camera.updateOffset(); // Omit 'virtual', as it can't have any setter | ||
flicking.camera.updateOffset(); | ||
// Omit 'virtual', as it can't have any setter | ||
var _a = this.props; | ||
_a.virtual; | ||
var props = __rest(_a, ["virtual"]); | ||
_a.virtual; | ||
var props = __rest(_a, ["virtual"]); | ||
for (var key in props) { | ||
@@ -665,3 +553,2 @@ if (key in flicking && flicking[key] !== props[key]) { | ||
} | ||
if (!diffResult || !flicking.initialized) return; | ||
@@ -671,8 +558,5 @@ VanillaFlicking.sync(flicking, diffResult, this.reactPanels); | ||
}; | ||
__proto.render = function () { | ||
var _this = this; | ||
var _a, _b; | ||
var props = this.props; | ||
@@ -684,3 +568,2 @@ var Viewport = props.viewportTag; | ||
this.beforeRender(); | ||
for (var name in props) { | ||
@@ -691,3 +574,2 @@ if (!(name in DEFAULT_PROPS) && !(name in VanillaFlicking.prototype)) { | ||
} | ||
var initialized = flicking && flicking.initialized; | ||
@@ -697,19 +579,14 @@ var viewportClasses = ["flicking-viewport"]; | ||
var isHorizontal = flicking ? flicking.horizontal : (_a = props.horizontal) !== null && _a !== void 0 ? _a : true; | ||
if (!isHorizontal) { | ||
viewportClasses.push("vertical"); | ||
} | ||
if (props.hideBeforeInit && !initialized) { | ||
viewportClasses.push("flicking-hidden"); | ||
} | ||
if (attributes.className) { | ||
viewportClasses.push(attributes.className); | ||
} | ||
if (props.cameraClass) { | ||
cameraClasses.push(props.cameraClass); | ||
} | ||
var cameraProps = !initialized && props.firstPanelSize ? { | ||
@@ -730,6 +607,4 @@ style: { | ||
}; | ||
__proto._createPanelRefs = function (props, children) { | ||
var _a; | ||
var panelsPerView = (_a = props.panelsPerView) !== null && _a !== void 0 ? _a : -1; | ||
@@ -742,6 +617,4 @@ return panelsPerView > 0 && !!props.virtual ? VanillaFlicking.range(panelsPerView + 1).map(function () { | ||
}; | ||
__proto._bindEvents = function () { | ||
var _this = this; | ||
var flicking = this._vanillaFlicking; | ||
@@ -761,12 +634,9 @@ Object.keys(VanillaFlicking.EVENTS).forEach(function (eventKey) { | ||
}; | ||
__proto._checkPlugins = function () { | ||
var flicking = this._vanillaFlicking; | ||
var _a = this._pluginsDiffer.update(this.props.plugins), | ||
list = _a.list, | ||
added = _a.added, | ||
removed = _a.removed, | ||
prevList = _a.prevList; | ||
list = _a.list, | ||
added = _a.added, | ||
removed = _a.removed, | ||
prevList = _a.prevList; | ||
flicking.addPlugins.apply(flicking, added.map(function (index) { | ||
@@ -779,3 +649,2 @@ return list[index]; | ||
}; | ||
__proto._hasSameChildren = function (prevChildren, nextChildren) { | ||
@@ -785,3 +654,2 @@ if (prevChildren.length !== nextChildren.length || prevChildren.length === 0) return false; | ||
var nextChild = nextChildren[idx]; | ||
if (child.key && nextChild.key) { | ||
@@ -795,10 +663,7 @@ return child.key === nextChild.key; | ||
}; | ||
__proto._getChildren = function (children) { | ||
var _this = this; | ||
if (children === void 0) { | ||
children = this.props.children; | ||
} | ||
return React.Children.toArray(children).filter(function (child) { | ||
@@ -810,3 +675,2 @@ return child.type !== ViewportSlot; | ||
}; | ||
__proto._getViewportSlot = function () { | ||
@@ -817,6 +681,4 @@ return React.Children.toArray(this.props.children).filter(function (child) { | ||
}; | ||
__proto._unpackFragment = function (child) { | ||
var _this = this; | ||
return this._isFragment(child) ? React.Children.toArray(child.props.children).reduce(function (allChilds, fragChild) { | ||
@@ -826,8 +688,6 @@ return __spreadArray(__spreadArray([], allChilds, true), _this._unpackFragment(fragChild), true); | ||
}; | ||
__proto._getVirtualPanels = function () { | ||
var _this = this; | ||
var _a = this.props.virtual.panelClass, | ||
panelClass = _a === void 0 ? "flicking-panel" : _a; | ||
panelClass = _a === void 0 ? "flicking-panel" : _a; | ||
var panelsPerView = this.props.panelsPerView; | ||
@@ -853,8 +713,5 @@ var flicking = this._vanillaFlicking; | ||
}; | ||
__proto._getPanels = function () { | ||
var _this = this; | ||
var origChildren = this._getChildren(); | ||
var vanillaFlicking = this._vanillaFlicking; | ||
@@ -875,3 +732,2 @@ var diffResult = this._diffResult; | ||
}; | ||
__proto._isFragment = function (child) { | ||
@@ -881,10 +737,6 @@ if (child.type) { | ||
} | ||
return child === React.Fragment; | ||
}; | ||
Flicking.defaultProps = DEFAULT_PROPS; | ||
__decorate([VanillaFlicking.withFlickingMethods], Flicking.prototype, "_vanillaFlicking", void 0); | ||
return Flicking; | ||
@@ -891,0 +743,0 @@ }(React.Component); |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/egjs-flicking/tree/master/packages/react-flicking | ||
version: 4.10.8 | ||
version: 4.10.9 | ||
*/ | ||
@@ -18,3 +18,3 @@ import * as React from 'react'; | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -33,4 +33,4 @@ | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function (d, b) { | ||
@@ -44,14 +44,10 @@ extendStatics = Object.setPrototypeOf || { | ||
}; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
@@ -63,9 +59,6 @@ } | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
@@ -75,5 +68,3 @@ }; | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
@@ -86,4 +77,4 @@ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; | ||
var c = arguments.length, | ||
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, | ||
d; | ||
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, | ||
d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
@@ -98,3 +89,2 @@ return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
@@ -108,3 +98,2 @@ function fulfilled(value) { | ||
} | ||
function rejected(value) { | ||
@@ -117,7 +106,5 @@ try { | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -128,14 +115,14 @@ }); | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
f, | ||
y, | ||
t, | ||
g; | ||
return g = { | ||
@@ -148,3 +135,2 @@ next: verb(0), | ||
}), g; | ||
function verb(n) { | ||
@@ -155,10 +141,7 @@ return function (v) { | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
@@ -169,3 +152,2 @@ case 0: | ||
break; | ||
case 4: | ||
@@ -177,3 +159,2 @@ _.label++; | ||
}; | ||
case 5: | ||
@@ -184,10 +165,6 @@ _.label++; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
@@ -198,3 +175,2 @@ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
@@ -204,3 +180,2 @@ _.label = op[1]; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
@@ -211,18 +186,11 @@ _.label = t[1]; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
@@ -235,3 +203,2 @@ } catch (e) { | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
@@ -281,23 +248,15 @@ return { | ||
var ReactRenderer = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var ReactRenderer = /*#__PURE__*/function (_super) { | ||
__extends(ReactRenderer, _super); | ||
function ReactRenderer(options) { | ||
var _this = _super.call(this, options) || this; | ||
_this._reactFlicking = options.reactFlicking; | ||
return _this; | ||
} // eslint-disable-next-line @typescript-eslint/require-await | ||
} | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
var __proto = ReactRenderer.prototype; | ||
__proto.render = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var flicking, reactFlicking, strategy; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -310,10 +269,6 @@ flicking = getFlickingAttached(this._flicking); | ||
strategy.renderPanels(flicking); | ||
return [2 | ||
/*return*/ | ||
, new Promise(function (resolve) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
reactFlicking.renderEmitter.once("render", function () { | ||
_this._rendering = false; | ||
_this._afterRender(); | ||
resolve(); | ||
@@ -326,9 +281,6 @@ }); | ||
}; | ||
__proto.forceRenderAllPanels = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var reactFlicking; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -339,12 +291,6 @@ switch (_a.label) { | ||
this._rendering = true; | ||
return [4 | ||
/*yield*/ | ||
, _super.prototype.forceRenderAllPanels.call(this)]; | ||
return [4 /*yield*/, _super.prototype.forceRenderAllPanels.call(this)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 | ||
/*return*/ | ||
, new Promise(function (resolve) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
reactFlicking.renderEmitter.once("render", function () { | ||
@@ -360,9 +306,6 @@ _this._rendering = false; | ||
}; | ||
__proto.destroy = function () { | ||
_super.prototype.destroy.call(this); | ||
this._reactFlicking.renderEmitter.off("render"); | ||
}; | ||
__proto._collectPanels = function () { | ||
@@ -374,18 +317,12 @@ var flicking = getFlickingAttached(this._flicking); | ||
}; | ||
__proto._createPanel = function (externalComponent, options) { | ||
return this._strategy.createPanel(externalComponent, options); | ||
}; | ||
return ReactRenderer; | ||
}(ExternalRenderer); | ||
var StrictPanel = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var StrictPanel = /*#__PURE__*/function (_super) { | ||
__extends(StrictPanel, _super); | ||
function StrictPanel() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._hide = false; | ||
@@ -395,3 +332,2 @@ _this._elRef = React.createRef(); | ||
} | ||
var __proto = StrictPanel.prototype; | ||
@@ -412,15 +348,11 @@ Object.defineProperty(__proto, "nativeElement", { | ||
}); | ||
__proto.render = function () { | ||
return this._hide ? React.createElement(React.Fragment, null) : this._getElement(); | ||
}; | ||
__proto.show = function () { | ||
this._hide = false; | ||
}; | ||
__proto.hide = function () { | ||
this._hide = true; | ||
}; | ||
__proto._getElement = function () { | ||
@@ -431,18 +363,12 @@ return React.cloneElement(React.Children.only(this.props.children), { | ||
}; | ||
return StrictPanel; | ||
}(React.Component); | ||
var NonStrictPanel = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var NonStrictPanel = /*#__PURE__*/function (_super) { | ||
__extends(NonStrictPanel, _super); | ||
function NonStrictPanel() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._hide = false; | ||
return _this; | ||
} | ||
var __proto = NonStrictPanel.prototype; | ||
@@ -463,15 +389,11 @@ Object.defineProperty(__proto, "nativeElement", { | ||
}); | ||
__proto.render = function () { | ||
return this._hide ? React.createElement(React.Fragment, null) : this.props.children; | ||
}; | ||
__proto.show = function () { | ||
this._hide = false; | ||
}; | ||
__proto.hide = function () { | ||
this._hide = true; | ||
}; | ||
return NonStrictPanel; | ||
@@ -488,9 +410,6 @@ }(React.Component); | ||
var ReactElementProvider = | ||
/*#__PURE__*/ | ||
function () { | ||
var ReactElementProvider = /*#__PURE__*/function () { | ||
function ReactElementProvider(el) { | ||
this._el = el; | ||
} | ||
var __proto = ReactElementProvider.prototype; | ||
@@ -511,27 +430,18 @@ Object.defineProperty(__proto, "element", { | ||
}); | ||
__proto.show = function () { | ||
this._el.show(); | ||
}; | ||
__proto.hide = function () { | ||
this._el.hide(); | ||
}; | ||
return ReactElementProvider; | ||
}(); | ||
var Flicking = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var Flicking = /*#__PURE__*/function (_super) { | ||
__extends(Flicking, _super); | ||
function Flicking(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this._panels = []; | ||
_this._renderEmitter = new Component(); | ||
var children = _this._getChildren(); | ||
_this._panels = _this._createPanelRefs(props, children); | ||
@@ -541,3 +451,2 @@ _this._prevChildren = children; | ||
} | ||
var __proto = Flicking.prototype; | ||
@@ -560,3 +469,2 @@ Object.defineProperty(__proto, "reactPanels", { | ||
}); | ||
__proto.componentDidMount = function () { | ||
@@ -575,5 +483,3 @@ var props = this.props; | ||
this._vanillaFlicking = flicking; | ||
var children = this._getChildren(); | ||
this._jsxDiffer = new ListDiffer(children, function (panel) { | ||
@@ -584,7 +490,4 @@ return panel.key; | ||
this._prevChildren = children; | ||
this._bindEvents(); | ||
this._checkPlugins(); | ||
if (props.status) { | ||
@@ -594,9 +497,6 @@ flicking.setStatus(props.status); | ||
}; | ||
__proto.componentWillUnmount = function () { | ||
var _a; | ||
(_a = this._vanillaFlicking) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
}; | ||
__proto.shouldComponentUpdate = function (nextProps) { | ||
@@ -606,6 +506,4 @@ var vanillaFlicking = this._vanillaFlicking; | ||
if (!vanillaFlicking || !vanillaFlicking.initialized) return false; | ||
var children = nextProps.children, | ||
restProps = __rest(nextProps, ["children"]); | ||
restProps = __rest(nextProps, ["children"]); | ||
for (var key in restProps) { | ||
@@ -616,22 +514,16 @@ if (prevProps[key] !== nextProps[key]) { | ||
} | ||
var prevChildren = this._prevChildren; | ||
var nextChildren = this._getChildren(children); | ||
if (nextProps.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) return true; | ||
return false; | ||
}; | ||
__proto.beforeRender = function () { | ||
var vanillaFlicking = this._vanillaFlicking; | ||
var props = this.props; | ||
var prevChildren = this._prevChildren; // Ignore updates before init, they will be updated after "ready" event's force update | ||
var prevChildren = this._prevChildren; | ||
// Ignore updates before init, they will be updated after "ready" event's force update | ||
// Also, prevent updates when another update is already queued. | ||
// This usually happens when render() called twice without calling componentDidMount, like in the case of React.StrictMode. | ||
if (!vanillaFlicking || !vanillaFlicking.initialized || this._diffResult) return; | ||
var nextChildren = this._getChildren(props.children); | ||
if (props.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) { | ||
@@ -643,3 +535,2 @@ this._panels = this._createPanelRefs(props, nextChildren); | ||
}; | ||
__proto.componentDidUpdate = function () { | ||
@@ -649,12 +540,9 @@ var flicking = this._vanillaFlicking; | ||
var diffResult = this._diffResult; | ||
this._checkPlugins(); | ||
renderEmitter.trigger("render"); | ||
flicking.camera.updateOffset(); // Omit 'virtual', as it can't have any setter | ||
flicking.camera.updateOffset(); | ||
// Omit 'virtual', as it can't have any setter | ||
var _a = this.props; | ||
_a.virtual; | ||
var props = __rest(_a, ["virtual"]); | ||
_a.virtual; | ||
var props = __rest(_a, ["virtual"]); | ||
for (var key in props) { | ||
@@ -665,3 +553,2 @@ if (key in flicking && flicking[key] !== props[key]) { | ||
} | ||
if (!diffResult || !flicking.initialized) return; | ||
@@ -671,8 +558,5 @@ sync(flicking, diffResult, this.reactPanels); | ||
}; | ||
__proto.render = function () { | ||
var _this = this; | ||
var _a, _b; | ||
var props = this.props; | ||
@@ -684,3 +568,2 @@ var Viewport = props.viewportTag; | ||
this.beforeRender(); | ||
for (var name in props) { | ||
@@ -691,3 +574,2 @@ if (!(name in DEFAULT_PROPS) && !(name in VanillaFlicking__default.prototype)) { | ||
} | ||
var initialized = flicking && flicking.initialized; | ||
@@ -697,19 +579,14 @@ var viewportClasses = ["flicking-viewport"]; | ||
var isHorizontal = flicking ? flicking.horizontal : (_a = props.horizontal) !== null && _a !== void 0 ? _a : true; | ||
if (!isHorizontal) { | ||
viewportClasses.push("vertical"); | ||
} | ||
if (props.hideBeforeInit && !initialized) { | ||
viewportClasses.push("flicking-hidden"); | ||
} | ||
if (attributes.className) { | ||
viewportClasses.push(attributes.className); | ||
} | ||
if (props.cameraClass) { | ||
cameraClasses.push(props.cameraClass); | ||
} | ||
var cameraProps = !initialized && props.firstPanelSize ? { | ||
@@ -730,6 +607,4 @@ style: { | ||
}; | ||
__proto._createPanelRefs = function (props, children) { | ||
var _a; | ||
var panelsPerView = (_a = props.panelsPerView) !== null && _a !== void 0 ? _a : -1; | ||
@@ -742,6 +617,4 @@ return panelsPerView > 0 && !!props.virtual ? range(panelsPerView + 1).map(function () { | ||
}; | ||
__proto._bindEvents = function () { | ||
var _this = this; | ||
var flicking = this._vanillaFlicking; | ||
@@ -761,12 +634,9 @@ Object.keys(EVENTS).forEach(function (eventKey) { | ||
}; | ||
__proto._checkPlugins = function () { | ||
var flicking = this._vanillaFlicking; | ||
var _a = this._pluginsDiffer.update(this.props.plugins), | ||
list = _a.list, | ||
added = _a.added, | ||
removed = _a.removed, | ||
prevList = _a.prevList; | ||
list = _a.list, | ||
added = _a.added, | ||
removed = _a.removed, | ||
prevList = _a.prevList; | ||
flicking.addPlugins.apply(flicking, added.map(function (index) { | ||
@@ -779,3 +649,2 @@ return list[index]; | ||
}; | ||
__proto._hasSameChildren = function (prevChildren, nextChildren) { | ||
@@ -785,3 +654,2 @@ if (prevChildren.length !== nextChildren.length || prevChildren.length === 0) return false; | ||
var nextChild = nextChildren[idx]; | ||
if (child.key && nextChild.key) { | ||
@@ -795,10 +663,7 @@ return child.key === nextChild.key; | ||
}; | ||
__proto._getChildren = function (children) { | ||
var _this = this; | ||
if (children === void 0) { | ||
children = this.props.children; | ||
} | ||
return React.Children.toArray(children).filter(function (child) { | ||
@@ -810,3 +675,2 @@ return child.type !== ViewportSlot; | ||
}; | ||
__proto._getViewportSlot = function () { | ||
@@ -817,6 +681,4 @@ return React.Children.toArray(this.props.children).filter(function (child) { | ||
}; | ||
__proto._unpackFragment = function (child) { | ||
var _this = this; | ||
return this._isFragment(child) ? React.Children.toArray(child.props.children).reduce(function (allChilds, fragChild) { | ||
@@ -826,8 +688,6 @@ return __spreadArray(__spreadArray([], allChilds, true), _this._unpackFragment(fragChild), true); | ||
}; | ||
__proto._getVirtualPanels = function () { | ||
var _this = this; | ||
var _a = this.props.virtual.panelClass, | ||
panelClass = _a === void 0 ? "flicking-panel" : _a; | ||
panelClass = _a === void 0 ? "flicking-panel" : _a; | ||
var panelsPerView = this.props.panelsPerView; | ||
@@ -853,8 +713,5 @@ var flicking = this._vanillaFlicking; | ||
}; | ||
__proto._getPanels = function () { | ||
var _this = this; | ||
var origChildren = this._getChildren(); | ||
var vanillaFlicking = this._vanillaFlicking; | ||
@@ -875,3 +732,2 @@ var diffResult = this._diffResult; | ||
}; | ||
__proto._isFragment = function (child) { | ||
@@ -881,10 +737,6 @@ if (child.type) { | ||
} | ||
return child === React.Fragment; | ||
}; | ||
Flicking.defaultProps = DEFAULT_PROPS; | ||
__decorate([withFlickingMethods], Flicking.prototype, "_vanillaFlicking", void 0); | ||
return Flicking; | ||
@@ -891,0 +743,0 @@ }(React.Component); |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/egjs-flicking/tree/master/packages/react-flicking | ||
version: 4.10.8 | ||
version: 4.10.9 | ||
*/ | ||
@@ -16,3 +16,3 @@ (function (global, factory) { | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -31,4 +31,4 @@ | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function (d, b) { | ||
@@ -42,14 +42,10 @@ extendStatics = Object.setPrototypeOf || { | ||
}; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
@@ -61,9 +57,6 @@ } | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
@@ -73,5 +66,3 @@ }; | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
@@ -84,4 +75,4 @@ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; | ||
var c = arguments.length, | ||
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, | ||
d; | ||
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, | ||
d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
@@ -96,3 +87,2 @@ return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
@@ -106,3 +96,2 @@ function fulfilled(value) { | ||
} | ||
function rejected(value) { | ||
@@ -115,7 +104,5 @@ try { | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -126,14 +113,14 @@ }); | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
f, | ||
y, | ||
t, | ||
g; | ||
return g = { | ||
@@ -146,3 +133,2 @@ next: verb(0), | ||
}), g; | ||
function verb(n) { | ||
@@ -153,10 +139,7 @@ return function (v) { | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
@@ -167,3 +150,2 @@ case 0: | ||
break; | ||
case 4: | ||
@@ -175,3 +157,2 @@ _.label++; | ||
}; | ||
case 5: | ||
@@ -182,10 +163,6 @@ _.label++; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
@@ -196,3 +173,2 @@ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
@@ -202,3 +178,2 @@ _.label = op[1]; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
@@ -209,18 +184,11 @@ _.label = t[1]; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
@@ -233,3 +201,2 @@ } catch (e) { | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
@@ -279,23 +246,15 @@ return { | ||
var ReactRenderer = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var ReactRenderer = /*#__PURE__*/function (_super) { | ||
__extends(ReactRenderer, _super); | ||
function ReactRenderer(options) { | ||
var _this = _super.call(this, options) || this; | ||
_this._reactFlicking = options.reactFlicking; | ||
return _this; | ||
} // eslint-disable-next-line @typescript-eslint/require-await | ||
} | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
var __proto = ReactRenderer.prototype; | ||
__proto.render = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var flicking, reactFlicking, strategy; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -308,10 +267,6 @@ flicking = VanillaFlicking.getFlickingAttached(this._flicking); | ||
strategy.renderPanels(flicking); | ||
return [2 | ||
/*return*/ | ||
, new Promise(function (resolve) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
reactFlicking.renderEmitter.once("render", function () { | ||
_this._rendering = false; | ||
_this._afterRender(); | ||
resolve(); | ||
@@ -324,9 +279,6 @@ }); | ||
}; | ||
__proto.forceRenderAllPanels = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var reactFlicking; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -337,12 +289,6 @@ switch (_a.label) { | ||
this._rendering = true; | ||
return [4 | ||
/*yield*/ | ||
, _super.prototype.forceRenderAllPanels.call(this)]; | ||
return [4 /*yield*/, _super.prototype.forceRenderAllPanels.call(this)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 | ||
/*return*/ | ||
, new Promise(function (resolve) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
reactFlicking.renderEmitter.once("render", function () { | ||
@@ -358,9 +304,6 @@ _this._rendering = false; | ||
}; | ||
__proto.destroy = function () { | ||
_super.prototype.destroy.call(this); | ||
this._reactFlicking.renderEmitter.off("render"); | ||
}; | ||
__proto._collectPanels = function () { | ||
@@ -372,18 +315,12 @@ var flicking = VanillaFlicking.getFlickingAttached(this._flicking); | ||
}; | ||
__proto._createPanel = function (externalComponent, options) { | ||
return this._strategy.createPanel(externalComponent, options); | ||
}; | ||
return ReactRenderer; | ||
}(VanillaFlicking.ExternalRenderer); | ||
var StrictPanel = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var StrictPanel = /*#__PURE__*/function (_super) { | ||
__extends(StrictPanel, _super); | ||
function StrictPanel() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._hide = false; | ||
@@ -393,3 +330,2 @@ _this._elRef = React.createRef(); | ||
} | ||
var __proto = StrictPanel.prototype; | ||
@@ -410,15 +346,11 @@ Object.defineProperty(__proto, "nativeElement", { | ||
}); | ||
__proto.render = function () { | ||
return this._hide ? React.createElement(React.Fragment, null) : this._getElement(); | ||
}; | ||
__proto.show = function () { | ||
this._hide = false; | ||
}; | ||
__proto.hide = function () { | ||
this._hide = true; | ||
}; | ||
__proto._getElement = function () { | ||
@@ -429,18 +361,12 @@ return React.cloneElement(React.Children.only(this.props.children), { | ||
}; | ||
return StrictPanel; | ||
}(React.Component); | ||
var NonStrictPanel = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var NonStrictPanel = /*#__PURE__*/function (_super) { | ||
__extends(NonStrictPanel, _super); | ||
function NonStrictPanel() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this._hide = false; | ||
return _this; | ||
} | ||
var __proto = NonStrictPanel.prototype; | ||
@@ -461,15 +387,11 @@ Object.defineProperty(__proto, "nativeElement", { | ||
}); | ||
__proto.render = function () { | ||
return this._hide ? React.createElement(React.Fragment, null) : this.props.children; | ||
}; | ||
__proto.show = function () { | ||
this._hide = false; | ||
}; | ||
__proto.hide = function () { | ||
this._hide = true; | ||
}; | ||
return NonStrictPanel; | ||
@@ -486,9 +408,6 @@ }(React.Component); | ||
var ReactElementProvider = | ||
/*#__PURE__*/ | ||
function () { | ||
var ReactElementProvider = /*#__PURE__*/function () { | ||
function ReactElementProvider(el) { | ||
this._el = el; | ||
} | ||
var __proto = ReactElementProvider.prototype; | ||
@@ -509,27 +428,18 @@ Object.defineProperty(__proto, "element", { | ||
}); | ||
__proto.show = function () { | ||
this._el.show(); | ||
}; | ||
__proto.hide = function () { | ||
this._el.hide(); | ||
}; | ||
return ReactElementProvider; | ||
}(); | ||
var Flicking = | ||
/*#__PURE__*/ | ||
function (_super) { | ||
var Flicking = /*#__PURE__*/function (_super) { | ||
__extends(Flicking, _super); | ||
function Flicking(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this._panels = []; | ||
_this._renderEmitter = new Component(); | ||
var children = _this._getChildren(); | ||
_this._panels = _this._createPanelRefs(props, children); | ||
@@ -539,3 +449,2 @@ _this._prevChildren = children; | ||
} | ||
var __proto = Flicking.prototype; | ||
@@ -558,3 +467,2 @@ Object.defineProperty(__proto, "reactPanels", { | ||
}); | ||
__proto.componentDidMount = function () { | ||
@@ -573,5 +481,3 @@ var props = this.props; | ||
this._vanillaFlicking = flicking; | ||
var children = this._getChildren(); | ||
this._jsxDiffer = new ListDiffer(children, function (panel) { | ||
@@ -582,7 +488,4 @@ return panel.key; | ||
this._prevChildren = children; | ||
this._bindEvents(); | ||
this._checkPlugins(); | ||
if (props.status) { | ||
@@ -592,9 +495,6 @@ flicking.setStatus(props.status); | ||
}; | ||
__proto.componentWillUnmount = function () { | ||
var _a; | ||
(_a = this._vanillaFlicking) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
}; | ||
__proto.shouldComponentUpdate = function (nextProps) { | ||
@@ -604,6 +504,4 @@ var vanillaFlicking = this._vanillaFlicking; | ||
if (!vanillaFlicking || !vanillaFlicking.initialized) return false; | ||
var children = nextProps.children, | ||
restProps = __rest(nextProps, ["children"]); | ||
restProps = __rest(nextProps, ["children"]); | ||
for (var key in restProps) { | ||
@@ -614,22 +512,16 @@ if (prevProps[key] !== nextProps[key]) { | ||
} | ||
var prevChildren = this._prevChildren; | ||
var nextChildren = this._getChildren(children); | ||
if (nextProps.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) return true; | ||
return false; | ||
}; | ||
__proto.beforeRender = function () { | ||
var vanillaFlicking = this._vanillaFlicking; | ||
var props = this.props; | ||
var prevChildren = this._prevChildren; // Ignore updates before init, they will be updated after "ready" event's force update | ||
var prevChildren = this._prevChildren; | ||
// Ignore updates before init, they will be updated after "ready" event's force update | ||
// Also, prevent updates when another update is already queued. | ||
// This usually happens when render() called twice without calling componentDidMount, like in the case of React.StrictMode. | ||
if (!vanillaFlicking || !vanillaFlicking.initialized || this._diffResult) return; | ||
var nextChildren = this._getChildren(props.children); | ||
if (props.renderOnSameKey || !this._hasSameChildren(prevChildren, nextChildren)) { | ||
@@ -641,3 +533,2 @@ this._panels = this._createPanelRefs(props, nextChildren); | ||
}; | ||
__proto.componentDidUpdate = function () { | ||
@@ -647,12 +538,9 @@ var flicking = this._vanillaFlicking; | ||
var diffResult = this._diffResult; | ||
this._checkPlugins(); | ||
renderEmitter.trigger("render"); | ||
flicking.camera.updateOffset(); // Omit 'virtual', as it can't have any setter | ||
flicking.camera.updateOffset(); | ||
// Omit 'virtual', as it can't have any setter | ||
var _a = this.props; | ||
_a.virtual; | ||
var props = __rest(_a, ["virtual"]); | ||
_a.virtual; | ||
var props = __rest(_a, ["virtual"]); | ||
for (var key in props) { | ||
@@ -663,3 +551,2 @@ if (key in flicking && flicking[key] !== props[key]) { | ||
} | ||
if (!diffResult || !flicking.initialized) return; | ||
@@ -669,8 +556,5 @@ VanillaFlicking.sync(flicking, diffResult, this.reactPanels); | ||
}; | ||
__proto.render = function () { | ||
var _this = this; | ||
var _a, _b; | ||
var props = this.props; | ||
@@ -682,3 +566,2 @@ var Viewport = props.viewportTag; | ||
this.beforeRender(); | ||
for (var name in props) { | ||
@@ -689,3 +572,2 @@ if (!(name in DEFAULT_PROPS) && !(name in VanillaFlicking.prototype)) { | ||
} | ||
var initialized = flicking && flicking.initialized; | ||
@@ -695,19 +577,14 @@ var viewportClasses = ["flicking-viewport"]; | ||
var isHorizontal = flicking ? flicking.horizontal : (_a = props.horizontal) !== null && _a !== void 0 ? _a : true; | ||
if (!isHorizontal) { | ||
viewportClasses.push("vertical"); | ||
} | ||
if (props.hideBeforeInit && !initialized) { | ||
viewportClasses.push("flicking-hidden"); | ||
} | ||
if (attributes.className) { | ||
viewportClasses.push(attributes.className); | ||
} | ||
if (props.cameraClass) { | ||
cameraClasses.push(props.cameraClass); | ||
} | ||
var cameraProps = !initialized && props.firstPanelSize ? { | ||
@@ -728,6 +605,4 @@ style: { | ||
}; | ||
__proto._createPanelRefs = function (props, children) { | ||
var _a; | ||
var panelsPerView = (_a = props.panelsPerView) !== null && _a !== void 0 ? _a : -1; | ||
@@ -740,6 +615,4 @@ return panelsPerView > 0 && !!props.virtual ? VanillaFlicking.range(panelsPerView + 1).map(function () { | ||
}; | ||
__proto._bindEvents = function () { | ||
var _this = this; | ||
var flicking = this._vanillaFlicking; | ||
@@ -759,12 +632,9 @@ Object.keys(VanillaFlicking.EVENTS).forEach(function (eventKey) { | ||
}; | ||
__proto._checkPlugins = function () { | ||
var flicking = this._vanillaFlicking; | ||
var _a = this._pluginsDiffer.update(this.props.plugins), | ||
list = _a.list, | ||
added = _a.added, | ||
removed = _a.removed, | ||
prevList = _a.prevList; | ||
list = _a.list, | ||
added = _a.added, | ||
removed = _a.removed, | ||
prevList = _a.prevList; | ||
flicking.addPlugins.apply(flicking, added.map(function (index) { | ||
@@ -777,3 +647,2 @@ return list[index]; | ||
}; | ||
__proto._hasSameChildren = function (prevChildren, nextChildren) { | ||
@@ -783,3 +652,2 @@ if (prevChildren.length !== nextChildren.length || prevChildren.length === 0) return false; | ||
var nextChild = nextChildren[idx]; | ||
if (child.key && nextChild.key) { | ||
@@ -793,10 +661,7 @@ return child.key === nextChild.key; | ||
}; | ||
__proto._getChildren = function (children) { | ||
var _this = this; | ||
if (children === void 0) { | ||
children = this.props.children; | ||
} | ||
return React.Children.toArray(children).filter(function (child) { | ||
@@ -808,3 +673,2 @@ return child.type !== ViewportSlot; | ||
}; | ||
__proto._getViewportSlot = function () { | ||
@@ -815,6 +679,4 @@ return React.Children.toArray(this.props.children).filter(function (child) { | ||
}; | ||
__proto._unpackFragment = function (child) { | ||
var _this = this; | ||
return this._isFragment(child) ? React.Children.toArray(child.props.children).reduce(function (allChilds, fragChild) { | ||
@@ -824,8 +686,6 @@ return __spreadArray(__spreadArray([], allChilds, true), _this._unpackFragment(fragChild), true); | ||
}; | ||
__proto._getVirtualPanels = function () { | ||
var _this = this; | ||
var _a = this.props.virtual.panelClass, | ||
panelClass = _a === void 0 ? "flicking-panel" : _a; | ||
panelClass = _a === void 0 ? "flicking-panel" : _a; | ||
var panelsPerView = this.props.panelsPerView; | ||
@@ -851,8 +711,5 @@ var flicking = this._vanillaFlicking; | ||
}; | ||
__proto._getPanels = function () { | ||
var _this = this; | ||
var origChildren = this._getChildren(); | ||
var vanillaFlicking = this._vanillaFlicking; | ||
@@ -873,3 +730,2 @@ var diffResult = this._diffResult; | ||
}; | ||
__proto._isFragment = function (child) { | ||
@@ -879,10 +735,6 @@ if (child.type) { | ||
} | ||
return child === React.Fragment; | ||
}; | ||
Flicking.defaultProps = DEFAULT_PROPS; | ||
__decorate([VanillaFlicking.withFlickingMethods], Flicking.prototype, "_vanillaFlicking", void 0); | ||
return Flicking; | ||
@@ -889,0 +741,0 @@ }(React.Component); |
{ | ||
"name": "@egjs/react-flicking", | ||
"version": "4.10.8", | ||
"version": "4.10.9", | ||
"description": "Everyday 30 million people experience. It's reliable, flexible and extendable carousel.", | ||
@@ -23,4 +23,4 @@ "main": "dist/flicking.cjs.js", | ||
"@egjs/component": "^3.0.2", | ||
"@egjs/flicking": "~4.10.6", | ||
"@egjs/list-differ": "^1.0.0" | ||
"@egjs/flicking": "~4.10.7", | ||
"@egjs/list-differ": "^1.0.1" | ||
}, | ||
@@ -46,3 +46,3 @@ "devDependencies": { | ||
"tslib": "^2.2.0", | ||
"typescript": "^4.2.2" | ||
"typescript": "4.8.4" | ||
}, | ||
@@ -49,0 +49,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231933
2833
Updated@egjs/flicking@~4.10.7
Updated@egjs/list-differ@^1.0.1