UNPKG

plumes

Version:

Flying-fast Metro future vision components

3 lines (2 loc) 2.6 kB
!function(){"use strict";window.Ractive.controller("pl-scrolls",function(e,o,t,n,i){function r(){var e=T.container.prop("scrollHeight"),o=T.vertical.outerHeight(),t=100*o/e;y.set("active",e>o),y.set("height",t),l()}function l(){var e=T.container.prop("scrollHeight"),o=T.container.scrollTop(),t=100*o/e;y.set("top",t)}function c(){return T.verticalTicker.offset().top-T.vertical.offset().top}function a(e){f={scrollTop:T.container.scrollTop(),pageY:e.pageY},y.set("inDrag",!0),e.preventDefault(),e.stopPropagation()}function s(e){if(f){var o=T.container.prop("scrollHeight"),t=T.vertical.outerHeight(),n=f.scrollTop+(e.pageY-f.pageY)*o/t;T.container.scrollTop(n),e.preventDefault(),e.stopPropagation()}}function u(){f=!1,y.set("inDrag",!1)}function v(){r(),y.set("enter",!0)}function p(){y.set("enter",!1)}var d=268,f=!1,h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"];if("undefined"==typeof window.Ractive.plScrollsWidth){var g=$("<div/>").css({"overflow-y":"auto","overflow-x":"hidden",visibility:"hidden",height:50,width:100}).html('<div style="height: 200px; width: 100%"></div>');$("body").append(g);var m=Math.ceil(100-g.find("div").width());g.remove();var w=window.document.styleSheets[0];w.insertRule?w.insertRule(".pl-scrolls { margin-right: -"+m+"px; }",w.cssRules.length):w.addRule(".pl-scrolls","margin-right: -"+m+"px;",-1),window.Ractive.plScrollsWidth=m}var y=e({plName:"pl-scrolls",data:$.extend(!0,{top:0,height:0,active:!1,hover:!1,inDrag:!1,enter:!1},o),update:r}),T={body:$("body"),scrolls:$(y.el),vertical:$(y.el).find(".pl-scrolls-vertical"),verticalTicker:$(y.el).find(".pl-scrolls-vertical-ticker"),container:$(y.el).next(".pl-scrolls")};y.on("teardown",function(){T.container.off("scroll",l),T.body.off("mousemove",s),T.body.off("mouseup",u),T.container.off("mouseenter",v),T.container.off("mouseenter",p),T=null,y=null}),T.container.scroll(l),T.vertical.mouseenter(function(){y.set("hover",!0)}),T.vertical.mouseleave(function(){y.set("hover",!1)}),T.vertical.click(function(e){if(e.target==T.vertical[0]){var t=c(),n=T.container.scrollTop();T.container.stop().animate({scrollTop:n+(t>e.offsetY?-d:d)},150,o.easing||"swing")}}),$.each(h,function(e,o){T.vertical.on(o,function(e){var t=new window.WheelEvent(o,e.originalEvent);document.createEvent?T.container[0].dispatchEvent(t):T.container[0].fireEvent("on"+t.eventType,t)})}),T.verticalTicker.mousedown(a),T.body.mousemove(s),T.body.mouseup(u),T.container.mouseenter(v),T.container.mouseleave(p),r(),i()})}(); //# sourceMappingURL=pl-scrolls.min.js.map