masonry-lightgallery 1.0.0
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/.gitattributes +2 -0
- package/README.md +2 -0
- package/masonry-lightgallery.css +72 -0
- package/masonry-lightgallery.js +59 -0
- package/package.json +20 -0
package/.gitattributes
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.mosaic-lightgallery-data {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
opacity: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.grid-item {
|
|
8
|
+
margin-bottom: 12px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.image-grid {
|
|
12
|
+
margin: 0 auto;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.grid-item img {
|
|
16
|
+
width: 380px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (max-width: 430px) {
|
|
20
|
+
.image-grid {
|
|
21
|
+
margin: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.grid-item img {
|
|
25
|
+
width: 100vw;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.lg-outer {
|
|
30
|
+
background: white;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.lg-outer button {
|
|
34
|
+
background: white;
|
|
35
|
+
color: black;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.lg-outer button:hover {
|
|
39
|
+
color: #aaa !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.lg-toolbar button {
|
|
43
|
+
color: black !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.lg-toolbar button:hover {
|
|
47
|
+
color: black !important;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.lg-toolbar .lg-counter {
|
|
51
|
+
color: black !important;
|
|
52
|
+
font-size: 18px;
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.lg-toolbar .lg-download, .lg-toolbar .lg-download:hover {
|
|
57
|
+
color: black !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.lg-sub-html {
|
|
61
|
+
color: black;
|
|
62
|
+
max-height: 20vh;
|
|
63
|
+
overflow-y: auto;
|
|
64
|
+
padding-top: 2px;
|
|
65
|
+
padding-bottom: 20px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@media (max-height: 700px) {
|
|
69
|
+
.lg-sub-html {
|
|
70
|
+
max-height: 100px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export function linesToSections(lines, baseImageUrl = 'gallery/tr/tr-', baseThumbnailUrl = 'gallery/tr-sm/tr-sm-') {
|
|
2
|
+
const sections = []
|
|
3
|
+
for (let i = 0; i < lines.length; i += 2) {
|
|
4
|
+
const section = {};
|
|
5
|
+
const titleLine = lines[i].trim();
|
|
6
|
+
section.description = lines[i + 1].trim();
|
|
7
|
+
section.title = titleLine.trim();
|
|
8
|
+
const id = parseInt(titleLine.split('. ')[0].trim());
|
|
9
|
+
// format with 3 zero padding
|
|
10
|
+
section.id = id.toString().padStart(3, '0');
|
|
11
|
+
section.imageUrl = `${baseImageUrl}${section.id}.jpg`;
|
|
12
|
+
section.imageThumbnailUrl = `${baseThumbnailUrl}${section.id}.jpg`;
|
|
13
|
+
|
|
14
|
+
sections.push(section);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return sections;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function initMasonryLightGallery(imageGridContainer, sections) {
|
|
21
|
+
// create grid items
|
|
22
|
+
sections.forEach(section => {
|
|
23
|
+
const gridItem = document.createElement('div');
|
|
24
|
+
gridItem.classList.add('grid-item');
|
|
25
|
+
const link = document.createElement('a');
|
|
26
|
+
link.href = section.imageUrl;
|
|
27
|
+
const img = document.createElement('img');
|
|
28
|
+
img.src = section.imageThumbnailUrl;
|
|
29
|
+
// img.alt = section.title;
|
|
30
|
+
const caption = `<div id='caption-${section.id}'>${section.title}<br/><b>${section.description}</b></div>`;
|
|
31
|
+
link.setAttribute('data-sub-html', caption);
|
|
32
|
+
link.appendChild(img);
|
|
33
|
+
gridItem.appendChild(link);
|
|
34
|
+
imageGridContainer.appendChild(gridItem);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const msnry = new Masonry(imageGridContainer, {
|
|
39
|
+
// options
|
|
40
|
+
itemSelector: '.grid-item',
|
|
41
|
+
columnWidth: 380,
|
|
42
|
+
gutter: 12,
|
|
43
|
+
fitWidth: true
|
|
44
|
+
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// layout Masonry after each image loads
|
|
48
|
+
$(imageGridContainer).imagesLoaded().progress(function () {
|
|
49
|
+
msnry.layout();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
lightGallery(imageGridContainer, {
|
|
53
|
+
plugins: [lgZoom],
|
|
54
|
+
speed: 0,
|
|
55
|
+
selector: '.grid-item a',
|
|
56
|
+
allowMediaOverlap: false,
|
|
57
|
+
mobileSettings: { controls: false, showCloseIcon: true, download: false, }
|
|
58
|
+
});
|
|
59
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "masonry-lightgallery",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "lightgallery with masonry layout for thumbs",
|
|
5
|
+
"homepage": "https://github.com/juozasg/masonry-lightgallery#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/juozasg/masonry-lightgallery/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/juozasg/masonry-lightgallery.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "GPL",
|
|
14
|
+
"author": "Juozas Gaigalas",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "index.js",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
|
+
}
|
|
20
|
+
}
|