Browse Source

Feature: Implements FadeIn and Fadeout for specified pin

pull/169/head
winkidney 5 years ago
committed by Isaac Bythewood
parent
commit
01bac724d6
7 changed files with 34 additions and 19 deletions
  1. +0
    -1
      pinry/static/css/pinry.css
  2. +7
    -0
      pinry/static/css/vue-pin.css
  3. +0
    -12
      pinry/static/js/helpers.js
  4. +14
    -0
      pinry/static/js/vue/main.js
  5. +2
    -4
      pinry/templates/base.html
  6. +9
    -0
      pinry/templates/includes/vue-pin.html
  7. +2
    -2
      pinry/templates/includes/vue-pins.html

+ 0
- 1
pinry/static/css/pinry.css View File

@@ -185,7 +185,6 @@ textarea {
-webkit-box-shadow: 0 1px 0 #bbb; -webkit-box-shadow: 0 1px 0 #bbb;
-moz-box-shadow: 0 1px 0 #bbb; -moz-box-shadow: 0 1px 0 #bbb;
box-shadow: 0 1px 0 #bbb; box-shadow: 0 1px 0 #bbb;
display: none;
position: absolute; position: absolute;
width: 240px; width: 240px;
} }


+ 7
- 0
pinry/static/css/vue-pin.css View File

@@ -0,0 +1,7 @@
.fade-enter-active, .fade-leave-active {
transition: opacity .3s;
}

.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0;
}

+ 0
- 12
pinry/static/js/helpers.js View File

@@ -87,15 +87,3 @@ function postPinData(data) {
function getUrlParameter(name) { function getUrlParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
} }

Handlebars.registerHelper('niceLinks', (function () {
var reNL = /\r?\n/g,
reURL = /https?:[/][/](?:www[.])?([^/]+)(?:[/]([.]?[^\s,.])+)?/g;
return function (text) {
var t = Handlebars.Utils.escapeExpression(text);
t = t.replace(reURL, '<a href="$&" target="_blank">$1</a>');
t = t.replace(reNL, '<br>');
return new Handlebars.SafeString(t);
};
})());


+ 14
- 0
pinry/static/js/vue/main.js View File

@@ -6,6 +6,20 @@ function fetchPins(offset) {
return axios.get(apiUrl) return axios.get(apiUrl)
} }


Vue.component('pin', {
data: function () {
return {'loaded': false}
},
props: ['pin'],
template: '#pin-template',
methods: {
onImageLoad: function () {
this.loaded = true;
}
}
});


var app = new Vue({ var app = new Vue({
el: '#app', el: '#app',
components: { components: {


+ 2
- 4
pinry/templates/base.html View File

@@ -16,6 +16,7 @@
<link rel="stylesheet" href="{% static "css/messages.css" %}"/> <link rel="stylesheet" href="{% static "css/messages.css" %}"/>
<link rel="stylesheet" href="{% static "css/lightbox.css" %}"/> <link rel="stylesheet" href="{% static "css/lightbox.css" %}"/>
<link rel="stylesheet" href="{% static "css/pinry.css" %}"/> <link rel="stylesheet" href="{% static "css/pinry.css" %}"/>
<link rel="stylesheet" href="{% static "css/vue-pin.css" %}"/>
{% endcompress %} {% endcompress %}
{% compress css inline %} {% compress css inline %}
{% block extra_css %}{% endblock %} {% block extra_css %}{% endblock %}
@@ -95,6 +96,7 @@
<!-- End Content --> <!-- End Content -->


<!-- Templates --> <!-- Templates -->
{% include 'includes/vue-pin.html' %}
{% block extra_templates %}{% endblock %} {% block extra_templates %}{% endblock %}
<!-- End Templates --> <!-- End Templates -->


@@ -108,10 +110,6 @@
{% compress js %} {% compress js %}
<script src="{% static "js/helpers.js" %}"></script> <script src="{% static "js/helpers.js" %}"></script>
<script src="{% static "js/vendors/vue-waterfall.min.js" %}"></script> <script src="{% static "js/vendors/vue-waterfall.min.js" %}"></script>
{# <script src="{% static "js/messages.js" %}"></script>#}
{# <script src="{% static "js/lightbox.js" %}"></script>#}
{# <script src="{% static "js/pinry.js" %}"></script>#}
{# <script src="{% static "js/pin-form.js" %}"></script>#}
<script src="{% static "js/vue/main.js" %}"></script> <script src="{% static "js/vue/main.js" %}"></script>
{% endcompress %} {% endcompress %}
{% compress js inline %} {% compress js inline %}


+ 9
- 0
pinry/templates/includes/vue-pin.html View File

@@ -0,0 +1,9 @@
{% verbatim %}
<script type="text/x-template" id="pin-template">
<transition name="fade">
<div class="pin pin-wrapper" v-show="loaded">
<img :src="pin.image.thumbnail.image" v-on:load="onImageLoad">
</div>
</transition>
</script>
{% endverbatim %}

+ 2
- 2
pinry/templates/includes/vue-pins.html View File

@@ -1,6 +1,6 @@
{% verbatim %} {% verbatim %}


<waterfall :line-gap="200" :watch="pins">
<waterfall :line-gap="240" :watch="pins">
<!-- each component is wrapped by a waterfall slot --> <!-- each component is wrapped by a waterfall slot -->
<waterfall-slot <waterfall-slot
v-for="(item, index) in pins" v-for="(item, index) in pins"
@@ -9,7 +9,7 @@
:order="index" :order="index"
:key="item.id" :key="item.id"
> >
<img :src="item.image.thumbnail.image">
<pin :pin="item"></pin>
</waterfall-slot> </waterfall-slot>
</waterfall> </waterfall>




Loading…
Cancel
Save