mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 00:55:43 +01:00
Improvements to lightbox to get a parallax mode
This commit is contained in:
@@ -12,21 +12,32 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
-moz-border-radius: 3px;
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lightbox-data {
|
.lightbox-data {
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lightbox-data .description {
|
||||||
|
padding: 8px;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
font-family: "Georgia", "Times", "Times New Roman", Serif;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.lightbox-data .avatar img {
|
.lightbox-data .avatar img {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
padding: 5px;
|
margin: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
-moz-border-radius: 3px;
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lightbox-data .text {
|
.lightbox-data .text {
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
font-size: 18px;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
$(window).load(function() {
|
$(window).load(function() {
|
||||||
|
var scrollLevel = 0;
|
||||||
|
|
||||||
window.lightbox = function(pins) {
|
window.lightbox = function(pins) {
|
||||||
var links = pins.find('.lightbox');
|
var links = pins.find('.lightbox');
|
||||||
|
|
||||||
@@ -7,16 +9,18 @@ $(window).load(function() {
|
|||||||
var html = template(boxData);
|
var html = template(boxData);
|
||||||
$('body').append(html);
|
$('body').append(html);
|
||||||
|
|
||||||
|
scrollLevel = $(window).scrollTop();
|
||||||
|
$('#pins').css({
|
||||||
|
'margin-top': String(-scrollLevel)+'px',
|
||||||
|
'position': 'fixed'
|
||||||
|
});
|
||||||
|
|
||||||
$('.lightbox-wrapper img').load(function() {
|
$('.lightbox-wrapper img').load(function() {
|
||||||
$('.lightbox-background').css('height', String($(document).height())+'px');
|
$('.lightbox-background').css('height', String($(document).height())+'px');
|
||||||
$(this).css({
|
|
||||||
'max-width': String($(window).width()-200)+'px',
|
|
||||||
'max-height': String($(window).height()-300)+'px',
|
|
||||||
});
|
|
||||||
var width = $(this).width();
|
|
||||||
$('.lightbox-wrapper').css({
|
$('.lightbox-wrapper').css({
|
||||||
'margin-top': String($(window).scrollTop()+100)+'px',
|
'width': boxData.width,
|
||||||
'margin-left': '-'+String(width/2)+'px'
|
'margin-top': String(100)+'px',
|
||||||
|
'margin-left': '-'+String(boxData.width/2)+'px'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,10 +35,18 @@ $(window).load(function() {
|
|||||||
image: $(this).attr('href'),
|
image: $(this).attr('href'),
|
||||||
gravatar: $(this).data('gravatar'),
|
gravatar: $(this).data('gravatar'),
|
||||||
username: $(this).data('username'),
|
username: $(this).data('username'),
|
||||||
tags: $(this).data('tags').split(',')
|
description: $(this).data('description'),
|
||||||
|
tags: $(this).data('tags').split(','),
|
||||||
|
width: $(this).data('width'),
|
||||||
|
height: $(this).data('height')
|
||||||
});
|
});
|
||||||
box.click(function() {
|
box.click(function() {
|
||||||
box.remove()
|
box.remove()
|
||||||
|
$('#pins').css({
|
||||||
|
'position': 'static',
|
||||||
|
'margin-top': 0
|
||||||
|
});
|
||||||
|
$(window).scrollTop(scrollLevel);
|
||||||
});
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
<div class="lightbox-wrapper">
|
<div class="lightbox-wrapper">
|
||||||
<img src="{{image}}" />
|
<img src="{{image}}" />
|
||||||
<div class="lightbox-data clearfix">
|
<div class="lightbox-data clearfix">
|
||||||
|
{{#if description}}
|
||||||
|
<div class="description">
|
||||||
|
{{description}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
<div class="avatar pull-left">
|
<div class="avatar pull-left">
|
||||||
<img src="http://gravatar.com/avatar/{{gravatar}}.jpg">
|
<img src="http://gravatar.com/avatar/{{gravatar}}.jpg">
|
||||||
</div>
|
</div>
|
||||||
@@ -12,7 +17,7 @@
|
|||||||
{{#if tags}}
|
{{#if tags}}
|
||||||
<br /><span class="dim">in</span>
|
<br /><span class="dim">in</span>
|
||||||
{{#each tags}}
|
{{#each tags}}
|
||||||
<span class="tag label">{{this}}</span>
|
<span class="tag"><a href="/pins/tag/{{this}}/">{{this}}</a></span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<a href="{{image.standard.image}}" class="lightbox" data-username="{{submitter.username}}" data-tags="{{tags}}" data-gravatar="{{submitter.gravatar}}">
|
<a href="{{image.standard.image}}"
|
||||||
|
class="lightbox"
|
||||||
|
data-username="{{submitter.username}}"
|
||||||
|
data-tags="{{tags}}"
|
||||||
|
data-gravatar="{{submitter.gravatar}}"
|
||||||
|
data-description="{{description}}"
|
||||||
|
data-width="{{image.standard.width}}"
|
||||||
|
data-height="{{image.standard.height}}">
|
||||||
<img src="{{image.thumbnail.image}}" />
|
<img src="{{image.thumbnail.image}}" />
|
||||||
</a>
|
</a>
|
||||||
{{#if description}}
|
{{#if description}}
|
||||||
|
|||||||
Reference in New Issue
Block a user