| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- var __wxsModules={};
- __wxsModules["30f4e25a"] = (() => {
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __commonJS = (cb, mod) => function __require() {
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
- };
- // <stdin>
- var require_stdin = __commonJS({
- "<stdin>"(exports, module) {
- var me = {};
- me.onMoving = function(ins, rate, downHight) {
- ins.requestAnimationFrame(function() {
- ins.selectComponent(".mescroll-wxs-content").setStyle({
- "will-change": "transform",
- // 可解决下拉过程中, image和swiper脱离文档流的问题
- "transform": "translateY(" + downHight + "px)",
- "transition": ""
- });
- var progress = ins.selectComponent(".mescroll-wxs-progress");
- progress && progress.setStyle({ transform: "rotate(" + 360 * rate + "deg)" });
- });
- };
- me.showLoading = function(ins) {
- me.downHight = me.optDown.offset;
- ins.requestAnimationFrame(function() {
- ins.selectComponent(".mescroll-wxs-content").setStyle({
- "will-change": "auto",
- "transform": "translateY(" + me.downHight + "px)",
- "transition": "transform 300ms"
- });
- });
- };
- me.endDownScroll = function(ins) {
- me.downHight = 0;
- me.isDownScrolling = false;
- ins.requestAnimationFrame(function() {
- ins.selectComponent(".mescroll-wxs-content").setStyle({
- "will-change": "auto",
- "transform": "translateY(0)",
- // 不可以写空串,否则scroll-view渲染不完整 (延时350ms会调clearTransform置空)
- "transition": "transform 300ms"
- });
- });
- };
- me.clearTransform = function(ins) {
- ins.requestAnimationFrame(function() {
- ins.selectComponent(".mescroll-wxs-content").setStyle({
- "will-change": "",
- "transform": "",
- "transition": ""
- });
- });
- };
- function propObserver(wxsProp) {
- if (!wxsProp)
- return;
- me.optDown = wxsProp.optDown;
- me.scrollTop = wxsProp.scrollTop;
- me.bodyHeight = wxsProp.bodyHeight;
- me.isDownScrolling = wxsProp.isDownScrolling;
- me.isUpScrolling = wxsProp.isUpScrolling;
- me.isUpBoth = wxsProp.isUpBoth;
- me.isScrollBody = wxsProp.isScrollBody;
- me.startTop = wxsProp.scrollTop;
- }
- function callObserver(callProp, oldValue, ins) {
- if (me.disabled())
- return;
- if (callProp.callType) {
- if (callProp.callType === "showLoading") {
- me.showLoading(ins);
- } else if (callProp.callType === "endDownScroll") {
- me.endDownScroll(ins);
- } else if (callProp.callType === "clearTransform") {
- me.clearTransform(ins);
- }
- }
- }
- function touchstartEvent(e, ins) {
- me.downHight = 0;
- me.startPoint = me.getPoint(e);
- me.startTop = me.getScrollTop();
- me.startAngle = 0;
- me.lastPoint = me.startPoint;
- me.maxTouchmoveY = me.getBodyHeight() - me.optDown.bottomOffset;
- me.inTouchend = false;
- me.callMethod(ins, { type: "setWxsProp" });
- }
- function touchmoveEvent(e, ins) {
- var isPrevent = true;
- if (me.disabled())
- return isPrevent;
- var scrollTop = me.getScrollTop();
- var curPoint = me.getPoint(e);
- var moveY = curPoint.y - me.startPoint.y;
- if (moveY > 0 && (me.isScrollBody && scrollTop <= 0 || !me.isScrollBody && (scrollTop <= 0 || scrollTop <= me.optDown.startTop && scrollTop === me.startTop))) {
- if (!me.inTouchend && !me.isDownScrolling && !me.optDown.isLock && (!me.isUpScrolling || me.isUpScrolling && me.isUpBoth)) {
- if (!me.startAngle)
- me.startAngle = me.getAngle(me.lastPoint, curPoint);
- if (me.startAngle < me.optDown.minAngle)
- return isPrevent;
- if (me.maxTouchmoveY > 0 && curPoint.y >= me.maxTouchmoveY) {
- me.inTouchend = true;
- touchendEvent(e, ins);
- return isPrevent;
- }
- isPrevent = false;
- var diff = curPoint.y - me.lastPoint.y;
- if (me.downHight < me.optDown.offset) {
- if (me.movetype !== 1) {
- me.movetype = 1;
- me.callMethod(ins, { type: "setLoadType", downLoadType: 1 });
- me.isMoveDown = true;
- }
- me.downHight += diff * me.optDown.inOffsetRate;
- } else {
- if (me.movetype !== 2) {
- me.movetype = 2;
- me.callMethod(ins, { type: "setLoadType", downLoadType: 2 });
- me.isMoveDown = true;
- }
- if (diff > 0) {
- me.downHight += diff * me.optDown.outOffsetRate;
- } else {
- me.downHight += diff;
- }
- }
- me.downHight = Math.round(me.downHight);
- var rate = me.downHight / me.optDown.offset;
- me.onMoving(ins, rate, me.downHight);
- }
- }
- me.lastPoint = curPoint;
- return isPrevent;
- }
- function touchendEvent(e, ins) {
- if (me.isMoveDown) {
- if (me.downHight >= me.optDown.offset) {
- me.downHight = me.optDown.offset;
- me.callMethod(ins, { type: "triggerDownScroll" });
- } else {
- me.downHight = 0;
- me.callMethod(ins, { type: "endDownScroll" });
- }
- me.movetype = 0;
- me.isMoveDown = false;
- } else if (!me.isScrollBody && me.getScrollTop() === me.startTop) {
- var isScrollUp = me.getPoint(e).y - me.startPoint.y < 0;
- if (isScrollUp) {
- var angle = me.getAngle(me.getPoint(e), me.startPoint);
- if (angle > 80) {
- me.callMethod(ins, { type: "triggerUpScroll" });
- }
- }
- }
- me.callMethod(ins, { type: "setWxsProp" });
- }
- me.disabled = function() {
- return !me.optDown || !me.optDown.use || me.optDown.native;
- };
- me.getPoint = function(e) {
- if (!e) {
- return { x: 0, y: 0 };
- }
- if (e.touches && e.touches[0]) {
- return { x: e.touches[0].pageX, y: e.touches[0].pageY };
- } else if (e.changedTouches && e.changedTouches[0]) {
- return { x: e.changedTouches[0].pageX, y: e.changedTouches[0].pageY };
- } else {
- return { x: e.clientX, y: e.clientY };
- }
- };
- me.getAngle = function(p1, p2) {
- var x = Math.abs(p1.x - p2.x);
- var y = Math.abs(p1.y - p2.y);
- var z = Math.sqrt(x * x + y * y);
- var angle = 0;
- if (z !== 0) {
- angle = Math.asin(y / z) / Math.PI * 180;
- }
- return angle;
- };
- me.getScrollTop = function() {
- return me.scrollTop || 0;
- };
- me.getBodyHeight = function() {
- return me.bodyHeight || 0;
- };
- me.callMethod = function(ins, param) {
- if (ins)
- ins.callMethod("wxsCall", param);
- };
- module.exports = {
- propObserver,
- callObserver,
- touchstartEvent,
- touchmoveEvent,
- touchendEvent
- };
- }
- });
- return require_stdin();
- })();
- __wxsModules.f1d6d7d8 = (() => {
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __commonJS = (cb, mod) => function __require() {
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
- };
- // <stdin>
- var require_stdin = __commonJS({
- "<stdin>"(exports, module) {
- function touchstart(event, ownerInstance) {
- var instance = event.instance;
- var state = instance.getState();
- if (state.disabled)
- return;
- var touches = event.touches;
- if (touches && touches.length > 1)
- return;
- state.moving = true;
- state.startX = touches[0].pageX;
- state.startY = touches[0].pageY;
- ownerInstance.callMethod("closeOther");
- }
- function touchmove(event, ownerInstance) {
- var instance = event.instance;
- var state = instance.getState();
- if (state.disabled || !state.moving)
- return;
- var touches = event.touches;
- var pageX = touches[0].pageX;
- var pageY = touches[0].pageY;
- var moveX = pageX - state.startX;
- var moveY = pageY - state.startY;
- var buttonsWidth = state.buttonsWidth;
- if (Math.abs(moveX) > Math.abs(moveY) || Math.abs(moveX) > state.threshold) {
- event.preventDefault && event.preventDefault();
- event.stopPropagation && event.stopPropagation();
- }
- if (Math.abs(moveX) < Math.abs(moveY))
- return;
- if (state.status === "open") {
- if (moveX < 0)
- moveX = 0;
- if (moveX > buttonsWidth)
- moveX = buttonsWidth;
- moveSwipeAction(-buttonsWidth + moveX, instance, ownerInstance);
- } else {
- if (moveX > 0)
- moveX = 0;
- if (Math.abs(moveX) > buttonsWidth)
- moveX = -buttonsWidth;
- moveSwipeAction(moveX, instance, ownerInstance);
- }
- }
- function touchend(event, ownerInstance) {
- var instance = event.instance;
- var state = instance.getState();
- if (!state.moving || state.disabled)
- return;
- var touches = event.changedTouches ? event.changedTouches[0] : {};
- var pageX = touches.pageX;
- var pageY = touches.pageY;
- var moveX = pageX - state.startX;
- if (state.status === "open") {
- if (moveX < 0)
- return;
- if (moveX === 0) {
- return closeSwipeAction(instance, ownerInstance);
- }
- if (Math.abs(moveX) < state.threshold) {
- openSwipeAction(instance, ownerInstance);
- } else {
- closeSwipeAction(instance, ownerInstance);
- }
- } else {
- if (moveX > 0)
- return;
- if (Math.abs(moveX) < state.threshold) {
- closeSwipeAction(instance, ownerInstance);
- } else {
- openSwipeAction(instance, ownerInstance);
- }
- }
- }
- function getDuration(value) {
- if (value.toString().indexOf("s") >= 0)
- return value;
- return value > 30 ? value + "ms" : value + "s";
- }
- function moveSwipeAction(moveX, instance, ownerInstance) {
- var state = instance.getState();
- var buttons = ownerInstance.selectAllComponents(".u-swipe-action-item__right__button");
- instance.requestAnimationFrame(function() {
- instance.setStyle({
- // 设置translateX的值
- "transition": "none",
- transform: "translateX(" + moveX + "px)",
- "-webkit-transform": "translateX(" + moveX + "px)"
- });
- });
- }
- function openSwipeAction(instance, ownerInstance) {
- var state = instance.getState();
- var buttons = ownerInstance.selectAllComponents(".u-swipe-action-item__right__button");
- var duration = getDuration(state.duration);
- var buttonsWidth = -state.buttonsWidth;
- instance.requestAnimationFrame(function() {
- instance.setStyle({
- "transition": "transform " + duration,
- "transform": "translateX(" + buttonsWidth + "px)",
- "-webkit-transform": "translateX(" + buttonsWidth + "px)"
- });
- });
- setStatus("open", instance, ownerInstance);
- }
- function setStatus(status, instance, ownerInstance) {
- var state = instance.getState();
- state.status = status;
- ownerInstance.callMethod("setState", status);
- }
- function closeSwipeAction(instance, ownerInstance) {
- var state = instance.getState();
- var buttons = ownerInstance.selectAllComponents(".u-swipe-action-item__right__button");
- var len = buttons.length;
- var duration = getDuration(state.duration);
- instance.requestAnimationFrame(function() {
- instance.setStyle({
- "transition": "transform " + duration,
- "transform": "translateX(0px)",
- "-webkit-transform": "translateX(0px)"
- });
- for (var i = len - 1; i >= 0; i--) {
- buttons[i].setStyle({
- "transition": "transform " + duration,
- "transform": "translateX(0px)",
- "-webkit-transform": "translateX(0px)"
- });
- }
- });
- setStatus("close", instance, ownerInstance);
- }
- function statusChange(newValue, oldValue, ownerInstance, instance) {
- var state = instance.getState();
- if (state.disabled)
- return;
- if (newValue === "close" && state.status === "open") {
- closeSwipeAction(instance, ownerInstance);
- } else if (newValue === "open" && state.status === "close") {
- openSwipeAction(instance, ownerInstance);
- }
- }
- function sizeChange(newValue, oldValue, ownerInstance, instance) {
- var state = instance.getState();
- state.disabled = newValue.disabled;
- state.duration = newValue.duration;
- state.show = newValue.show;
- state.threshold = newValue.threshold;
- state.buttons = newValue.buttons;
- if (state.buttons) {
- var len = state.buttons.length;
- var buttonsWidth = 0;
- var buttons = newValue.buttons;
- for (var i = 0; i < len; i++) {
- buttonsWidth += buttons[i].width;
- }
- }
- state.buttonsWidth = buttonsWidth;
- }
- module.exports = {
- touchstart,
- touchmove,
- touchend,
- sizeChange,
- statusChange
- };
- }
- });
- return require_stdin();
- })();
|