koel/resources/assets/js/mixins/has-add-to-menu.js

42 lines
1,005 B
JavaScript
Raw Normal View History

/**
* Add necessary functionalities into a (song-list type) component.
*/
import addToMenu from '../components/shared/add-to-menu.vue';
export default {
components: { addToMenu },
data() {
return {
showingAddToMenu: false,
};
},
methods: {
scrolling(e) {
var $wrapper = $(this.$els.wrapper);
// Here we check if the user has scrolled to the end of the wrapper (or 32px to the end).
// If that's true, load more items.
if ($wrapper.scrollTop() + $wrapper.innerHeight() >= $wrapper[0].scrollHeight - 32) {
this.displayMore();
}
},
displayMore() {
this.numOfItems += this.perPage;
if (this.numOfItems > this.items.length) {
this.numOfItems = this.items.length;
}
},
},
events: {
2016-01-07 01:11:16 +00:00
'add-to-menu:close': function () {
this.showingAddToMenu = false;
},
},
};