@tarojs/components
Version:
Taro 组件库。
1 lines • 3.47 kB
JavaScript
System.register(["./p-b2d01686.system.js","./p-5f4d0d5b.system.js","./p-663d1bb9.system.js"],(function(l){"use strict";var o,r,t,e,s,i,c;return{setters:[function(l){o=l.r;r=l.c;t=l.h;e=l.H;s=l.g},function(l){i=l.c},function(l){c=l.d}],execute:function(){var n="taro-scroll-view-core{display:block;width:100%;-webkit-overflow-scrolling:auto}taro-scroll-view-core::-webkit-scrollbar{display:none}.taro-scroll-view__scroll-x{overflow-x:scroll;overflow-y:hidden}.taro-scroll-view__scroll-y{overflow-x:hidden;overflow-y:scroll}";function f(l,o,r){if(l===o||typeof l!=="number"){return}var t=o-l;var e=500;var s=Date.now();var i=o>=l;function c(l,o,r,t){return r*l/t+o}function n(){l=c(Date.now()-s,l,t,e);if(i&&l>=o||!i&&o>=l){r(o);return}r(l);requestAnimationFrame(n)}n()}var h=l("taro_scroll_view_core",function(){function l(l){var t=this;o(this,l);this.onScroll=r(this,"scroll",3);this.onScrollToUpper=r(this,"scrolltoupper",3);this.onScrollToLower=r(this,"scrolltolower",3);this.scrollX=false;this.scrollY=false;this.upperThreshold=50;this.lowerThreshold=50;this.scrollWithAnimation=false;this.handleScroll=function(l){if(l instanceof CustomEvent)return;var o=t.el,r=o.scrollLeft,e=o.scrollTop,s=o.scrollHeight,i=o.scrollWidth;t._scrollLeft=r;t._scrollTop=e;t.upperAndLower();t.onScroll.emit({scrollLeft:r,scrollTop:e,scrollHeight:s,scrollWidth:i})};this.upperAndLower=c((function(){var l=t.el,o=l.offsetWidth,r=l.offsetHeight,e=l.scrollLeft,s=l.scrollTop,i=l.scrollHeight,c=l.scrollWidth;var n=Number(t.lowerThreshold);var f=Number(t.upperThreshold);if(!isNaN(n)&&(t.scrollY&&r+s+n>=i||t.scrollX&&o+e+n>=c)){t.onScrollToLower.emit({direction:t.scrollX?"right":t.scrollY?"bottom":""})}if(!isNaN(f)&&(t.scrollY&&s<=f||t.scrollX&&e<=f)){t.onScrollToUpper.emit({direction:t.scrollX?"left":t.scrollY?"top":""})}}),200)}l.prototype.watchScrollLeft=function(l){var o=this;var r=Number(l);if(this.scrollX&&!isNaN(r)&&r!==this._scrollLeft){if(this.scrollWithAnimation){f(this._scrollLeft,r,(function(l){return o.el.scrollLeft=l}))}else{this.el.scrollLeft=r}this._scrollLeft=r}};l.prototype.watchScrollTop=function(l){var o=this;var r=Number(l);if(this.scrollY&&!isNaN(r)&&r!==this._scrollTop){if(this.scrollWithAnimation){f(this._scrollTop,r,(function(l){return o.el.scrollTop=l}))}else{this.el.scrollTop=r}this._scrollTop=r}};l.prototype.watchScrollIntoView=function(l){var o;if(typeof l==="string"&&l){(o=document.querySelector("#"+l))===null||o===void 0?void 0:o.scrollIntoView({behavior:"smooth",block:"center",inline:"start"})}};l.prototype.componentDidLoad=function(){var l=this;var o=this,r=o.scrollY,t=o.scrollX,e=o.scrollWithAnimation;var s=Number(this.mpScrollTop);var i=Number(this.mpScrollLeft);if(r&&!isNaN(s)){if(e){f(0,s,(function(o){return l.el.scrollTop=o}))}else{this.el.scrollTop=s}this._scrollTop=s}if(t&&!isNaN(i)){if(e){f(0,i,(function(o){return l.el.scrollLeft=o}))}else{this.el.scrollLeft=i}this._scrollLeft=i}};l.prototype.render=function(){var l=this,o=l.scrollX,r=l.scrollY;var s=i({"taro-scroll-view__scroll-x":o,"taro-scroll-view__scroll-y":r});return t(e,{class:s,onScroll:this.handleScroll},t("slot",null))};Object.defineProperty(l.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(l,"watchers",{get:function(){return{mpScrollLeft:["watchScrollLeft"],mpScrollTop:["watchScrollTop"],mpScrollIntoView:["watchScrollIntoView"]}},enumerable:false,configurable:true});return l}());h.style=n}}}));