Browse Source

images in gallery now have hover effect when using macro

Thomas Buck 3 years ago
parent
commit
958565f90e
4 changed files with 32 additions and 3 deletions
  1. 1
    1
      macros.py
  2. 7
    2
      page.html
  3. 5
    0
      static/css/print.css
  4. 19
    0
      static/css/style.css

+ 1
- 1
macros.py View File

@@ -19,7 +19,7 @@ def lightgallery(links):
19 19
             link, alt = l
20 20
             x = link.rfind('.')
21 21
             img = link[:x] + '_small' + link[x:]
22
-        print '<a href="' + link + '"><img src="' + img + '" alt="' + alt + '"></a>'
22
+        print '<div class="border" data-src="' + link + '"><a href="' + link + '"><img class="pic" src="' + img + '" alt="' + alt + '"></a></div>'
23 23
     print '</div>'
24 24
 
25 25
 # -----------------------------------------------------------------------------

+ 7
- 2
page.html View File

@@ -195,7 +195,7 @@ else:
195 195
         $(document).ready(function() {
196 196
             var lg = document.getElementsByClassName("lightgallery");
197 197
             for (var i = 0; i < lg.length; i++) {
198
-                $(lg.item(i)).lightGallery({
198
+                var settings = {
199 199
                     loadYoutubeThumbnail: true,
200 200
                     youtubeThumbSize: 'mqdefault',
201 201
                     loadVimeoThumbnail: true,
@@ -213,7 +213,12 @@ else:
213 213
                     animateThumb: true,
214 214
                     showThumbByDefault: false,
215 215
                     galleryId: i
216
-                });
216
+                };
217
+                var d = lg.item(i);
218
+                if ($(d).find(".border").length > 0) {
219
+                    settings.selector = '.border';
220
+                }
221
+                $(d).lightGallery(settings);
217 222
             }
218 223
         });
219 224
     </script>

+ 5
- 0
static/css/print.css View File

@@ -10,6 +10,11 @@
10 10
     display: none;
11 11
 }
12 12
 
13
+.border {
14
+    display: inline-block;
15
+    border-radius: 10px;
16
+}
17
+
13 18
 pre {
14 19
     max-height: 100%;
15 20
     font-size: 0.9em;

+ 19
- 0
static/css/style.css View File

@@ -15,6 +15,7 @@ hr {
15 15
     border-bottom-color: purple; /* green; */ /* orange; */
16 16
     background-color: white;
17 17
     width: 100%;
18
+    z-index: 2;
18 19
 }
19 20
 
20 21
 #content {
@@ -131,3 +132,21 @@ span.font-small {
131 132
     font-size: 0.6em;
132 133
 }
133 134
 
135
+.border {
136
+    overflow: hidden;
137
+    height: auto;
138
+    display: inline-block;
139
+    border-radius: 10px;
140
+    vertical-align: middle;
141
+    margin: 3px 0 3px 0;
142
+}
143
+
144
+.border .pic {
145
+    transition: transform 0.1s;
146
+    vertical-align: bottom;
147
+}
148
+
149
+.border:hover .pic {
150
+    transform: scale(1.1, 1.1);
151
+    filter: brightness(75%);
152
+}

Loading…
Cancel
Save