UNPKG

1.23 kBJavaScriptView Raw
1!function(){"use strict";window.Ractive.controller("pl-grouped-list",function(e,t,i,l,o){function n(){r.fire("refresh")}t.lvl=0,t.level=function(e){return e.split("items").length-2};var r=e({plName:"pl-grouped-list",data:t}),s={window:$(window),list:$(r.el).find(".pl-grouped-list"),content:$(r.el).find(".pl-grouped-list-content")};r.on("refresh",function(){var e=s.list.get(0).scrollTop,t=null;s.content.children().each(function(){var i=e,l=$(this),o=l.data("level");l.removeClass("grouped-list-fixed grouped-list-fixed-last").css("top","");var n=l.position().top;if(0!==o){var d=$(l.prevAll(".level-"+(o-1)).get(0));i=Math.max(n,d.position().top+d.outerHeight(!0))}if(i>n){var a=l.outerHeight(!0),f=l.find("~ .grouped-list-item").filter(function(){return $(this).data("level")<=o});f=f.length?$(f.get(0)):null;var p=f?f.position().top-a:s.content.outerHeight()-a;l.css({"z-index":9999-o,top:Math.min(i,p)-n}),p>i&&(l.addClass("grouped-list-fixed"),t=l,r.fire("fixed",{item:l}))}}),t&&(t.addClass("grouped-list-fixed-last"),r.fire("lastFixed",{item:t}))}),s.list.scroll(n),s.window.resize(n),r.on("teardown",function(){s.window.off("resize",n)}),r.observe("items",n),n(),o()})}();
2//# sourceMappingURL=pl-grouped-list.min.js.map