UNPKG

@tarojs/components

Version:
1 lines 5.83 kB
var __awaiter=this&&this.__awaiter||function(t,o,r,e){function l(t){return t instanceof r?t:new r((function(o){o(t)}))}return new(r||(r=Promise))((function(r,n){function i(t){try{c(e.next(t))}catch(t){n(t)}}function s(t){try{c(e["throw"](t))}catch(t){n(t)}}function c(t){t.done?r(t.value):l(t.value).then(i,s)}c((e=e.apply(t,o||[])).next())}))};var __generator=this&&this.__generator||function(t,o){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},e,l,n,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(t){return function(o){return c([t,o])}}function c(s){if(e)throw new TypeError("Generator is already executing.");while(i&&(i=0,s[0]&&(r=0)),r)try{if(e=1,l&&(n=s[0]&2?l["return"]:s[0]?l["throw"]||((n=l["return"])&&n.call(l),0):l.next)&&!(n=n.call(l,s[1])).done)return n;if(l=0,n)s=[s[0]&2,n.value];switch(s[0]){case 0:case 1:n=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;l=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(n=r.trys,n=n.length>0&&n[n.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!n||s[1]>n[0]&&s[1]<n[3])){r.label=s[1];break}if(s[0]===6&&r.label<n[1]){r.label=n[1];n=s;break}if(n&&r.label<n[2]){r.label=n[2];r.ops.push(s);break}if(n[2])r.ops.pop();r.trys.pop();continue}s=o.call(t,r)}catch(t){s=[6,t];l=0}finally{e=n=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};System.register(["./p-88de70df.system.js","./p-443b9a72.system.js","./p-010faa87.system.js","./p-8c3b906c.system.js","@tarojs/taro"],(function(t){"use strict";var o,r,e,l,n,i,s,c;return{setters:[function(t){o=t.r;r=t.c;e=t.h;l=t.H;n=t.g},function(t){i=t.c},function(t){s=t.d},function(t){c=t.h},function(){}],execute:function(){var a="taro-scroll-view-core{-webkit-overflow-scrolling:auto;width:100%;display:block}taro-scroll-view-core::-webkit-scrollbar{display:none}.taro-scroll-view__scroll-x{overflow:scroll hidden}.taro-scroll-view__scroll-y{overflow:hidden scroll}";function u(t,o,r,e){if(r===void 0){r=500}if(t===o||typeof t!=="number"){return}var l=o-t;var n=Date.now();var i=o>=t;function s(t,o,r,e){return r*t/e+o}function c(){t=s(Date.now()-n,t,l,r);if(i&&t>=o||!i&&o>=t){e(o);return}e(t);requestAnimationFrame(c)}c()}var f=t("taro_scroll_view_core",function(){function t(t){var e=this;o(this,t);this.onScroll=r(this,"scroll",3);this.onScrollToUpper=r(this,"scrolltoupper",3);this.onScrollToLower=r(this,"scrolltolower",3);this._scrollLeft=0;this._scrollTop=0;this.upperAndLower=s((function(){var t=e.el,o=t.offsetWidth,r=t.offsetHeight,l=t.scrollLeft,n=t.scrollTop,i=t.scrollHeight,s=t.scrollWidth;var c=Number(e.lowerThreshold);var a=Number(e.upperThreshold);if(!isNaN(c)&&(e.scrollY&&r+n+c>=i||e.scrollX&&o+l+c>=s)){e.onScrollToLower.emit({direction:e.scrollX?"right":e.scrollY?"bottom":""})}if(!isNaN(a)&&(e.scrollY&&n<=a||e.scrollX&&l<=a)){e.onScrollToUpper.emit({direction:e.scrollX?"left":e.scrollY?"top":""})}}),200);this.scrollX=false;this.scrollY=false;this.upperThreshold=50;this.lowerThreshold=50;this.mpScrollTop=undefined;this.mpScrollLeft=undefined;this.mpScrollIntoView=undefined;this.mpScrollIntoViewAlignment=undefined;this.animated=false}t.prototype.watchScrollLeft=function(t){var o=Number(t);var r=this.animated;this.mpScrollToMethod({left:o,animated:r})};t.prototype.watchScrollTop=function(t){var o=Number(t);var r=this.animated;this.mpScrollToMethod({top:o,animated:r})};t.prototype.watchScrollIntoView=function(t){this.mpScrollIntoViewMethod(t)};t.prototype.handleScroll=function(t){var o;if(t instanceof CustomEvent)return;t.stopPropagation();(o=t.stopImmediatePropagation)===null||o===void 0?void 0:o.call(t);var r=this.el,e=r.scrollLeft,l=r.scrollTop,n=r.scrollHeight,i=r.scrollWidth;this._scrollLeft=e;this._scrollTop=l;this.upperAndLower();this.onScroll.emit({scrollLeft:e,scrollTop:l,scrollHeight:n,scrollWidth:i})};t.prototype.handleTouchMove=function(t){if(t instanceof CustomEvent)return;t.stopPropagation()};t.prototype.mpScrollToMethod=function(t){return __awaiter(this,void 0,void 0,(function(){var o,r,e,l,n;var i=this;return __generator(this,(function(s){o=t.top,r=t.left,e=t.duration,l=t.animated,n=l===void 0?false:l;if(this.scrollY&&typeof o==="number"&&!isNaN(o)&&o!==this._scrollTop){if(n){u(this._scrollTop,o,e,(function(t){return i.el.scrollTop=t}))}else{this.el.scrollTop=o}this._scrollTop=o}if(this.scrollX&&typeof r==="number"&&!isNaN(r)&&r!==this._scrollLeft){if(n){u(this._scrollLeft,r,e,(function(t){return i.el.scrollLeft=t}))}else{this.el.scrollLeft=r}this._scrollLeft=r}return[2]}))}))};t.prototype.mpScrollIntoViewMethod=function(t){return __awaiter(this,void 0,void 0,(function(){var o;return __generator(this,(function(r){if(typeof t==="string"&&t){(o=document.querySelector("#".concat(t)))===null||o===void 0?void 0:o.scrollIntoView({behavior:this.animated?"smooth":"auto",block:this.scrollY?this.mpScrollIntoViewAlignment||"center":"center",inline:this.scrollX?this.mpScrollIntoViewAlignment||"start":"start"})}return[2]}))}))};t.prototype.componentDidLoad=function(){var t=Number(this.mpScrollTop);var o=Number(this.mpScrollLeft);var r=this.animated;this.mpScrollToMethod({top:t,left:o,animated:r})};t.prototype.componentDidRender=function(){c(this.el)};t.prototype.render=function(){var t=this,o=t.scrollX,r=t.scrollY;var n=i({"taro-scroll-view__scroll-x":o,"taro-scroll-view__scroll-y":r});return e(l,{class:n},e("slot",null))};Object.defineProperty(t.prototype,"el",{get:function(){return n(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{mpScrollLeft:["watchScrollLeft"],mpScrollTop:["watchScrollTop"],mpScrollIntoView:["watchScrollIntoView"]}},enumerable:false,configurable:true});return t}());f.style=a}}}));