|
1 | 1 | import React from "react"; |
| 2 | +import defaultProps from "../default-props"; |
2 | 3 |
|
3 | 4 | export function clamp(number, lowerBound, upperBound) { |
4 | 5 | return Math.max(lowerBound, Math.min(number, upperBound)); |
5 | 6 | } |
6 | 7 |
|
7 | 8 | export const safePreventDefault = event => { |
8 | 9 | const passiveEvents = ["onTouchStart", "onTouchMove", "onWheel"]; |
9 | | - if(!passiveEvents.includes(event._reactName)) { |
| 10 | + if (!passiveEvents.includes(event._reactName)) { |
10 | 11 | event.preventDefault(); |
11 | 12 | } |
12 | | -} |
| 13 | +}; |
13 | 14 |
|
14 | 15 | export const getOnDemandLazySlides = spec => { |
15 | 16 | let onDemandSlides = []; |
@@ -386,9 +387,12 @@ export const swipeMove = (e, spec) => { |
386 | 387 | let touchSwipeLength = touchObject.swipeLength; |
387 | 388 | if (!infinite) { |
388 | 389 | if ( |
389 | | - (currentSlide === 0 && (swipeDirection === "right" || swipeDirection === "down")) || |
390 | | - (currentSlide + 1 >= dotCount && (swipeDirection === "left" || swipeDirection === "up")) || |
391 | | - (!canGoNext(spec) && (swipeDirection === "left" || swipeDirection === "up")) |
| 390 | + (currentSlide === 0 && |
| 391 | + (swipeDirection === "right" || swipeDirection === "down")) || |
| 392 | + (currentSlide + 1 >= dotCount && |
| 393 | + (swipeDirection === "left" || swipeDirection === "up")) || |
| 394 | + (!canGoNext(spec) && |
| 395 | + (swipeDirection === "left" || swipeDirection === "up")) |
392 | 396 | ) { |
393 | 397 | touchSwipeLength = touchObject.swipeLength * edgeFriction; |
394 | 398 | if (edgeDragged === false && onEdge) { |
@@ -849,3 +853,14 @@ export const canUseDOM = () => |
849 | 853 | window.document && |
850 | 854 | window.document.createElement |
851 | 855 | ); |
| 856 | + |
| 857 | +export const validSettings = Object.keys(defaultProps); |
| 858 | + |
| 859 | +export function filterSettings(settings) { |
| 860 | + return validSettings.reduce((acc, settingName) => { |
| 861 | + if (settings.hasOwnProperty(settingName)) { |
| 862 | + acc[settingName] = settings[settingName]; |
| 863 | + } |
| 864 | + return acc; |
| 865 | + }, {}); |
| 866 | +} |
0 commit comments