mirror of
https://github.com/pinry/pinry.git
synced 2025-11-18 02:40:40 +01:00
Feature: Closing for pin-preview works well with auto-close
This commit is contained in:
committed by
Isaac Bythewood
parent
9777c9bd73
commit
d7ba05103a
@@ -2,7 +2,10 @@ var events = new Vue({});
|
|||||||
var eventsName = {
|
var eventsName = {
|
||||||
pinReflowDone: "single-pin-reflow-done",
|
pinReflowDone: "single-pin-reflow-done",
|
||||||
allPinReflowDone: "all-pin-reflow-done",
|
allPinReflowDone: "all-pin-reflow-done",
|
||||||
viewPin: "view-single-pin"
|
pinView: {
|
||||||
|
open: "view-single-pin",
|
||||||
|
close: "close-pin-view",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function fetchPins(offset) {
|
function fetchPins(offset) {
|
||||||
@@ -133,7 +136,6 @@ Vue.component(
|
|||||||
var windowHeight = utils.getWindowHeight();
|
var windowHeight = utils.getWindowHeight();
|
||||||
var backgroundHeight = documentHeight;
|
var backgroundHeight = documentHeight;
|
||||||
var lightBoxWrapperStyle = {
|
var lightBoxWrapperStyle = {
|
||||||
'height': imageHeight + 'px',
|
|
||||||
'width': imageWidth + "px",
|
'width': imageWidth + "px",
|
||||||
'marginTop': '80px',
|
'marginTop': '80px',
|
||||||
'marginBottom': '80px',
|
'marginBottom': '80px',
|
||||||
@@ -152,6 +154,11 @@ Vue.component(
|
|||||||
height: imageHeight + 'px',
|
height: imageHeight + 'px',
|
||||||
};
|
};
|
||||||
this.lightBoxWrapperStyle = lightBoxWrapperStyle;
|
this.lightBoxWrapperStyle = lightBoxWrapperStyle;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onCloseView: function() {
|
||||||
|
events.$emit(eventsName.pinView.close);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -186,7 +193,7 @@ Vue.component('pin', {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showImageDetail: function(event) {
|
showImageDetail: function(event) {
|
||||||
events.$emit(eventsName.viewPin, this.pin);
|
events.$emit(eventsName.pinView.open, this.pin);
|
||||||
if (event) event.preventDefault();
|
if (event) event.preventDefault();
|
||||||
},
|
},
|
||||||
reflow: function() {
|
reflow: function() {
|
||||||
@@ -424,14 +431,21 @@ var app = new Vue({
|
|||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
events.$on(
|
events.$on(
|
||||||
eventsName.viewPin,
|
eventsName.pinView.open,
|
||||||
this.onViewPin,
|
this.onViewPin,
|
||||||
);
|
);
|
||||||
|
events.$on(
|
||||||
|
eventsName.pinView.close,
|
||||||
|
this.onClosePin,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onViewPin: function(pin) {
|
onViewPin: function(pin) {
|
||||||
this.currentPin = pin;
|
this.currentPin = pin;
|
||||||
},
|
},
|
||||||
|
onClosePin: function(pin) {
|
||||||
|
this.currentPin = null;
|
||||||
|
},
|
||||||
onLoaded: function(){
|
onLoaded: function(){
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% verbatim %}
|
{% verbatim %}
|
||||||
<script id="lightbox-template" type="text/x-template">
|
<script id="lightbox-template" type="text/x-template">
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<div class="lightbox-background" :style="backgroundStyle">
|
<div class="lightbox-background" :style="backgroundStyle" v-on:click.self="onCloseView()">
|
||||||
<div class="lightbox-wrapper" :style="lightBoxWrapperStyle">
|
<div class="lightbox-wrapper" :style="lightBoxWrapperStyle">
|
||||||
<div class="lightbox-image-wrapper" :style="lightBoxImageWrapperStyle">
|
<div class="lightbox-image-wrapper" :style="lightBoxImageWrapperStyle">
|
||||||
<img class="lightbox-image" :src="pin.image.image" />
|
<img class="lightbox-image" :src="pin.image.image" />
|
||||||
|
|||||||
Reference in New Issue
Block a user