fslightbox 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FsLightbox.js +110 -0
- package/README.md +55 -1
- package/components/helpers/renderSvg.js +17 -0
- package/components/nav/renderAndGetToolbarButton.js +11 -0
- package/components/nav/renderCloseButton.js +10 -0
- package/components/nav/renderFullscreenButton.js +42 -0
- package/components/nav/renderNav.js +17 -0
- package/components/nav/renderSlideNumber.js +33 -0
- package/components/nav/renderToolbar.js +13 -0
- package/components/renderSlideButton.js +11 -0
- package/components/renderSlideButtonContainer.js +15 -0
- package/components/renderSlideButtons.js +7 -0
- package/components/renderSlideSwipingHoverer.js +6 -0
- package/components/sources/proper-sources/renderCustom.js +15 -0
- package/components/sources/proper-sources/renderImage.js +18 -0
- package/components/sources/proper-sources/renderInvalid.js +19 -0
- package/components/sources/proper-sources/renderVideo.js +31 -0
- package/components/sources/proper-sources/renderYoutube.js +26 -0
- package/components/sources/renderSourceAnimationWrapper.js +4 -0
- package/components/sources/renderSourceMainWrapper.js +32 -0
- package/components/sources/renderSourceWrappersContainer.js +22 -0
- package/constants/classes-names.js +27 -0
- package/constants/core-constants.js +6 -0
- package/constants/css-constants.js +1 -0
- package/constants/dom-constants.js +1 -0
- package/constants/elements.js +3 -0
- package/constants/local-storage-constants.js +2 -0
- package/core/collections/fillSourcesOutersTransformersCollection.js +13 -0
- package/core/elements/setUpClassFacade.js +9 -0
- package/core/events/setUpEventsDispatcher.js +7 -0
- package/core/events/setUpGlobalEventsController.js +34 -0
- package/core/fullscreen/setUpFullscreenToggler.js +30 -0
- package/core/keyboard/KeyboardController.js +20 -0
- package/core/main-component/closing/LightboxCloseActioner.js +46 -0
- package/core/main-component/closing/setUpLightboxCloser.js +11 -0
- package/core/main-component/initializing/initializeLightbox.js +38 -0
- package/core/main-component/opening/setUpLightboxOpener.js +47 -0
- package/core/scrollbar/getInnerElementOfWidthGetter.js +5 -0
- package/core/scrollbar/getOuterElementOfWidthGetter.js +9 -0
- package/core/scrollbar/getScrollbarWidth.js +31 -0
- package/core/scrollbar/setUpScrollbarRecompensor.js +20 -0
- package/core/setUpCore.js +30 -0
- package/core/sizes/setUpWindowResizeActioner.js +35 -0
- package/core/slide/setUpSlideChangeFacade.js +23 -0
- package/core/slide/setUpSlideIndexChanger.js +60 -0
- package/core/sources/SourceLoadActioner.js +29 -0
- package/core/sources/SourceLoadHandler.js +41 -0
- package/core/sources/SourceSizer.js +36 -0
- package/core/sources/creating/CreatingSourcesBucket.js +29 -0
- package/core/sources/creating/CreatingSourcesLocalStorageManager.js +55 -0
- package/core/sources/creating/createSources.js +28 -0
- package/core/sources/pointering/down/setUpSourcesPointerDown.js +36 -0
- package/core/sources/pointering/move/SourcesPointerMove.js +16 -0
- package/core/sources/pointering/move/SourcesPointerMoveActioner.js +37 -0
- package/core/sources/pointering/up/SourcesPointerUp.js +13 -0
- package/core/sources/pointering/up/SourcesPointerUpActioner.js +38 -0
- package/core/sources/pointering/up/SourcesPointerUpActionerBucket.js +35 -0
- package/core/sources/setUpSourceDisplayFacade.js +26 -0
- package/core/sources/types/AutomaticTypeDetector.js +70 -0
- package/core/sources/types/DetectedTypeActioner.js +44 -0
- package/core/sources/types/getAutomaticTypeDetectorBucket.js +14 -0
- package/core/stage/setUpStageManager.js +60 -0
- package/core/styles/createAndAppendStyles.js +9 -0
- package/core/styles/injectStylesIfNotInDom.js +8 -0
- package/core/styles/styles-injection/styles-injection.js +5 -0
- package/core/timeouts/getQueuedAction.js +15 -0
- package/core/transforms/SourceMainWrapperTransformer.js +27 -0
- package/fslightbox.js +1 -0
- package/helpers/elements/addToElementClassIfNotContains.js +6 -0
- package/helpers/elements/removeFromElementChildIfContains.js +5 -0
- package/helpers/elements/removeFromElementClassIfContains.js +6 -0
- package/helpers/objects/assignToObject.js +10 -0
- package/helpers/source/setUpSourceClassName.js +13 -0
- package/helpers/source/setUpSourceCustomAttributes.js +5 -0
- package/helpers/state/ifOnUpdateExistsHandleItForState.js +6 -0
- package/i.js +86 -0
- package/index.js +1 -1
- package/package.json +4 -37
- package/styles.js +1 -0
- package/.env.example +0 -3
package/FsLightbox.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { setUpLightboxOpener } from "./core/main-component/opening/setUpLightboxOpener";
|
|
2
|
+
|
|
3
|
+
window.FsLightbox = function () {
|
|
4
|
+
/**
|
|
5
|
+
* @property { Array } sources
|
|
6
|
+
*
|
|
7
|
+
* @property { Function } onOpen
|
|
8
|
+
* @property { Function } onClose
|
|
9
|
+
* @property { Function } onInit
|
|
10
|
+
* @property { Function } onShow
|
|
11
|
+
*
|
|
12
|
+
* @property { Boolean } disableLocalStorage
|
|
13
|
+
* @property { Array } types
|
|
14
|
+
* @property { String } type
|
|
15
|
+
*
|
|
16
|
+
* @property { Array } customAttributes
|
|
17
|
+
* @property { Array } customClasses
|
|
18
|
+
* @property { Object } maxYoutubeDimensions
|
|
19
|
+
* @property { Array } videosPosters // deprecated 3.2.0
|
|
20
|
+
*
|
|
21
|
+
* @property { Boolean } exitFullscreenOnClose
|
|
22
|
+
* @property { Boolean } loadOnlyCurrentSource
|
|
23
|
+
* @property { Number } slideDistance
|
|
24
|
+
*/
|
|
25
|
+
this.props = {
|
|
26
|
+
sources: [],
|
|
27
|
+
customAttributes: [],
|
|
28
|
+
customClasses: [],
|
|
29
|
+
types: [],
|
|
30
|
+
videosPosters: [], // deprecated 3.2.0
|
|
31
|
+
slideDistance: 0.3
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this.data = {
|
|
35
|
+
isInitialized: false,
|
|
36
|
+
isFullscreenOpen: false,
|
|
37
|
+
maxSourceWidth: 0,
|
|
38
|
+
maxSourceHeight: 0,
|
|
39
|
+
scrollbarWidth: 0
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
this.sourcePointerProps = {
|
|
43
|
+
downScreenX: null,
|
|
44
|
+
isPointering: false,
|
|
45
|
+
isSourceDownEventTarget: false,
|
|
46
|
+
swipedX: 0
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @property { Number } previous
|
|
51
|
+
* @property { Number } current
|
|
52
|
+
* @property { Number } next
|
|
53
|
+
*/
|
|
54
|
+
this.stageIndexes = {};
|
|
55
|
+
|
|
56
|
+
this.elements = {
|
|
57
|
+
// array of <a> tags lightbox was created from
|
|
58
|
+
a: [],
|
|
59
|
+
container: null,
|
|
60
|
+
slideSwipingHoverer: null,
|
|
61
|
+
sourceWrappersContainer: null,
|
|
62
|
+
sources: [],
|
|
63
|
+
sourceMainWrappers: [],
|
|
64
|
+
sourceAnimationWrappers: [],
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
this.componentsServices = {
|
|
68
|
+
enterFullscreen: null,
|
|
69
|
+
exitFullscreen: null,
|
|
70
|
+
hideSourceLoaderIfNotYetCollection: [],
|
|
71
|
+
// if there is one slide SlideNumber is not rendered so we need to prevent calling undefined function
|
|
72
|
+
setSlideNumber: () => {}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
this.resolve = (dependency, params = []) => {
|
|
76
|
+
params.unshift(this);
|
|
77
|
+
return new dependency(...params);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
this.collections = {
|
|
81
|
+
sourceMainWrappersTransformers: [],
|
|
82
|
+
sourceLoadHandlers: [],
|
|
83
|
+
sourcesRenderFunctions: [],
|
|
84
|
+
// after source load its size adjuster will be stored in this array so it may be later resized
|
|
85
|
+
sourceSizers: [],
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
this.core = {
|
|
89
|
+
classFacade: {},
|
|
90
|
+
eventsDispatcher: {},
|
|
91
|
+
fullscreenToggler: {},
|
|
92
|
+
globalEventsController: {},
|
|
93
|
+
lightboxCloser: {},
|
|
94
|
+
lightboxOpener: {},
|
|
95
|
+
lightboxUpdater: {},
|
|
96
|
+
scrollbarRecompensor: {},
|
|
97
|
+
slideChangeFacade: {},
|
|
98
|
+
slideIndexChanger: {},
|
|
99
|
+
sourcesPointerDown: {},
|
|
100
|
+
sourceDisplayFacade: {},
|
|
101
|
+
stageManager: {},
|
|
102
|
+
windowResizeActioner: {}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
setUpLightboxOpener(this);
|
|
106
|
+
|
|
107
|
+
this.open = (i) => this.core.lightboxOpener.open(i);
|
|
108
|
+
|
|
109
|
+
this.close = () => this.core.lightboxCloser.closeLightbox();
|
|
110
|
+
};
|
package/README.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
# Vanilla JavaScript Fullscreen Lightbox Basic
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
A vanilla JavaScript plug-in without production dependencies for displaying images, videos, or, through custom sources, anything you want in a clean overlying box.
|
|
5
|
+
The project's website: https://fslightbox.com.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
### Through an archive downloaded from the website.
|
|
9
|
+
Just before the end of the <body> tag:
|
|
10
|
+
```html
|
|
11
|
+
<script src="fslightbox.js"></script>
|
|
12
|
+
```
|
|
13
|
+
### Or, through a package manager.
|
|
14
|
+
```
|
|
15
|
+
npm install fslightbox
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
And import it in your project's JavaScript file, for example through the Node.js "require" function:
|
|
19
|
+
```
|
|
20
|
+
require("fslightbox")
|
|
21
|
+
|
|
22
|
+
## Basic usage
|
|
23
|
+
```html
|
|
24
|
+
<a data-fslightbox="gallery" href="https://i.imgur.com/fsyrScY.jpg">
|
|
25
|
+
Open the first slide (an image)
|
|
26
|
+
</a>
|
|
27
|
+
<a data-fslightbox="gallery" href="https://www.youtube.com/watch?v=xshEZzpS4CQ">
|
|
28
|
+
Open the second slide (a YouTube video)
|
|
29
|
+
</a>
|
|
30
|
+
<a data-fslightbox="gallery" href="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4">
|
|
31
|
+
Open the third slide (an HTML video)
|
|
32
|
+
</a>
|
|
33
|
+
<a data-fslightbox="gallery" href="#vimeo">
|
|
34
|
+
Open the fourth slide (a Vimeo video—a custom source)
|
|
35
|
+
</a>
|
|
36
|
+
<iframe id="vimeo" src="https://player.vimeo.com/video/22439234" width="1920px" height="1080px"
|
|
37
|
+
frameBorder="0" allow="autoplay; fullscreen" allowFullScreen />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
Available at: https://fslightbox.com/javascript/documentation.
|
|
42
|
+
|
|
43
|
+
## Browser Compatibility
|
|
44
|
+
|
|
45
|
+
| Browser | Works? |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| Chrome | Yes |
|
|
48
|
+
| Firefox | Yes |
|
|
49
|
+
| Opera | Yes |
|
|
50
|
+
| Safari | Yes |
|
|
51
|
+
| Edge | Yes |
|
|
52
|
+
| IE 11 | Yes |
|
|
53
|
+
|
|
54
|
+
|
|
1
55
|
# Fullscreen Lightbox Basic
|
|
2
56
|
|
|
3
57
|
## Description
|
|
@@ -13,7 +67,7 @@ Website: https://fslightbox.com
|
|
|
13
67
|
### Installation
|
|
14
68
|
|
|
15
69
|
```
|
|
16
|
-
npm install
|
|
70
|
+
npm install fslightbox
|
|
17
71
|
```
|
|
18
72
|
|
|
19
73
|
### Example
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PREFIX } from "../../constants/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderAndGetSvg(parent, size, viewBox, d) {
|
|
4
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
5
|
+
svg.setAttributeNS(null, 'width', size);
|
|
6
|
+
svg.setAttributeNS(null, 'height', size);
|
|
7
|
+
svg.setAttributeNS(null, 'viewBox', viewBox);
|
|
8
|
+
|
|
9
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
10
|
+
path.setAttributeNS(null, 'class', `${PREFIX}svg-path`);
|
|
11
|
+
path.setAttributeNS(null, 'd', d);
|
|
12
|
+
|
|
13
|
+
svg.appendChild(path);
|
|
14
|
+
parent.appendChild(svg);
|
|
15
|
+
|
|
16
|
+
return svg;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FLEX_CENTERED_CLASS_NAME, PREFIX } from "../../constants/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderAndGetToolbarButton(parent, title) {
|
|
4
|
+
const toolbarButton = document.createElement('div');
|
|
5
|
+
toolbarButton.className = `${PREFIX}toolbar-button ${FLEX_CENTERED_CLASS_NAME}`;
|
|
6
|
+
toolbarButton.title = title;
|
|
7
|
+
|
|
8
|
+
parent.appendChild(toolbarButton);
|
|
9
|
+
|
|
10
|
+
return toolbarButton;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { renderAndGetToolbarButton } from "./renderAndGetToolbarButton";
|
|
2
|
+
import { renderAndGetSvg } from "../helpers/renderSvg";
|
|
3
|
+
|
|
4
|
+
export function renderCloseButton(fsLightbox, parent) {
|
|
5
|
+
const closeButton = renderAndGetToolbarButton(parent, 'Close');
|
|
6
|
+
|
|
7
|
+
closeButton.onclick = fsLightbox.core.lightboxCloser.closeLightbox;
|
|
8
|
+
|
|
9
|
+
renderAndGetSvg(closeButton, '20px', '0 0 24 24', 'M 4.7070312 3.2929688 L 3.2929688 4.7070312 L 10.585938 12 L 3.2929688 19.292969 L 4.7070312 20.707031 L 12 13.414062 L 19.292969 20.707031 L 20.707031 19.292969 L 13.414062 12 L 20.707031 4.7070312 L 19.292969 3.2929688 L 12 10.585938 L 4.7070312 3.2929688 z');
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { renderAndGetSvg } from "../helpers/renderSvg";
|
|
2
|
+
import { renderAndGetToolbarButton } from "./renderAndGetToolbarButton";
|
|
3
|
+
|
|
4
|
+
export function renderFullscreenButton({ componentsServices, core: { fullscreenToggler }, data }, parent) {
|
|
5
|
+
const enterSize = '20px';
|
|
6
|
+
const enterViewBox = '0 0 18 18';
|
|
7
|
+
const enterD = 'M4.5 11H3v4h4v-1.5H4.5V11zM3 7h1.5V4.5H7V3H3v4zm10.5 6.5H11V15h4v-4h-1.5v2.5zM11 3v1.5h2.5V7H15V3h-4z';
|
|
8
|
+
|
|
9
|
+
const exitSize = '24px';
|
|
10
|
+
const exitViewBox = '0 0 950 1024';
|
|
11
|
+
const exitD = 'M682 342h128v84h-212v-212h84v128zM598 810v-212h212v84h-128v128h-84zM342 342v-128h84v212h-212v-84h128zM214 682v-84h212v212h-84v-128h-128z';
|
|
12
|
+
|
|
13
|
+
const fullscreenButton = renderAndGetToolbarButton(parent);
|
|
14
|
+
fullscreenButton.title = 'Enter fullscreen';
|
|
15
|
+
const svg = renderAndGetSvg(fullscreenButton, enterSize, enterViewBox, enterD);
|
|
16
|
+
|
|
17
|
+
componentsServices.enterFullscreen = () => {
|
|
18
|
+
data.isFullscreenOpen = true;
|
|
19
|
+
fullscreenButton.title = 'Exit fullscreen';
|
|
20
|
+
svg.setAttributeNS(null, 'width', exitSize);
|
|
21
|
+
svg.setAttributeNS(null, 'height', exitSize);
|
|
22
|
+
svg.setAttributeNS(null, 'viewBox', exitViewBox);
|
|
23
|
+
svg.firstChild.setAttributeNS(null, 'd', exitD);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
componentsServices.exitFullscreen = () => {
|
|
27
|
+
data.isFullscreenOpen = false;
|
|
28
|
+
fullscreenButton.title = 'Enter fullscreen';
|
|
29
|
+
svg.setAttributeNS(null, 'width', enterSize);
|
|
30
|
+
svg.setAttributeNS(null, 'height', enterSize);
|
|
31
|
+
svg.setAttributeNS(null, 'viewBox', enterViewBox);
|
|
32
|
+
svg.firstChild.setAttributeNS(null, 'd', enterD);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
fullscreenButton.onclick = () => {
|
|
36
|
+
if (data.isFullscreenOpen) {
|
|
37
|
+
fullscreenToggler.exitFullscreen();
|
|
38
|
+
} else {
|
|
39
|
+
fullscreenToggler.enterFullscreen();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { renderToolbar } from "./renderToolbar";
|
|
2
|
+
import { renderSlideNumber } from "./renderSlideNumber";
|
|
3
|
+
import { PREFIX } from "../../constants/classes-names";
|
|
4
|
+
|
|
5
|
+
export function renderNav(fsLightbox) {
|
|
6
|
+
const { props: { sources }, elements: { container } } = fsLightbox;
|
|
7
|
+
|
|
8
|
+
const nav = document.createElement('div');
|
|
9
|
+
nav.className = `${PREFIX}nav`;
|
|
10
|
+
container.appendChild(nav);
|
|
11
|
+
|
|
12
|
+
renderToolbar(fsLightbox, nav);
|
|
13
|
+
|
|
14
|
+
if (sources.length > 1) {
|
|
15
|
+
renderSlideNumber(fsLightbox, nav);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FLEX_CENTERED_CLASS_NAME, PREFIX } from "../../constants/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderSlideNumber({ componentsServices, props: { sources }, stageIndexes }, parent) {
|
|
4
|
+
const slideNumberOuter = document.createElement('div');
|
|
5
|
+
slideNumberOuter.className = `${PREFIX}slide-number-container`;
|
|
6
|
+
|
|
7
|
+
const slideNumberInner = document.createElement('div');
|
|
8
|
+
slideNumberInner.className = FLEX_CENTERED_CLASS_NAME;
|
|
9
|
+
|
|
10
|
+
const currentNumber = document.createElement('span');
|
|
11
|
+
componentsServices.setSlideNumber = (number) => currentNumber.innerHTML = number;
|
|
12
|
+
if (process.env.NODE_ENV === 'development') {
|
|
13
|
+
currentNumber.setAttribute('data-test-id', 'slide-number');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const slash = document.createElement('span');
|
|
17
|
+
slash.className = `${PREFIX}slash`;
|
|
18
|
+
|
|
19
|
+
const totalNumber = document.createElement('div');
|
|
20
|
+
totalNumber.innerHTML = sources.length;
|
|
21
|
+
|
|
22
|
+
slideNumberOuter.appendChild(slideNumberInner);
|
|
23
|
+
slideNumberInner.appendChild(currentNumber);
|
|
24
|
+
slideNumberInner.appendChild(slash);
|
|
25
|
+
slideNumberInner.appendChild(totalNumber);
|
|
26
|
+
parent.appendChild(slideNumberOuter);
|
|
27
|
+
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
if (slideNumberInner.offsetWidth > 55) {
|
|
30
|
+
slideNumberOuter.style.justifyContent = 'flex-start';
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PREFIX } from "../../constants/classes-names";
|
|
2
|
+
import { renderFullscreenButton } from "./renderFullscreenButton";
|
|
3
|
+
import { renderCloseButton } from "./renderCloseButton";
|
|
4
|
+
|
|
5
|
+
export function renderToolbar(fsLightbox, parent) {
|
|
6
|
+
const toolbar = document.createElement('div');
|
|
7
|
+
toolbar.className = `${PREFIX}toolbar`;
|
|
8
|
+
|
|
9
|
+
parent.appendChild(toolbar);
|
|
10
|
+
|
|
11
|
+
renderFullscreenButton(fsLightbox, toolbar);
|
|
12
|
+
renderCloseButton(fsLightbox, toolbar);
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FLEX_CENTERED_CLASS_NAME, SLIDE_BTN } from "../constants/classes-names";
|
|
2
|
+
import { renderAndGetSvg } from "./helpers/renderSvg";
|
|
3
|
+
|
|
4
|
+
export function renderSlideButton(parent, d) {
|
|
5
|
+
const button = document.createElement('div');
|
|
6
|
+
button.className = `${SLIDE_BTN} ${FLEX_CENTERED_CLASS_NAME}`;
|
|
7
|
+
|
|
8
|
+
renderAndGetSvg(button, '20px', '0 0 20 20', d);
|
|
9
|
+
|
|
10
|
+
parent.appendChild(button);
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SLIDE_BTN_CONTAINER } from "../constants/classes-names";
|
|
2
|
+
import { renderSlideButton } from "./renderSlideButton";
|
|
3
|
+
|
|
4
|
+
export function renderSlideButtonContainer({ elements: { container } }, onClick, name, d) {
|
|
5
|
+
const titleName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
6
|
+
|
|
7
|
+
const slideBtnContainer = document.createElement('div');
|
|
8
|
+
slideBtnContainer.className = `${ SLIDE_BTN_CONTAINER } ${ SLIDE_BTN_CONTAINER }-${ name }`;
|
|
9
|
+
slideBtnContainer.title = `${ titleName } slide`;
|
|
10
|
+
slideBtnContainer.onclick = onClick;
|
|
11
|
+
|
|
12
|
+
renderSlideButton(slideBtnContainer, d);
|
|
13
|
+
|
|
14
|
+
container.appendChild(slideBtnContainer);
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { renderSlideButtonContainer } from "./renderSlideButtonContainer";
|
|
2
|
+
|
|
3
|
+
export function renderSlideButtons(fsLightbox) {
|
|
4
|
+
const { core: { slideChangeFacade } } = fsLightbox;
|
|
5
|
+
renderSlideButtonContainer(fsLightbox, slideChangeFacade.changeToPrevious, 'previous', 'M18.271,9.212H3.615l4.184-4.184c0.306-0.306,0.306-0.801,0-1.107c-0.306-0.306-0.801-0.306-1.107,0L1.21,9.403C1.194,9.417,1.174,9.421,1.158,9.437c-0.181,0.181-0.242,0.425-0.209,0.66c0.005,0.038,0.012,0.071,0.022,0.109c0.028,0.098,0.075,0.188,0.142,0.271c0.021,0.026,0.021,0.061,0.045,0.085c0.015,0.016,0.034,0.02,0.05,0.033l5.484,5.483c0.306,0.307,0.801,0.307,1.107,0c0.306-0.305,0.306-0.801,0-1.105l-4.184-4.185h14.656c0.436,0,0.788-0.353,0.788-0.788S18.707,9.212,18.271,9.212z');
|
|
6
|
+
renderSlideButtonContainer(fsLightbox, slideChangeFacade.changeToNext, 'next', 'M1.729,9.212h14.656l-4.184-4.184c-0.307-0.306-0.307-0.801,0-1.107c0.305-0.306,0.801-0.306,1.106,0l5.481,5.482c0.018,0.014,0.037,0.019,0.053,0.034c0.181,0.181,0.242,0.425,0.209,0.66c-0.004,0.038-0.012,0.071-0.021,0.109c-0.028,0.098-0.075,0.188-0.143,0.271c-0.021,0.026-0.021,0.061-0.045,0.085c-0.015,0.016-0.034,0.02-0.051,0.033l-5.483,5.483c-0.306,0.307-0.802,0.307-1.106,0c-0.307-0.305-0.307-0.801,0-1.105l4.184-4.185H1.729c-0.436,0-0.788-0.353-0.788-0.788S1.293,9.212,1.729,9.212z');
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ABSOLUTED_CLASS_NAME, FULL_DIMENSION_CLASS_NAME, PREFIX } from "../constants/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderSlideSwipingHoverer({ elements }) {
|
|
4
|
+
elements.slideSwipingHoverer = document.createElement('div');
|
|
5
|
+
elements.slideSwipingHoverer.className = `${PREFIX}slide-swiping-hoverer ${FULL_DIMENSION_CLASS_NAME} ${ABSOLUTED_CLASS_NAME}`;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SOURCE_CLASS_NAME } from "../../../constants/classes-names";
|
|
2
|
+
import { setUpSourceClassName } from "../../../helpers/source/setUpSourceClassName";
|
|
3
|
+
|
|
4
|
+
export function renderCustom(fsLightbox, i) {
|
|
5
|
+
const {
|
|
6
|
+
collections: { sourceLoadHandlers },
|
|
7
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
8
|
+
props: { sources }
|
|
9
|
+
} = fsLightbox;
|
|
10
|
+
|
|
11
|
+
sourcesElements[i] = sources[i];
|
|
12
|
+
setUpSourceClassName(fsLightbox, i, `${sourcesElements[i].className} ${SOURCE_CLASS_NAME}`);
|
|
13
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
14
|
+
sourceLoadHandlers[i].handleCustomLoad();
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SOURCE_CLASS_NAME } from "../../../constants/classes-names";
|
|
2
|
+
import { setUpSourceClassName } from "../../../helpers/source/setUpSourceClassName";
|
|
3
|
+
import { setUpSourceCustomAttributes } from "../../../helpers/source/setUpSourceCustomAttributes";
|
|
4
|
+
|
|
5
|
+
export function renderImage(fsLightbox, i) {
|
|
6
|
+
const {
|
|
7
|
+
collections: { sourceLoadHandlers },
|
|
8
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
9
|
+
props: { sources }
|
|
10
|
+
} = fsLightbox;
|
|
11
|
+
|
|
12
|
+
sourcesElements[i] = document.createElement('img');
|
|
13
|
+
setUpSourceClassName(fsLightbox, i, SOURCE_CLASS_NAME);
|
|
14
|
+
sourcesElements[i].src = sources[i];
|
|
15
|
+
sourcesElements[i].onload = sourceLoadHandlers[i].handleImageLoad;
|
|
16
|
+
setUpSourceCustomAttributes(fsLightbox, i);
|
|
17
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FADE_IN_STRONG_CLASS_NAME, FLEX_CENTERED_CLASS_NAME, PREFIX } from "../../../constants/classes-names";
|
|
2
|
+
|
|
3
|
+
export function renderInvalid(
|
|
4
|
+
{
|
|
5
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers, sourceMainWrappers },
|
|
6
|
+
props: { sources }
|
|
7
|
+
}, i
|
|
8
|
+
) {
|
|
9
|
+
sourcesElements[i] = document.createElement('div');
|
|
10
|
+
sourcesElements[i].className = `${PREFIX}invalid-file-wrapper ${FLEX_CENTERED_CLASS_NAME}`;
|
|
11
|
+
sourcesElements[i].innerHTML = 'Invalid source';
|
|
12
|
+
|
|
13
|
+
sourceAnimationWrappers[i].classList.add(FADE_IN_STRONG_CLASS_NAME);
|
|
14
|
+
|
|
15
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
16
|
+
|
|
17
|
+
// remove loader
|
|
18
|
+
sourceMainWrappers[i].removeChild(sourceMainWrappers[i].firstChild);
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SOURCE_CLASS_NAME } from "../../../constants/classes-names";
|
|
2
|
+
import { setUpSourceClassName } from "../../../helpers/source/setUpSourceClassName";
|
|
3
|
+
import { setUpSourceCustomAttributes } from "../../../helpers/source/setUpSourceCustomAttributes";
|
|
4
|
+
|
|
5
|
+
export function renderVideo(fsLightbox, i) {
|
|
6
|
+
const {
|
|
7
|
+
collections: { sourceLoadHandlers },
|
|
8
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
9
|
+
props: { sources, videosPosters }
|
|
10
|
+
} = fsLightbox;
|
|
11
|
+
|
|
12
|
+
sourcesElements[i] = document.createElement('video');
|
|
13
|
+
setUpSourceClassName(fsLightbox, i, SOURCE_CLASS_NAME)
|
|
14
|
+
sourcesElements[i].src = sources[i];
|
|
15
|
+
sourcesElements[i].onloadedmetadata = (e) => {
|
|
16
|
+
sourceLoadHandlers[i].handleVideoLoad(e);
|
|
17
|
+
};
|
|
18
|
+
sourcesElements[i].controls = true;
|
|
19
|
+
setUpSourceCustomAttributes(fsLightbox, i);
|
|
20
|
+
if (videosPosters[i]) {
|
|
21
|
+
sourcesElements[i].poster = videosPosters[i];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const source = document.createElement('source');
|
|
25
|
+
source.src = sources[i];
|
|
26
|
+
sourcesElements[i].appendChild(source);
|
|
27
|
+
|
|
28
|
+
setTimeout(sourceLoadHandlers[i].handleNotMetaDatedVideoLoad, 3000);
|
|
29
|
+
|
|
30
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PREFIX, SOURCE_CLASS_NAME } from "../../../constants/classes-names";
|
|
2
|
+
import { setUpSourceClassName } from "../../../helpers/source/setUpSourceClassName";
|
|
3
|
+
import { setUpSourceCustomAttributes } from "../../../helpers/source/setUpSourceCustomAttributes";
|
|
4
|
+
|
|
5
|
+
export function renderYoutube(fsLightbox, i) {
|
|
6
|
+
const {
|
|
7
|
+
collections: { sourceLoadHandlers },
|
|
8
|
+
elements: { sources: sourcesElements, sourceAnimationWrappers },
|
|
9
|
+
props: { sources }
|
|
10
|
+
} = fsLightbox;
|
|
11
|
+
|
|
12
|
+
sourcesElements[i] = document.createElement("iframe");
|
|
13
|
+
setUpSourceClassName(fsLightbox, i, `${SOURCE_CLASS_NAME} ${PREFIX}youtube-iframe`);
|
|
14
|
+
var url = sources[i];
|
|
15
|
+
var p = url.split("?")[1];
|
|
16
|
+
sourcesElements[i].src = `https://www.youtube.com/embed/${getYoutubeVideoIdFromUrl()}?${p ? p : ""}`;
|
|
17
|
+
sourcesElements[i].allowFullscreen = true;
|
|
18
|
+
setUpSourceCustomAttributes(fsLightbox, i);
|
|
19
|
+
sourceAnimationWrappers[i].appendChild(sourcesElements[i]);
|
|
20
|
+
sourceLoadHandlers[i].handleYoutubeLoad();
|
|
21
|
+
|
|
22
|
+
function getYoutubeVideoIdFromUrl() {
|
|
23
|
+
const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
|
|
24
|
+
return url.match(regExp)[2];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ABSOLUTED_CLASS_NAME,
|
|
3
|
+
FLEX_CENTERED_CLASS_NAME,
|
|
4
|
+
FULL_DIMENSION_CLASS_NAME,
|
|
5
|
+
} from "../../constants/classes-names";
|
|
6
|
+
import { renderSourceAnimationWrapper } from "./renderSourceAnimationWrapper";
|
|
7
|
+
|
|
8
|
+
export function renderSourceMainWrapper(fsLightbox, i) {
|
|
9
|
+
const {
|
|
10
|
+
componentsServices: { hideSourceLoaderIfNotYetCollection },
|
|
11
|
+
elements: { sourceWrappersContainer, sourceMainWrappers }
|
|
12
|
+
} = fsLightbox;
|
|
13
|
+
|
|
14
|
+
sourceMainWrappers[i] = document.createElement('div');
|
|
15
|
+
sourceMainWrappers[i].className = `${ABSOLUTED_CLASS_NAME} ${FULL_DIMENSION_CLASS_NAME} ${FLEX_CENTERED_CLASS_NAME}`;
|
|
16
|
+
|
|
17
|
+
sourceMainWrappers[i].innerHTML = '<div class="fslightbox-loader"><div></div><div></div><div></div><div></div></div>';
|
|
18
|
+
const loader = sourceMainWrappers[i].firstChild;
|
|
19
|
+
hideSourceLoaderIfNotYetCollection[i] = () => {
|
|
20
|
+
if (sourceMainWrappers[i].contains(loader)) {
|
|
21
|
+
sourceMainWrappers[i].removeChild(loader);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (process.env.NODE_ENV === 'development') {
|
|
26
|
+
sourceMainWrappers[i].setAttribute('data-test-class', 'source-main-wrapper');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
sourceWrappersContainer.appendChild(sourceMainWrappers[i]);
|
|
30
|
+
|
|
31
|
+
renderSourceAnimationWrapper(fsLightbox, i);
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { renderSourceMainWrapper } from "./renderSourceMainWrapper";
|
|
2
|
+
import { ABSOLUTED_CLASS_NAME, FULL_DIMENSION_CLASS_NAME } from "../../constants/classes-names";
|
|
3
|
+
|
|
4
|
+
export function renderSourceWrappersContainer(fsLightbox) {
|
|
5
|
+
const { core: { sourcesPointerDown }, elements, props: { sources } } = fsLightbox;
|
|
6
|
+
|
|
7
|
+
const sourceWrappersContainer = document.createElement('div');
|
|
8
|
+
sourceWrappersContainer.className = `${ABSOLUTED_CLASS_NAME} ${FULL_DIMENSION_CLASS_NAME}`;
|
|
9
|
+
elements.container.appendChild(sourceWrappersContainer);
|
|
10
|
+
|
|
11
|
+
sourceWrappersContainer.addEventListener('pointerdown', sourcesPointerDown.listener);
|
|
12
|
+
|
|
13
|
+
if (process.env.NODE_ENV === 'development') {
|
|
14
|
+
sourceWrappersContainer.setAttribute('data-test-id', 'source-wrappers-container');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
elements.sourceWrappersContainer = sourceWrappersContainer;
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < sources.length; i++) {
|
|
20
|
+
renderSourceMainWrapper(fsLightbox, i);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const PREFIX = 'fslightbox-';
|
|
2
|
+
|
|
3
|
+
// single classes names
|
|
4
|
+
export const FSLIGHTBOX_STYLES = `${PREFIX}styles`;
|
|
5
|
+
export const CURSOR_GRABBING_CLASS_NAME = `${PREFIX}cursor-grabbing`;
|
|
6
|
+
export const FULL_DIMENSION_CLASS_NAME = `${PREFIX}full-dimension`;
|
|
7
|
+
export const FLEX_CENTERED_CLASS_NAME = `${PREFIX}flex-centered`;
|
|
8
|
+
export const OPEN_CLASS_NAME = `${PREFIX}open`;
|
|
9
|
+
export const TRANSFORM_TRANSITION_CLASS_NAME = `${PREFIX}transform-transition`;
|
|
10
|
+
export const ABSOLUTED_CLASS_NAME = `${PREFIX}absoluted`;
|
|
11
|
+
|
|
12
|
+
// slide buttons
|
|
13
|
+
export const SLIDE_BTN = `${PREFIX}slide-btn`;
|
|
14
|
+
export const SLIDE_BTN_CONTAINER = `${SLIDE_BTN}-container`;
|
|
15
|
+
|
|
16
|
+
// animations
|
|
17
|
+
export const FADE_IN_CLASS_NAME = `${PREFIX}fade-in`;
|
|
18
|
+
export const FADE_OUT_CLASS_NAME = `${PREFIX}fade-out`;
|
|
19
|
+
export const FADE_IN_STRONG_CLASS_NAME = FADE_IN_CLASS_NAME + '-strong';
|
|
20
|
+
export const FADE_OUT_STRONG_CLASS_NAME = FADE_OUT_CLASS_NAME + '-strong';
|
|
21
|
+
|
|
22
|
+
// opacity
|
|
23
|
+
const opacityBaseClassName = `${PREFIX}opacity-`;
|
|
24
|
+
export const OPACITY_1_CLASS_NAME = `${opacityBaseClassName}1`;
|
|
25
|
+
|
|
26
|
+
// sources
|
|
27
|
+
export const SOURCE_CLASS_NAME = `${PREFIX}source`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ANIMATION_TIME = 300;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FSLIGHTBOX_STYLES_ID = 'fslightbox-styles';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SourceMainWrapperTransformer } from "../transforms/SourceMainWrapperTransformer";
|
|
2
|
+
|
|
3
|
+
export function fillSourcesOutersTransformersCollection(
|
|
4
|
+
{
|
|
5
|
+
collections: { sourceMainWrappersTransformers },
|
|
6
|
+
props: { sources },
|
|
7
|
+
resolve
|
|
8
|
+
}
|
|
9
|
+
) {
|
|
10
|
+
for (let i = 0; i < sources.length; i++) {
|
|
11
|
+
sourceMainWrappersTransformers[i] = resolve(SourceMainWrapperTransformer, [i]);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { removeFromElementClassIfContains } from "../../helpers/elements/removeFromElementClassIfContains";
|
|
2
|
+
|
|
3
|
+
export function setUpClassFacade({ core: { classFacade: self }, elements }) {
|
|
4
|
+
self.removeFromEachElementClassIfContains = (elementsArrayName, className) => {
|
|
5
|
+
for (let i = 0; i < elements[elementsArrayName].length; i++) {
|
|
6
|
+
removeFromElementClassIfContains(elements[elementsArrayName][i], className);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|