J'essaye de faire un thème tumblr simple en utilisant le plugin moelleux (https://github.com/mzdr/fluffy.js) mais j'ai rencontré un problème. Le plugin ne s'exécute qu'une seule fois lors du chargement de la page. J'essaye de l'obtenir pour fonctionner avec le plugin de défilement infini (http://www.infinite-scroll.com/) et j'ai besoin du plugin moelleux pour se déclencher chaque fois que le nouveau contenu se charge. Je suis assez nouveau quand il s'agit de JS, donc j'apprécie toute aide que je peux obtenir. Merci.Triggering fluffy.js
Modifier ajouté le code:
<script src="https://code.jquery.com/jquery-2.2.2.min.js"></script>
<script src="https://npmcdn.com/[email protected]/imagesloaded.pkgd.min.js"></script>
<script src="http://static.tumblr.com/hpghjri/co2nfnr1j/infinitescroll.min.js"></script>
<script src="http://static.tumblr.com/nxwjyyg/XWUob8gtq/fluffy.min.js"></script>
<script>
$(function(){
app.initInfinite();
app.onImagesLoad();
}); //end document ready
var app = {
'initInfinite' : function() {
var $container = $('.page-index .posts');
$container.infinitescroll({
navSelector:".pagination",
nextSelector:".pagination-next",
itemSelector:".posts__container",
appendCallback:true,
loading:{
finishedMsg:" ",
img:"data:image/gif;base64,R0lGODlhAQABAHAAACH5BAUAAAAALAAAAAABAAEAAAICRAEAOw==",
msg:null,
msgText:" ",
selector:null,
finished:function() {
}
}
},
function(newElements) {
var $newElems = $(newElements).css({opacity:0});
var $newElemsIDs = $newElems.map(function() {
return this.id;
Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
}).get();
$newElems.imagesLoaded(function() {
$newElems.animate({opacity: 1});
//what to do when new elems appended
// I need to trigger fluffy here
});
var $newElemsIDs = $newElems.map(function() {
return this.id;
}).get();
Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
});
},
'onImagesLoad' : function() {
$('.content .posts').imagesLoaded()
.always(function(instance) {
console.log('all images loaded');
$('.overlay').addClass('hide');
$('.overlay__preloader').attr('class', '');
})
.done(function(instance) {
console.log('all images successfully loaded');
});
}
}
</script>
Veuillez poster ce que vous avez fait jusqu'ici. (code) – m02ph3u5
Il ne me semble pas que Fluffy ait une option dynamique. Vous pourriez ne pas avoir de chance. – Ally