fslightbox 3.3.2 → 3.3.3
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/README.md +24 -72
- package/index.js +1 -1
- package/package.json +1 -1
- package/FsLightbox.js +0 -110
- package/components/helpers/renderSvg.js +0 -17
- package/components/nav/renderAndGetToolbarButton.js +0 -11
- package/components/nav/renderCloseButton.js +0 -10
- package/components/nav/renderFullscreenButton.js +0 -42
- package/components/nav/renderNav.js +0 -17
- package/components/nav/renderSlideNumber.js +0 -33
- package/components/nav/renderToolbar.js +0 -13
- package/components/renderSlideButton.js +0 -11
- package/components/renderSlideButtonContainer.js +0 -15
- package/components/renderSlideButtons.js +0 -7
- package/components/renderSlideSwipingHoverer.js +0 -6
- package/components/sources/proper-sources/renderCustom.js +0 -15
- package/components/sources/proper-sources/renderImage.js +0 -18
- package/components/sources/proper-sources/renderInvalid.js +0 -19
- package/components/sources/proper-sources/renderVideo.js +0 -31
- package/components/sources/proper-sources/renderYoutube.js +0 -26
- package/components/sources/renderSourceAnimationWrapper.js +0 -4
- package/components/sources/renderSourceMainWrapper.js +0 -32
- package/components/sources/renderSourceWrappersContainer.js +0 -22
- package/constants/classes-names.js +0 -27
- package/constants/core-constants.js +0 -6
- package/constants/css-constants.js +0 -1
- package/constants/dom-constants.js +0 -1
- package/constants/elements.js +0 -3
- package/constants/local-storage-constants.js +0 -2
- package/core/collections/fillSourcesOutersTransformersCollection.js +0 -13
- package/core/elements/setUpClassFacade.js +0 -9
- package/core/events/setUpEventsDispatcher.js +0 -7
- package/core/events/setUpGlobalEventsController.js +0 -34
- package/core/fullscreen/setUpFullscreenToggler.js +0 -30
- package/core/keyboard/KeyboardController.js +0 -20
- package/core/main-component/closing/LightboxCloseActioner.js +0 -46
- package/core/main-component/closing/setUpLightboxCloser.js +0 -11
- package/core/main-component/initializing/initializeLightbox.js +0 -38
- package/core/main-component/opening/setUpLightboxOpener.js +0 -47
- package/core/scrollbar/getInnerElementOfWidthGetter.js +0 -5
- package/core/scrollbar/getOuterElementOfWidthGetter.js +0 -9
- package/core/scrollbar/getScrollbarWidth.js +0 -31
- package/core/scrollbar/setUpScrollbarRecompensor.js +0 -20
- package/core/setUpCore.js +0 -30
- package/core/sizes/setUpWindowResizeActioner.js +0 -35
- package/core/slide/setUpSlideChangeFacade.js +0 -23
- package/core/slide/setUpSlideIndexChanger.js +0 -60
- package/core/sources/SourceLoadActioner.js +0 -29
- package/core/sources/SourceLoadHandler.js +0 -41
- package/core/sources/SourceSizer.js +0 -36
- package/core/sources/creating/CreatingSourcesBucket.js +0 -29
- package/core/sources/creating/CreatingSourcesLocalStorageManager.js +0 -55
- package/core/sources/creating/createSources.js +0 -28
- package/core/sources/pointering/down/setUpSourcesPointerDown.js +0 -36
- package/core/sources/pointering/move/SourcesPointerMove.js +0 -16
- package/core/sources/pointering/move/SourcesPointerMoveActioner.js +0 -37
- package/core/sources/pointering/up/SourcesPointerUp.js +0 -13
- package/core/sources/pointering/up/SourcesPointerUpActioner.js +0 -38
- package/core/sources/pointering/up/SourcesPointerUpActionerBucket.js +0 -35
- package/core/sources/setUpSourceDisplayFacade.js +0 -26
- package/core/sources/types/AutomaticTypeDetector.js +0 -70
- package/core/sources/types/DetectedTypeActioner.js +0 -44
- package/core/sources/types/getAutomaticTypeDetectorBucket.js +0 -14
- package/core/stage/setUpStageManager.js +0 -60
- package/core/styles/createAndAppendStyles.js +0 -9
- package/core/styles/injectStylesIfNotInDom.js +0 -8
- package/core/styles/styles-injection/styles-injection.js +0 -5
- package/core/timeouts/getQueuedAction.js +0 -15
- package/core/transforms/SourceMainWrapperTransformer.js +0 -27
- package/fslightbox.js +0 -1
- package/helpers/elements/addToElementClassIfNotContains.js +0 -6
- package/helpers/elements/removeFromElementChildIfContains.js +0 -5
- package/helpers/elements/removeFromElementClassIfContains.js +0 -6
- package/helpers/objects/assignToObject.js +0 -10
- package/helpers/source/setUpSourceClassName.js +0 -13
- package/helpers/source/setUpSourceCustomAttributes.js +0 -5
- package/helpers/state/ifOnUpdateExistsHandleItForState.js +0 -6
- package/i.js +0 -86
- package/styles.js +0 -1
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const ANIMATION_TIME = 300;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const FSLIGHTBOX_STYLES_ID = 'fslightbox-styles';
|
package/constants/elements.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { KeyboardController } from "../keyboard/KeyboardController";
|
|
2
|
-
import { SourcesPointerMove } from "../sources/pointering/move/SourcesPointerMove";
|
|
3
|
-
import { SourcesPointerUp } from "../sources/pointering/up/SourcesPointerUp";
|
|
4
|
-
|
|
5
|
-
export function setUpGlobalEventsController(
|
|
6
|
-
{
|
|
7
|
-
core: { globalEventsController: self, windowResizeActioner, },
|
|
8
|
-
resolve
|
|
9
|
-
}
|
|
10
|
-
) {
|
|
11
|
-
const keyboardController = resolve(KeyboardController);
|
|
12
|
-
const sourcesPointerMove = resolve(SourcesPointerMove);
|
|
13
|
-
const sourcesPointerUp = resolve(SourcesPointerUp);
|
|
14
|
-
|
|
15
|
-
self.attachListeners = () => {
|
|
16
|
-
document.addEventListener('pointermove', sourcesPointerMove.listener);
|
|
17
|
-
|
|
18
|
-
document.addEventListener('pointerup', sourcesPointerUp.listener);
|
|
19
|
-
|
|
20
|
-
addEventListener('resize', windowResizeActioner.runActions);
|
|
21
|
-
|
|
22
|
-
document.addEventListener('keydown', keyboardController.listener);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
self.removeListeners = () => {
|
|
26
|
-
document.removeEventListener('pointermove', sourcesPointerMove.listener);
|
|
27
|
-
|
|
28
|
-
document.removeEventListener('pointerup', sourcesPointerUp.listener);
|
|
29
|
-
|
|
30
|
-
removeEventListener('resize', windowResizeActioner.runActions);
|
|
31
|
-
|
|
32
|
-
document.removeEventListener('keydown', keyboardController.listener);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export function setUpFullscreenToggler({ componentsServices, core: { fullscreenToggler: self } }) {
|
|
2
|
-
self.enterFullscreen = () => {
|
|
3
|
-
componentsServices.enterFullscreen();
|
|
4
|
-
|
|
5
|
-
const documentElement = document.documentElement;
|
|
6
|
-
if (documentElement.requestFullscreen) {
|
|
7
|
-
documentElement.requestFullscreen();
|
|
8
|
-
} else if (documentElement.mozRequestFullScreen) {
|
|
9
|
-
documentElement.mozRequestFullScreen();
|
|
10
|
-
} else if (documentElement.webkitRequestFullscreen) {
|
|
11
|
-
documentElement.webkitRequestFullscreen();
|
|
12
|
-
} else if (documentElement.msRequestFullscreen) {
|
|
13
|
-
documentElement.msRequestFullscreen();
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
self.exitFullscreen = () => {
|
|
18
|
-
componentsServices.exitFullscreen();
|
|
19
|
-
|
|
20
|
-
if (document.exitFullscreen) {
|
|
21
|
-
document.exitFullscreen();
|
|
22
|
-
} else if (document.mozCancelFullScreen) {
|
|
23
|
-
document.mozCancelFullScreen();
|
|
24
|
-
} else if (document.webkitExitFullscreen) {
|
|
25
|
-
document.webkitExitFullscreen();
|
|
26
|
-
} else if (document.msExitFullscreen) {
|
|
27
|
-
document.msExitFullscreen();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function KeyboardController({ core: { lightboxCloser, fullscreenToggler, slideChangeFacade } }) {
|
|
2
|
-
this.listener = (e) => {
|
|
3
|
-
switch (e.key) {
|
|
4
|
-
case 'Escape':
|
|
5
|
-
lightboxCloser.closeLightbox();
|
|
6
|
-
break;
|
|
7
|
-
case 'ArrowLeft':
|
|
8
|
-
slideChangeFacade.changeToPrevious();
|
|
9
|
-
break;
|
|
10
|
-
case 'ArrowRight':
|
|
11
|
-
slideChangeFacade.changeToNext();
|
|
12
|
-
break;
|
|
13
|
-
case 'F11':
|
|
14
|
-
e.preventDefault();
|
|
15
|
-
// browsers does not trigger 'keydown' event when browser is already in fullscreen
|
|
16
|
-
fullscreenToggler.enterFullscreen();
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { FADE_OUT_STRONG_CLASS_NAME, OPEN_CLASS_NAME } from "../../../constants/classes-names";
|
|
2
|
-
import { ANIMATION_TIME } from "../../../constants/css-constants";
|
|
3
|
-
|
|
4
|
-
export function LightboxCloseActioner(
|
|
5
|
-
{
|
|
6
|
-
core: {
|
|
7
|
-
eventsDispatcher,
|
|
8
|
-
fullscreenToggler,
|
|
9
|
-
globalEventsController,
|
|
10
|
-
scrollbarRecompensor
|
|
11
|
-
},
|
|
12
|
-
data,
|
|
13
|
-
elements,
|
|
14
|
-
props,
|
|
15
|
-
sourcePointerProps
|
|
16
|
-
}
|
|
17
|
-
) {
|
|
18
|
-
this.isLightboxFadingOut = false;
|
|
19
|
-
|
|
20
|
-
this.runActions = () => {
|
|
21
|
-
this.isLightboxFadingOut = true;
|
|
22
|
-
|
|
23
|
-
elements.container.classList.add(FADE_OUT_STRONG_CLASS_NAME);
|
|
24
|
-
|
|
25
|
-
globalEventsController.removeListeners();
|
|
26
|
-
|
|
27
|
-
if (props.exitFullscreenOnClose && data.isFullscreenOpen) {
|
|
28
|
-
fullscreenToggler.exitFullscreen();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
this.isLightboxFadingOut = false;
|
|
33
|
-
|
|
34
|
-
sourcePointerProps.isPointering = false;
|
|
35
|
-
|
|
36
|
-
elements.container.classList.remove(FADE_OUT_STRONG_CLASS_NAME);
|
|
37
|
-
document.documentElement.classList.remove(OPEN_CLASS_NAME);
|
|
38
|
-
|
|
39
|
-
scrollbarRecompensor.removeRecompense();
|
|
40
|
-
|
|
41
|
-
document.body.removeChild(elements.container);
|
|
42
|
-
|
|
43
|
-
eventsDispatcher.dispatch('onClose');
|
|
44
|
-
}, ANIMATION_TIME - 30);
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LightboxCloseActioner } from "./LightboxCloseActioner";
|
|
2
|
-
|
|
3
|
-
export function setUpLightboxCloser({ core: { lightboxCloser: self }, resolve }) {
|
|
4
|
-
const lightboxCloseActioner = resolve(LightboxCloseActioner);
|
|
5
|
-
|
|
6
|
-
self.closeLightbox = () => {
|
|
7
|
-
if (!lightboxCloseActioner.isLightboxFadingOut) {
|
|
8
|
-
lightboxCloseActioner.runActions();
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FADE_IN_STRONG_CLASS_NAME,
|
|
3
|
-
FULL_DIMENSION_CLASS_NAME,
|
|
4
|
-
PREFIX
|
|
5
|
-
} from "../../../constants/classes-names";
|
|
6
|
-
import { createSources } from "../../sources/creating/createSources";
|
|
7
|
-
import { renderSourceWrappersContainer } from "../../../components/sources/renderSourceWrappersContainer";
|
|
8
|
-
import { renderNav } from "../../../components/nav/renderNav";
|
|
9
|
-
import { fillSourcesOutersTransformersCollection } from "../../collections/fillSourcesOutersTransformersCollection";
|
|
10
|
-
import { renderSlideButtons } from "../../../components/renderSlideButtons";
|
|
11
|
-
import { renderSlideSwipingHoverer } from "../../../components/renderSlideSwipingHoverer";
|
|
12
|
-
import { setUpCore } from "../../setUpCore";
|
|
13
|
-
import { getScrollbarWidth } from "../../scrollbar/getScrollbarWidth";
|
|
14
|
-
|
|
15
|
-
export function initializeLightbox(fsLightbox) {
|
|
16
|
-
const { core: { eventsDispatcher }, data, elements, props: { sources } } = fsLightbox;
|
|
17
|
-
|
|
18
|
-
data.isInitialized = true;
|
|
19
|
-
data.scrollbarWidth = getScrollbarWidth(fsLightbox);
|
|
20
|
-
|
|
21
|
-
fillSourcesOutersTransformersCollection(fsLightbox);
|
|
22
|
-
|
|
23
|
-
setUpCore(fsLightbox);
|
|
24
|
-
|
|
25
|
-
elements.container = document.createElement('div');
|
|
26
|
-
elements.container.className = `${PREFIX}container ${FULL_DIMENSION_CLASS_NAME} ${FADE_IN_STRONG_CLASS_NAME}`;
|
|
27
|
-
|
|
28
|
-
renderSlideSwipingHoverer(fsLightbox);
|
|
29
|
-
renderNav(fsLightbox);
|
|
30
|
-
renderSourceWrappersContainer(fsLightbox);
|
|
31
|
-
if (sources.length > 1) {
|
|
32
|
-
renderSlideButtons(fsLightbox);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
createSources(fsLightbox);
|
|
36
|
-
|
|
37
|
-
eventsDispatcher.dispatch('onInit');
|
|
38
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { OPEN_CLASS_NAME } from "../../../constants/classes-names";
|
|
2
|
-
import { initializeLightbox } from "../initializing/initializeLightbox";
|
|
3
|
-
|
|
4
|
-
export function setUpLightboxOpener(fsLightbox) {
|
|
5
|
-
const {
|
|
6
|
-
collections: { sourceMainWrappersTransformers },
|
|
7
|
-
componentsServices,
|
|
8
|
-
core: {
|
|
9
|
-
eventsDispatcher,
|
|
10
|
-
lightboxOpener: self,
|
|
11
|
-
globalEventsController,
|
|
12
|
-
scrollbarRecompensor,
|
|
13
|
-
sourceDisplayFacade,
|
|
14
|
-
stageManager,
|
|
15
|
-
windowResizeActioner
|
|
16
|
-
},
|
|
17
|
-
data,
|
|
18
|
-
elements,
|
|
19
|
-
stageIndexes
|
|
20
|
-
} = fsLightbox;
|
|
21
|
-
|
|
22
|
-
self.open = (index = 0) => {
|
|
23
|
-
stageIndexes.current = index;
|
|
24
|
-
|
|
25
|
-
(data.isInitialized) ?
|
|
26
|
-
eventsDispatcher.dispatch('onShow') :
|
|
27
|
-
initializeLightbox(fsLightbox);
|
|
28
|
-
|
|
29
|
-
stageManager.updateStageIndexes();
|
|
30
|
-
|
|
31
|
-
sourceDisplayFacade.displaySourcesWhichShouldBeDisplayed();
|
|
32
|
-
|
|
33
|
-
componentsServices.setSlideNumber(index + 1);
|
|
34
|
-
|
|
35
|
-
document.body.appendChild(elements.container);
|
|
36
|
-
document.documentElement.classList.add(OPEN_CLASS_NAME);
|
|
37
|
-
|
|
38
|
-
scrollbarRecompensor.addRecompense();
|
|
39
|
-
|
|
40
|
-
globalEventsController.attachListeners();
|
|
41
|
-
|
|
42
|
-
windowResizeActioner.runActions();
|
|
43
|
-
sourceMainWrappersTransformers[stageIndexes.current].zero();
|
|
44
|
-
|
|
45
|
-
eventsDispatcher.dispatch('onOpen');
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function getOuterElementOfWidthGetter() {
|
|
2
|
-
const outer = document.createElement('div');
|
|
3
|
-
const outerStyle = outer.style;
|
|
4
|
-
outerStyle.visibility = "hidden";
|
|
5
|
-
outerStyle.width = "100px";
|
|
6
|
-
outerStyle.msOverflowStyle = "scrollbar";
|
|
7
|
-
outerStyle.overflow = "scroll";
|
|
8
|
-
return outer;
|
|
9
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { getOuterElementOfWidthGetter } from "./getOuterElementOfWidthGetter";
|
|
2
|
-
import { getInnerElementOfWidthGetter } from "./getInnerElementOfWidthGetter";
|
|
3
|
-
import { SCROLLBAR_WIDTH_KEY } from "../../constants/local-storage-constants";
|
|
4
|
-
|
|
5
|
-
export function getScrollbarWidth({ props: { disableLocalStorage } }) {
|
|
6
|
-
if (!disableLocalStorage) {
|
|
7
|
-
const localStorageScrollbarWidth = localStorage.getItem(SCROLLBAR_WIDTH_KEY);
|
|
8
|
-
if (localStorageScrollbarWidth) {
|
|
9
|
-
return localStorageScrollbarWidth;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const outer = getOuterElementOfWidthGetter();
|
|
14
|
-
const inner = getInnerElementOfWidthGetter();
|
|
15
|
-
|
|
16
|
-
document.body.appendChild(outer);
|
|
17
|
-
const widthNoScroll = outer.offsetWidth;
|
|
18
|
-
|
|
19
|
-
outer.appendChild(inner);
|
|
20
|
-
const widthWithScroll = inner.offsetWidth;
|
|
21
|
-
|
|
22
|
-
document.body.removeChild(outer);
|
|
23
|
-
|
|
24
|
-
const scrollbarWidth = widthNoScroll - widthWithScroll;
|
|
25
|
-
|
|
26
|
-
if (!disableLocalStorage) {
|
|
27
|
-
localStorage.setItem(SCROLLBAR_WIDTH_KEY, scrollbarWidth.toString());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return scrollbarWidth;
|
|
31
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function setUpScrollbarRecompensor({ data, core: { scrollbarRecompensor: self } }) {
|
|
2
|
-
self.addRecompense = () => {
|
|
3
|
-
(document.readyState === "complete") ?
|
|
4
|
-
ifBodyIsHigherThanWindowAddRecompenseToScrollbar() :
|
|
5
|
-
addEventListener('load', () => {
|
|
6
|
-
ifBodyIsHigherThanWindowAddRecompenseToScrollbar();
|
|
7
|
-
self.addRecompense = ifBodyIsHigherThanWindowAddRecompenseToScrollbar;
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
function ifBodyIsHigherThanWindowAddRecompenseToScrollbar() {
|
|
12
|
-
if (document.body.offsetHeight > innerHeight) {
|
|
13
|
-
document.body.style.marginRight = data.scrollbarWidth + 'px';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
self.removeRecompense = () => {
|
|
18
|
-
document.body.style.removeProperty('margin-right');
|
|
19
|
-
};
|
|
20
|
-
}
|
package/core/setUpCore.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { setUpLightboxOpener } from "./main-component/opening/setUpLightboxOpener";
|
|
2
|
-
import { setUpClassFacade } from "./elements/setUpClassFacade";
|
|
3
|
-
import { setUpEventsDispatcher } from "./events/setUpEventsDispatcher";
|
|
4
|
-
import { setUpFullscreenToggler } from "./fullscreen/setUpFullscreenToggler";
|
|
5
|
-
import { setUpLightboxCloser } from "./main-component/closing/setUpLightboxCloser";
|
|
6
|
-
import { setUpWindowResizeActioner } from "./sizes/setUpWindowResizeActioner";
|
|
7
|
-
import { setUpScrollbarRecompensor } from "./scrollbar/setUpScrollbarRecompensor";
|
|
8
|
-
import { setUpSlideIndexChanger } from "./slide/setUpSlideIndexChanger";
|
|
9
|
-
import { setUpGlobalEventsController } from "./events/setUpGlobalEventsController";
|
|
10
|
-
import { setUpSlideChangeFacade } from "./slide/setUpSlideChangeFacade";
|
|
11
|
-
import { setUpSourceDisplayFacade } from "./sources/setUpSourceDisplayFacade";
|
|
12
|
-
import { setUpStageManager } from "./stage/setUpStageManager";
|
|
13
|
-
import { setUpSourcesPointerDown } from "./sources/pointering/down/setUpSourcesPointerDown";
|
|
14
|
-
|
|
15
|
-
export function setUpCore(fsLightbox) {
|
|
16
|
-
setUpClassFacade(fsLightbox);
|
|
17
|
-
setUpEventsDispatcher(fsLightbox);
|
|
18
|
-
setUpFullscreenToggler(fsLightbox);
|
|
19
|
-
setUpGlobalEventsController(fsLightbox);
|
|
20
|
-
setUpLightboxCloser(fsLightbox);
|
|
21
|
-
setUpLightboxOpener(fsLightbox);
|
|
22
|
-
setUpScrollbarRecompensor(fsLightbox);
|
|
23
|
-
setUpSlideChangeFacade(fsLightbox);
|
|
24
|
-
setUpSlideIndexChanger(fsLightbox);
|
|
25
|
-
setUpSourcesPointerDown(fsLightbox);
|
|
26
|
-
setUpSourceDisplayFacade(fsLightbox);
|
|
27
|
-
setUpStageManager(fsLightbox);
|
|
28
|
-
setUpWindowResizeActioner(fsLightbox);
|
|
29
|
-
}
|
|
30
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { removeFromElementClassIfContains } from "../../helpers/elements/removeFromElementClassIfContains";
|
|
2
|
-
import { TRANSFORM_TRANSITION_CLASS_NAME } from "../../constants/classes-names";
|
|
3
|
-
|
|
4
|
-
export function setUpWindowResizeActioner(
|
|
5
|
-
{
|
|
6
|
-
collections: { sourceMainWrappersTransformers, sourceSizers },
|
|
7
|
-
core: { windowResizeActioner: self },
|
|
8
|
-
data,
|
|
9
|
-
elements: { sourceMainWrappers },
|
|
10
|
-
props,
|
|
11
|
-
stageIndexes
|
|
12
|
-
}
|
|
13
|
-
) {
|
|
14
|
-
self.runActions = () => {
|
|
15
|
-
// decreasing max source dimensions for better UX
|
|
16
|
-
(innerWidth < 992) ?
|
|
17
|
-
data.maxSourceWidth = innerWidth :
|
|
18
|
-
data.maxSourceWidth = 0.9 * innerWidth;
|
|
19
|
-
data.maxSourceHeight = 0.9 * innerHeight;
|
|
20
|
-
|
|
21
|
-
for (let i = 0; i < props.sources.length; i++) {
|
|
22
|
-
removeFromElementClassIfContains(sourceMainWrappers[i], TRANSFORM_TRANSITION_CLASS_NAME);
|
|
23
|
-
|
|
24
|
-
if (i !== stageIndexes.current) {
|
|
25
|
-
sourceMainWrappersTransformers[i].negative();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// if source is Invalid or if lightbox is initialized there are no sourceSizers
|
|
29
|
-
// so we need to check if it exists
|
|
30
|
-
if (sourceSizers[i]) {
|
|
31
|
-
sourceSizers[i].adjustSize();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function setUpSlideChangeFacade(
|
|
2
|
-
{
|
|
3
|
-
core: {
|
|
4
|
-
slideChangeFacade: self,
|
|
5
|
-
slideIndexChanger,
|
|
6
|
-
stageManager
|
|
7
|
-
},
|
|
8
|
-
props: { sources }
|
|
9
|
-
}
|
|
10
|
-
) {
|
|
11
|
-
if (sources.length > 1) {
|
|
12
|
-
self.changeToPrevious = () => {
|
|
13
|
-
slideIndexChanger.jumpTo(stageManager.getPreviousSlideIndex());
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
self.changeToNext = () => {
|
|
17
|
-
slideIndexChanger.jumpTo(stageManager.getNextSlideIndex());
|
|
18
|
-
};
|
|
19
|
-
} else {
|
|
20
|
-
self.changeToPrevious = () => {};
|
|
21
|
-
self.changeToNext = () => {};
|
|
22
|
-
}
|
|
23
|
-
}
|