@smt-ui/component
Advanced tools
Comparing version 0.0.36-alpha.0 to 0.0.37-alpha.0
{ | ||
"editor": { | ||
"curPath": "/Volumes/code/work/swan-ui/packages/component/src/icon/src/index.swan", | ||
"curPath": "/Volumes/code/work/swan-ui/packages/component/package-lock.json", | ||
"expands": [ | ||
@@ -11,5 +11,7 @@ "/Volumes/code/work/swan-ui/packages/component/src", | ||
"paths": [ | ||
"/Volumes/code/work/swan-ui/packages/component/src/icon/src/index.swan" | ||
"/Volumes/code/work/swan-ui/packages/component/src/icon/src/index.swan", | ||
"/Volumes/code/work/swan-ui/packages/component/package-lock.json" | ||
], | ||
"recentlyFiles": [ | ||
"/Volumes/code/work/swan-ui/packages/component/package-lock.json", | ||
"/Volumes/code/work/swan-ui/packages/component/src/icon/src/index.swan", | ||
@@ -16,0 +18,0 @@ "/Volumes/code/work/swan-ui/packages/component/src/icon/src/index.json", |
{ | ||
"name": "@smt-ui/component", | ||
"version": "0.0.36-alpha.0", | ||
"version": "0.0.37-alpha.0", | ||
"description": "extension base", | ||
@@ -12,2 +12,5 @@ "author": "jialipeng <jialipeng@baidu.com>", | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"scripts": { | ||
@@ -26,2 +29,3 @@ "build": "sh ./build.sh", | ||
"@babel/register": "^7.0.0", | ||
"@baidu/smartium": "^1.0.101", | ||
"assert": "^2.0.0", | ||
@@ -38,3 +42,3 @@ "babel-plugin-module-resolver": "^3.1.3", | ||
}, | ||
"gitHead": "60718dbb07f7838620782e957def6b07ee41df08" | ||
"gitHead": "db2e32b93ef39ac1aace71cf67724d62b7823688" | ||
} |
@@ -1,1 +0,1 @@ | ||
{"npmPackageName":"@smt-ui/component","npmPackageVersion":"0.0.32-alpha.0","componentsList":[{"name":"layout","label":"布局组件","icon":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NiA2NiI+PHBhdGggZD0iTTIzLjkgMjUuOGMtMS40IDAtMi41IDEuMS0yLjUgMi41VjM5YzAgMS40IDEuMSAyLjUgMi41IDIuNXMyLjUtMS4xIDIuNS0yLjVWMjguM2MwLTEuNC0xLjEtMi41LTIuNS0yLjV6TTQ1LjkgMjYuOWMtMS0xLTIuNS0xLTMuNSAwTDM4IDMxLjNjLS42LjYtLjkgMS40LS44IDIuMi0uMS44LjIgMS42LjggMi4xbDQuNCA0LjRjLjUuNSAxLjEuNyAxLjguN3MxLjMtLjMgMS44LS43LjctMS4xLjctMS44LS4zLTEuMy0uNy0xLjhsLTMtMyAzLTNjLjktLjkuOS0yLjUtLjEtMy41eiIvPjxwYXRoIGQ9Ik01MC44IDE0LjdjLTMuNy0xLjgtMTAuNC0zLjEtMTcuNi0zLjItNy4yLjEtMTQgMS4zLTE3LjcgMy4yLTUuNyAyLjctOCA4LjMtOCAxOS4yIDAgOC43IDIuNCAxNSA2LjUgMTcuMiA1LjMgMi43IDEwLjEgMy42IDE5LjEgMy42IDkuMSAwIDEzLjktLjkgMTktMy41IDQuMi0yLjMgNi42LTguNyA2LjYtMTcuMyAwLTEwLjgtMi40LTE2LjUtNy45LTE5LjJ6bTIuOSAxOS4xYzAgNy40LTIgMTEuOC0zLjkgMTIuOS0zLjggMS45LTcuNiAyLjktMTYuNyAyLjktOSAwLTEyLjktMS0xNi44LTIuOS0xLjktMS0zLjgtNS41LTMuOC0xMi45IDAtOC43IDEuNS0xMi45IDUuMS0xNC44IDMtMS41IDkuMi0yLjYgMTUuNS0yLjYgNi4zLjEgMTIuNSAxLjIgMTUuNSAyLjYgMy42IDEuOSA1LjEgNi4xIDUuMSAxNC44eiIvPjwvc3ZnPg==","components":[{"name":"smt-feed-item","label":"信息流子项","description":"信息流子项,包括左文右图、纯文本、上文下图、多图及视频模式。","codeSnap":"<smt-feed-item theme='default' content='{{ {title: '宠物自己在家时, 如何帮助它度过孤独时光', infoSource: '萌宠在家', commentsNum: 2} }}' status='0'></smt-feed-item>","groups":"layout","fragement":"swanide://fragment/afebdafc13cda2201207a3d6721577481577175550244","properties":{"attributes":[{"name":"theme","type":"string","description":"信息流子项的主题:default是左文右图模式,如不配置content中的images则是纯文本子项;large-image是大图模式;multiple-images是多图模式","required":"否","default":"default"},{"name":"content","type":"Object","description":"信息流子项目的内容,包含标题(title),消息来源(infoSource),评论数(commentsNum),图片路径(images)","required":"否","default":"{title: '这个是子项的标题',infoSource: '百度新闻',commentsNum: 2,images: []}"},{"name":"video","type":"Object","description":"是否为视频和视频信息,配置isVideo为true,则显示视频形式(注:在多图模式不生效)","required":"否","default":"{isVideo: true, time: '05:00'}"},{"name":"status","type":"String","description":"阅读状态:0未读,1已读","required":"否","default":"0"}],"events":[{"name":"bindfeeditemtap","type":"Event","description":"点击feed-item之后的回调","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed-item","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed-item.png","usingComponents":{"smt-feed-item":"@smt-ui/component/src/feed-item"}},{"name":"smt-feed","label":"信息流","description":"信息流组件,可配置下拉刷新、列表加载、上滑加载功能,适用于列表信息展示,并可放置在页面的任何部分;组件包含手势下拉以及api调用两种使用方式\n* 注意:\n1. 和scroll-view一样,信息流组件作为局部滚动组件,必须在它的父级或本身指定高度\n2. 当同时启用下拉刷新和上滑加载且请求不稳定时,可使用CancelToken取消先前的请求","codeSnap":"<smt-feed pull-to-refresh><view>list</view></smt-feed>","groups":"layout","fragement":"swanide://fragment/7b9bf19d0c974d45d9b68fd9fc4429b31577200628346","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHeight","type":"Number","description":"加载、话术区域高度,单位为设备px,转换方法: import {upx2dpx} from '@smt-ui/component/src/common/utils/px';","required":"否","default":"192px(设计稿宽度为1242)"},{"name":"pullToRefresh","type":"Boolean","description":"是否开启手势下拉刷新; 默认只能通过组件api调起","required":"否","default":"false"},{"name":"lowerThreshold","type":"Number","description":"触发scrolltolower事件的阈值","required":"否","default":"150px(设备上的px)"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"},{"name":"refresh","type":"EventHandle","description":"手势滑动触发加载时,响应该onRefresh事件; 通过调用api加载,不会触发该事件","required":"否","default":""},{"name":"startRefresh","type":"EventHandle","description":"手动调用该api,触发加载","required":"否","default":""},{"name":"stopRefresh","type":"EventHandle","description":"手动调用该api,停止加载,并弹出加载提示(对应属性text);可使用await等待关闭动画结束","required":"否","default":""},{"name":"closeLoading","type":"EventHandle","description":"手动调用该api,立即关闭加载,不弹出加载提示;例如接口异常,建义直接关闭加载(小球交替一次大约为500ms,调用前可加延时避免关闭太快)","required":"否","default":""},{"name":"smt-feed-container","type":"externalClass","description":"组件整体class名","required":"否","default":"-"},{"name":"smt-feed-loading","type":"externalClass","description":"加载区域class名","required":"否","default":"-"},{"name":"smt-feed-content","type":"externalClass","description":"滚动区域class名,用于设置ios回弹背景","required":"false","default":""},{"name":"smt-refresh-circle-left","type":"externalClass","description":"加载中左侧小球class名","required":"否","default":"-"},{"name":"smt-refresh-circle-right","type":"externalClass","description":"加载中右侧小球class名","required":"否","default":"-"},{"name":"ext-cls-content","type":"externalClass","description":"滚动区域class名","required":"否","default":"-"},{"name":"smt-refresh-result-container","type":"externalClass","description":"加载话术外框class名","required":"否","default":"-"},{"name":"ext-cls-result-text","type":"externalClass","description":"加载话术文字class名","required":"否","default":"-"}],"events":[{"name":"bindscroll","type":"Event","description":"滚动时触发,返回当前组件的值","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed.png","usingComponents":{"smt-feed":"@smt-ui/component/src/feed"}},{"name":"smt-icon","label":"图标","description":"包括天气、系统设置、互动社交、生活服务、书籍影音、政务服务、交通出行7个行业类别的图标。请扫描示例二维码查看图标全集。","codeSnap":"<smt-icon name='add'></smt-icon>","groups":"layout","fragement":"swanide://fragment/1151cb408d98313c4e79bb6a62755bfa1577193673206","properties":{"attributes":[{"name":"name","type":"String","description":"icon的英文名称","required":"是"},{"name":"color","type":"String, Array.<String>","description":"icon的颜色,多色图标支持传入色值的数组"},{"name":"size","type":"Number","description":"icon的尺寸,单位px","default":25}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-icon","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-icon.png","usingComponents":{"smt-icon":"@smt-ui/component/src/icon"}},{"name":"navigation","label":"顶部导航bar","description":"顶部导航bar可以自定义","codeSnap":"<smt-navigation></smt-navigation>","groups":"layout","properties":{"properties":[],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/navigation","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/navigation.png","usingComponents":{"navigation":"@smt-ui/component/src/navigation"}},{"name":"smt-page-status","label":"页面状态组件","description":"页面状态组件,可用于全屏和半屏。用于展示页面加载,页面异常-有操作、页面异常-无操作三种页面状态。","codeSnap":"<smt-page-status></smt-page-status>","groups":"layout","fragment":"swanide://fragment/4cc92982287ac8a30b5fe19f220dc8f71577190736077","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;沉浸式主题请指定dark","required":"否","default":""},{"name":"loading","type":"Boolean","description":"页面状态配置,默认不展示加载状态页面","required":"否","default":"false"},{"name":"icon","type":"String","description":"空态/缺省页面下的图标名称","required":"否","default":"content"},{"name":"loadingTitle","type":"String","description":"加载页面下的标题文案","required":"否","default":"正在加载..."},{"name":"title","type":"String","description":"空态/缺省页面下的标题文案","required":"否","default":"单行标题"},{"name":"desc","type":"String","description":"空态/缺省页面下的描述文案","required":"否","default":""},{"name":"showBtn","type":"Boolean","description":"是否展示空态/缺省页面下的操作按钮,默认展示","required":"否","default":"true"},{"name":"btnText","type":"String","description":"空态/缺省页面下,操作按钮的描述文案,建议最多显示4个汉字,超出内容截断","required":"否","default":"重新加载"}],"events":[{"name":"reloading","type":"Event","description":"空态/缺省页面下,点击操作按钮时触发","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-page-status","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-page-status.png","usingComponents":{"smt-page-status":"@smt-ui/component/src/page-status"}},{"name":"publish","label":"发布器","description":"发布器组件可以用于用户直接发布文章使用,可以包含文字与图片,在支持发布器的客户端上,会直接调用API来展示发布器,在不支持发布器的客户端上,则会展示降级版的发布器","codeSnap":"<smt-publish></smt-publish>","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"false","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"false","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"false","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"false","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"false","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/publish","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/publish.png","usingComponents":{"publish":"@smt-ui/component/src/publish"}},{"name":"smt-refresh","label":"刷新","description":"可用于页面任意区域;使用时需自行添加下拉逻辑改变offset-y参数;smt-feed组件对smt-refresh进行了封装,支持手势交互和api调起刷新。","codeSnap":"<smt-refresh offset-y=\"{{0}}\" status=\"{{1}}\" text=\"为你推荐15条更新\"></smt-refresh>","fragement":"swanide://fragment/598510a21b650b89e2e5d13c814dc46c1577192328823","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"否","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"否","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"否","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-refresh","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-refresh.png","usingComponents":{"smt-refresh":"@smt-ui/component/src/refresh"}},{"name":"smt-spin","label":"加载","description":"加载组件,可用于全屏和半屏。用于展示加载状态,点击加载、正在加载、加载完成、重新加载四种状态。","codeSnap":"<spin status='1'></spin>","groups":"layout","fragement":"swanide://fragment/25af44248f8aad73b64e274ead38d6151577191316430","properties":{"attributes":[{"name":"status","type":"Number","description":"加载状态配置","required":"是"},{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":""},{"name":"textConfig","type":"Array","description":"加载状态对应的文案","required":"否","default":"['点击加载更多', '正在加载...', '已经到底啦', '加载失败 点击重新加载']"},{"name":"secureBottom","type":"Boolean","description":"默认兼容iPhoneX 及以上型号底部安全区,非全屏可关闭","required":"否","default":"true"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-spin","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-spin.png","usingComponents":{"smt-spin":"@smt-ui/component/src/spin"}}]}]} | ||
{"npmPackageName":"@smt-ui/component","npmPackageVersion":"0.0.36-alpha.0","componentsList":[{"name":"layout","label":"布局组件","icon":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NiA2NiI+PHBhdGggZD0iTTIzLjkgMjUuOGMtMS40IDAtMi41IDEuMS0yLjUgMi41VjM5YzAgMS40IDEuMSAyLjUgMi41IDIuNXMyLjUtMS4xIDIuNS0yLjVWMjguM2MwLTEuNC0xLjEtMi41LTIuNS0yLjV6TTQ1LjkgMjYuOWMtMS0xLTIuNS0xLTMuNSAwTDM4IDMxLjNjLS42LjYtLjkgMS40LS44IDIuMi0uMS44LjIgMS42LjggMi4xbDQuNCA0LjRjLjUuNSAxLjEuNyAxLjguN3MxLjMtLjMgMS44LS43LjctMS4xLjctMS44LS4zLTEuMy0uNy0xLjhsLTMtMyAzLTNjLjktLjkuOS0yLjUtLjEtMy41eiIvPjxwYXRoIGQ9Ik01MC44IDE0LjdjLTMuNy0xLjgtMTAuNC0zLjEtMTcuNi0zLjItNy4yLjEtMTQgMS4zLTE3LjcgMy4yLTUuNyAyLjctOCA4LjMtOCAxOS4yIDAgOC43IDIuNCAxNSA2LjUgMTcuMiA1LjMgMi43IDEwLjEgMy42IDE5LjEgMy42IDkuMSAwIDEzLjktLjkgMTktMy41IDQuMi0yLjMgNi42LTguNyA2LjYtMTcuMyAwLTEwLjgtMi40LTE2LjUtNy45LTE5LjJ6bTIuOSAxOS4xYzAgNy40LTIgMTEuOC0zLjkgMTIuOS0zLjggMS45LTcuNiAyLjktMTYuNyAyLjktOSAwLTEyLjktMS0xNi44LTIuOS0xLjktMS0zLjgtNS41LTMuOC0xMi45IDAtOC43IDEuNS0xMi45IDUuMS0xNC44IDMtMS41IDkuMi0yLjYgMTUuNS0yLjYgNi4zLjEgMTIuNSAxLjIgMTUuNSAyLjYgMy42IDEuOSA1LjEgNi4xIDUuMSAxNC44eiIvPjwvc3ZnPg==","components":[{"name":"smt-feed-item","label":"信息流子项","description":"信息流子项:包括左文右图、纯文本、上文下图、多图及视频模式。","codeSnap":"<smt-feed-item theme='default' content='title: '宠物自己在家时, 如何帮助它度过孤独时光',infoSource: '萌宠在家',commentsNum: 2' status='0'></smt-feed-item>","groups":"layout","fragement":"swanide://fragment/afebdafc13cda2201207a3d6721577481577175550244","properties":{"attributes":[{"name":"theme","type":"string","description":"信息流子项的主题","required":"是","default":"default"},{"name":"content","type":"Object","description":"信息流子项目的内容","required":"是","default":"{title: '标题',infoSource: '网易新闻',commentsNum: 2,images: []}"},{"name":"video","type":"Object","description":"是否为视频和视频信息","required":"否","default":"{isVideo: true, time: '05:00'}"},{"name":"status","type":"String","description":"阅读状态:0未读,1已读","required":"否","default":"0"}],"events":[{"name":"bindfeeditemtap","type":"Event","description":"点击feed-item之后的回调","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed-item","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed-item.png","usingComponents":{"smt-feed-item":"@smt-ui/component/src/feed-item"}},{"name":"smt-feed","label":"信息流","description":"信息流组件,可配置下拉刷新、列表加载、上滑加载功能,适用于列表信息展示,并可放置在页面的任何部分;组件包含手势下拉以及api调用两种使用方式\n* 注意:\n1. 和scroll-view一样,信息流组件作为局部滚动组件,必须在它的父级或本身指定高度\n2. 当同时启用下拉刷新和上滑加载且请求不稳定时,可使用CancelToken取消先前的请求","codeSnap":"<smt-feed pull-to-refresh><view>list</view></smt-feed>","groups":"layout","fragement":"swanide://fragment/7b9bf19d0c974d45d9b68fd9fc4429b31577200628346","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHeight","type":"Number","description":"加载、话术区域高度,单位为设备px,转换方法: import {upx2dpx} from '@smt-ui/component/src/common/utils/px';","required":"否","default":"192px(设计稿宽度为1242)"},{"name":"pullToRefresh","type":"Boolean","description":"是否开启手势下拉刷新; 默认只能通过组件api调起","required":"否","default":"false"},{"name":"lowerThreshold","type":"Number","description":"触发scrolltolower事件的阈值","required":"否","default":"150px(设备上的px)"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"},{"name":"refresh","type":"EventHandle","description":"手势滑动触发加载时,响应该onRefresh事件; 通过调用api加载,不会触发该事件","required":"否","default":""},{"name":"startRefresh","type":"EventHandle","description":"手动调用该api,触发加载","required":"否","default":""},{"name":"stopRefresh","type":"EventHandle","description":"手动调用该api,停止加载,并弹出加载提示(对应属性text);可使用await等待关闭动画结束","required":"否","default":""},{"name":"closeLoading","type":"EventHandle","description":"手动调用该api,立即关闭加载,不弹出加载提示;例如接口异常,建义直接关闭加载(小球交替一次大约为500ms,调用前可加延时避免关闭太快)","required":"否","default":""},{"name":"smt-feed-container","type":"externalClass","description":"组件整体class名","required":"否","default":"-"},{"name":"smt-feed-loading","type":"externalClass","description":"加载区域class名","required":"否","default":"-"},{"name":"smt-feed-content","type":"externalClass","description":"滚动区域class名,用于设置ios回弹背景","required":"false","default":""},{"name":"smt-refresh-circle-left","type":"externalClass","description":"加载中左侧小球class名","required":"否","default":"-"},{"name":"smt-refresh-circle-right","type":"externalClass","description":"加载中右侧小球class名","required":"否","default":"-"},{"name":"ext-cls-content","type":"externalClass","description":"滚动区域class名","required":"否","default":"-"},{"name":"smt-refresh-result-container","type":"externalClass","description":"加载话术外框class名","required":"否","default":"-"},{"name":"ext-cls-result-text","type":"externalClass","description":"加载话术文字class名","required":"否","default":"-"}],"events":[{"name":"bindscroll","type":"Event","description":"滚动时触发,返回当前组件的值","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed.png","usingComponents":{"smt-feed":"@smt-ui/component/src/feed"}},{"name":"smt-icon","label":"图标","description":"包括天气、系统设置、互动社交、生活服务、书籍影音、政务服务、交通出行7个行业类别的图标。请扫描示例二维码查看图标全集。","codeSnap":"<smt-icon name='add'></smt-icon>","groups":"layout","fragement":"swanide://fragment/1151cb408d98313c4e79bb6a62755bfa1577193673206","properties":{"attributes":[{"name":"name","type":"String","description":"icon的英文名称","required":"是"},{"name":"color","type":"String, Array.<String>","description":"icon的颜色,多色图标支持传入色值的数组"},{"name":"size","type":"Number","description":"icon的尺寸,单位px","default":25}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-icon","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-icon.png","usingComponents":{"smt-icon":"@smt-ui/component/src/icon"}},{"name":"navigation","label":"顶部导航bar","description":"顶部导航bar可以自定义","codeSnap":"<smt-navigation></smt-navigation>","groups":"layout","properties":{"properties":[],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/navigation","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/navigation.png","usingComponents":{"navigation":"@smt-ui/component/src/navigation"}},{"name":"smt-page-status","label":"页面状态组件","description":"页面状态组件,可用于全屏和半屏。用于展示页面加载,页面异常-有操作、页面异常-无操作三种页面状态。","codeSnap":"<smt-page-status></smt-page-status>","groups":"layout","fragment":"swanide://fragment/4cc92982287ac8a30b5fe19f220dc8f71577190736077","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;沉浸式主题请指定dark","required":"否","default":""},{"name":"loading","type":"Boolean","description":"页面状态配置,默认不展示加载状态页面","required":"否","default":"false"},{"name":"icon","type":"String","description":"空态/缺省页面下的图标名称","required":"否","default":"content"},{"name":"loadingTitle","type":"String","description":"加载页面下的标题文案","required":"否","default":"正在加载..."},{"name":"title","type":"String","description":"空态/缺省页面下的标题文案","required":"否","default":"单行标题"},{"name":"desc","type":"String","description":"空态/缺省页面下的描述文案","required":"否","default":""},{"name":"showBtn","type":"Boolean","description":"是否展示空态/缺省页面下的操作按钮,默认展示","required":"否","default":"true"},{"name":"btnText","type":"String","description":"空态/缺省页面下,操作按钮的描述文案,建议最多显示4个汉字,超出内容截断","required":"否","default":"重新加载"}],"events":[{"name":"reloading","type":"Event","description":"空态/缺省页面下,点击操作按钮时触发","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-page-status","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-page-status.png","usingComponents":{"smt-page-status":"@smt-ui/component/src/page-status"}},{"name":"publish","label":"发布器","description":"发布器组件可以用于用户直接发布文章使用,可以包含文字与图片,在支持发布器的客户端上,会直接调用API来展示发布器,在不支持发布器的客户端上,则会展示降级版的发布器","codeSnap":"<smt-publish></smt-publish>","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"false","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"false","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"false","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"false","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"false","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/publish","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/publish.png","usingComponents":{"publish":"@smt-ui/component/src/publish"}},{"name":"smt-refresh","label":"刷新","description":"可用于页面任意区域;使用时需自行添加下拉逻辑改变offset-y参数;smt-feed组件对smt-refresh进行了封装,支持手势交互和api调起刷新。","codeSnap":"<smt-refresh offset-y=\"{{0}}\" status=\"{{1}}\" text=\"为你推荐15条更新\"></smt-refresh>","fragement":"swanide://fragment/598510a21b650b89e2e5d13c814dc46c1577192328823","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"否","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"否","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"否","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-refresh","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-refresh.png","usingComponents":{"smt-refresh":"@smt-ui/component/src/refresh"}},{"name":"smt-spin","label":"加载","description":"加载组件,可用于全屏和半屏。用于展示加载状态,点击加载、正在加载、加载完成、重新加载四种状态。","codeSnap":"<spin status='1'></spin>","groups":"layout","fragement":"swanide://fragment/25af44248f8aad73b64e274ead38d6151577191316430","properties":{"attributes":[{"name":"status","type":"Number","description":"加载状态配置","required":"是"},{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":""},{"name":"textConfig","type":"Array","description":"加载状态对应的文案","required":"否","default":"['点击加载更多', '正在加载...', '已经到底啦', '加载失败 点击重新加载']"},{"name":"secureBottom","type":"Boolean","description":"默认兼容iPhoneX 及以上型号底部安全区,非全屏可关闭","required":"否","default":"true"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-spin","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-spin.png","usingComponents":{"smt-spin":"@smt-ui/component/src/spin"}}]}]} |
{ | ||
"name": "smt-feed-item", | ||
"label": "信息流子项", | ||
"description": "信息流子项,包括左文右图、纯文本、上文下图、多图及视频模式。", | ||
"codeSnap": "<smt-feed-item theme='default' content='{{ {title: '宠物自己在家时, 如何帮助它度过孤独时光', infoSource: '萌宠在家', commentsNum: 2} }}' status='0'></smt-feed-item>", | ||
"description": "信息流子项:包括左文右图、纯文本、上文下图、多图及视频模式。", | ||
"codeSnap": "<smt-feed-item theme='default' content='title: '宠物自己在家时, 如何帮助它度过孤独时光',infoSource: '萌宠在家',commentsNum: 2' status='0'></smt-feed-item>", | ||
"groups": "layout", | ||
"fragement": "swanide://fragment/afebdafc13cda2201207a3d6721577481577175550244", | ||
"demoCode": { | ||
"s": "<smt-feed-item \n theme=\"{{theme}}\"\n content=\"{{content}}\" \n video=\"{{video}}\"\n status=\"{{status}}\"\n>\n</smt-feed-item>", | ||
"js": "Page({ \n\n data: {\n theme: 'default',\n content: {\n title: '这个是子项的标题',\n infoSource: '百度新闻',\n commentsNum: 2,\n images: []\n },\n video: {\n isVideo: true,\n time: '02:00'\n },\n status: '0'\n }\n});\n", | ||
"css": "" | ||
"s": "<view>\r\n\t<smt-feed-item theme='default' content='{{feedItem}}' video='{{video}}' status='0' smt-feed-item-wrapper='custom-feed-item' bindfeeditemtap='handleTap'>\r\n\t</smt-feed-item>\r\n</view>", | ||
"js": "Page({\r\n\tdata: {\r\n\t\tfeedItem: {\r\n\t\t\ttitle: '宠物自己在家时, 如何帮助它度过孤独时光',\r\n\t\t\tinfoSource: '萌宠在家',\r\n\t\t\tcommentsNum: 11\r\n\t\t},\r\n\t\tvideo: {\r\n\t\t\tisVideo: true,\r\n\t\t\ttime: '05:00'\r\n\t\t}\r\n\t}\r\n});", | ||
"css": ".custom-feed-item {color: #f00}" | ||
}, | ||
@@ -17,4 +17,4 @@ "properties": { | ||
"type": "string", | ||
"description": "信息流子项的主题:default是左文右图模式,如不配置content中的images则是纯文本子项;large-image是大图模式;multiple-images是多图模式", | ||
"required": "否", | ||
"description": "信息流子项的主题", | ||
"required": "是", | ||
"default": "default" | ||
@@ -25,5 +25,5 @@ }, | ||
"type": "Object", | ||
"description": "信息流子项目的内容,包含标题(title),消息来源(infoSource),评论数(commentsNum),图片路径(images)", | ||
"required": "否", | ||
"default": "{title: '这个是子项的标题',infoSource: '百度新闻',commentsNum: 2,images: []}" | ||
"description": "信息流子项目的内容", | ||
"required": "是", | ||
"default": "{title: '标题',infoSource: '网易新闻',commentsNum: 2,images: []}" | ||
}, | ||
@@ -33,3 +33,3 @@ { | ||
"type": "Object", | ||
"description": "是否为视频和视频信息,配置isVideo为true,则显示视频形式(注:在多图模式不生效)", | ||
"description": "是否为视频和视频信息", | ||
"required": "否", | ||
@@ -36,0 +36,0 @@ "default": "{isVideo: true, time: '05:00'}" |
@@ -5,3 +5,3 @@ #### 组件名称 | ||
#### 解释: | ||
信息流子项,包括左文右图、纯文本、上文下图、多图及视频模式。 | ||
信息流子项:包括左文右图、纯文本、上文下图、多图及视频模式。 | ||
@@ -11,5 +11,5 @@ #### 属性说明: | ||
|---|---|---|---|---| | ||
|theme |string |否|default|信息流子项的主题:default是左文右图模式,如不配置content中的images则是纯文本子项;large-image是大图模式;multiple-images是多图模式| | ||
|content |Object |否|{title: '这个是子项的标题',infoSource: '百度新闻',commentsNum: 2,images: []}|信息流子项目的内容,包含标题(title),消息来源(infoSource),评论数(commentsNum),图片路径(images)| | ||
|video |Object |否|{isVideo: true, time: '05:00'}|是否为视频和视频信息,配置isVideo为true,则显示视频形式(注:在多图模式不生效)| | ||
|theme |string |是|default|信息流子项的主题| | ||
|content |Object |是|{title: '标题',infoSource: '网易新闻',commentsNum: 2,images: []}|信息流子项目的内容| | ||
|video |Object |否|{isVideo: true, time: '05:00'}|是否为视频和视频信息| | ||
|status |String |否|0|阅读状态:0未读,1已读| | ||
@@ -20,34 +20,26 @@ | ||
``` | ||
<smt-feed-item | ||
theme="{{theme}}" | ||
content="{{content}}" | ||
video="{{video}}" | ||
status="{{status}}" | ||
> | ||
</smt-feed-item> | ||
<view> | ||
<smt-feed-item theme='default' content='{{feedItem}}' video='{{video}}' status='0' smt-feed-item-wrapper='custom-feed-item' bindfeeditemtap='handleTap'> | ||
</smt-feed-item> | ||
</view> | ||
``` | ||
js: | ||
``` | ||
Page({ | ||
data: { | ||
theme: 'default', | ||
content: { | ||
title: '这个是子项的标题', | ||
infoSource: '百度新闻', | ||
commentsNum: 2, | ||
images: [] | ||
}, | ||
video: { | ||
isVideo: true, | ||
time: '02:00' | ||
}, | ||
status: '0' | ||
} | ||
Page({ | ||
data: { | ||
feedItem: { | ||
title: '宠物自己在家时, 如何帮助它度过孤独时光', | ||
infoSource: '萌宠在家', | ||
commentsNum: 11 | ||
}, | ||
video: { | ||
isVideo: true, | ||
time: '05:00' | ||
} | ||
} | ||
}); | ||
``` | ||
css: | ||
``` | ||
.custom-feed-item {color: #f00} | ||
``` |
@@ -65,2 +65,3 @@ "use strict"; | ||
data: { | ||
// 左右小球信息 | ||
circle: { | ||
@@ -78,5 +79,8 @@ // 小球尺寸 * device px防止变形 | ||
}, | ||
// 是否禁用scrollView | ||
enableScroll: true, | ||
// 滑动距离 | ||
offsetY: 0, | ||
lower: false, | ||
// 滑动区域高度,用于计算阻尼值 | ||
clientHeight: 0, | ||
// 最长18个汉字 | ||
@@ -99,2 +103,7 @@ clipedText: '', | ||
}, | ||
/** | ||
* scrollView 滚动参数 | ||
* @param {Object} param Event | ||
*/ | ||
scrollHdl: function scrollHdl(_ref) { | ||
@@ -118,2 +127,19 @@ var _this = this; | ||
}, | ||
/** | ||
* 阻尼值转换 * 四参方程有常数,便于转换屏幕比 | ||
* x: 0, 50, 100, 150, 200, 250, 300, 350, 400, 800, 40000, 120000 | ||
* y: 0,32,62,90,115,136,153,164,170,270, 420, 440 | ||
* | ||
* @param {number} pullDistance 下拉的总距离 | ||
* @param {number=} base 基础值,calc(iphone 8p - 40px) | ||
* @return {number} 返回值 | ||
*/ | ||
dumping: function dumping(offsetY) { | ||
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 464; | ||
var y = offsetY > 0 ? offsetY : 0; | ||
var ratio = this.data.clientHeight / base; | ||
var result = (440.5 + .5) * ratio / (1 + Math.pow(y / 551.5665, -1.009)) - .5; | ||
return Math.round(result); | ||
}, | ||
touchHdl: function () { | ||
@@ -125,3 +151,3 @@ var _touchHdl = (0, _asyncToGenerator2["default"])( | ||
var type, _ref2$changedTouches, changedTouches, _ref2$manual, manual, ids, last, y, disabled, identifier, distance, pullDown, offsetY, circleInfo, setOffsetY, shouldLoad, result; | ||
var type, _ref2$touches, touches, _ref2$changedTouches, changedTouches, _ref2$manual, manual, disabled, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, touch, id, pageY, distance, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _touch, _id, _pageY, offsetY, pullDown, circleInfo, setOffsetY, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _touch2, _id2, _pageY2, shouldLoad, result; | ||
@@ -132,3 +158,3 @@ return _regenerator["default"].wrap(function _callee$(_context) { | ||
case 0: | ||
type = _ref2.type, _ref2$changedTouches = _ref2.changedTouches, changedTouches = _ref2$changedTouches === void 0 ? [] : _ref2$changedTouches, _ref2$manual = _ref2.manual, manual = _ref2$manual === void 0 ? false : _ref2$manual; | ||
type = _ref2.type, _ref2$touches = _ref2.touches, touches = _ref2$touches === void 0 ? [] : _ref2$touches, _ref2$changedTouches = _ref2.changedTouches, changedTouches = _ref2$changedTouches === void 0 ? [] : _ref2$changedTouches, _ref2$manual = _ref2.manual, manual = _ref2$manual === void 0 ? false : _ref2$manual; | ||
@@ -143,33 +169,27 @@ if (!(this.closing || this.data.disableTouch && !manual)) { | ||
case 3: | ||
ids = changedTouches.map(function (_ref3) { | ||
var identifier = _ref3.identifier; | ||
return identifier; | ||
}); | ||
last = changedTouches.length - 1; | ||
y = changedTouches[last] && changedTouches[last].pageY; // ue规定: 如果api调用下拉刷新,则不启用手势刷新 | ||
// ue规定: 如果api调用下拉刷新,则不启用手势刷新 | ||
disabled = !this.data.pullToRefresh && !manual && this.status === STATUS.IDLE; // 禁用多点触控 | ||
_context.t0 = type; | ||
_context.next = _context.t0 === 'touchstart' ? 10 : _context.t0 === 'touchmove' ? 17 : _context.t0 === 'touchend' ? 33 : 42; | ||
_context.next = _context.t0 === 'touchstart' ? 7 : _context.t0 === 'touchmove' ? 37 : _context.t0 === 'touchend' ? 70 : 99; | ||
break; | ||
case 10: | ||
identifier = changedTouches[last].identifier; | ||
this.identifier = identifier; | ||
case 7: | ||
this.touching = true; | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context.prev = 11; | ||
_iterator = touches[Symbol.iterator](); | ||
if (ids.includes(this.identifier)) { | ||
_context.next = 14; | ||
case 13: | ||
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { | ||
_context.next = 22; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
touch = _step.value; | ||
id = touch.identifier, pageY = touch.pageY; | ||
case 14: | ||
this.startY = y + this.scrollTop; | ||
this.lastOffsetY = this.offsetY; | ||
return _context.abrupt("break", 42); | ||
case 17: | ||
if (ids.includes(this.identifier)) { | ||
if (!(this.pos[id] == null)) { | ||
_context.next = 19; | ||
@@ -179,17 +199,108 @@ break; | ||
return _context.abrupt("return"); | ||
this.pos[id] = pageY + this.scrollTop; | ||
return _context.abrupt("break", 22); | ||
case 19: | ||
distance = y - this.startY; | ||
pullDown = distance > 0; | ||
offsetY = this.offsetY = distance * .6 + this.lastOffsetY; // 没loading动画时下拉计算动画 | ||
_iteratorNormalCompletion = true; | ||
_context.next = 13; | ||
break; | ||
case 22: | ||
_context.next = 28; | ||
break; | ||
case 24: | ||
_context.prev = 24; | ||
_context.t1 = _context["catch"](11); | ||
_didIteratorError = true; | ||
_iteratorError = _context.t1; | ||
case 28: | ||
_context.prev = 28; | ||
_context.prev = 29; | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
case 31: | ||
_context.prev = 31; | ||
if (!_didIteratorError) { | ||
_context.next = 34; | ||
break; | ||
} | ||
throw _iteratorError; | ||
case 34: | ||
return _context.finish(31); | ||
case 35: | ||
return _context.finish(28); | ||
case 36: | ||
return _context.abrupt("break", 99); | ||
case 37: | ||
distance = 0; | ||
_iteratorNormalCompletion2 = true; | ||
_didIteratorError2 = false; | ||
_iteratorError2 = undefined; | ||
_context.prev = 41; | ||
for (_iterator2 = touches[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
_touch = _step2.value; | ||
_id = _touch.identifier, _pageY = _touch.pageY; | ||
if (this.pos[_id]) { | ||
distance += Math.round(_pageY - this.pos[_id]); | ||
} | ||
} | ||
_context.next = 49; | ||
break; | ||
case 45: | ||
_context.prev = 45; | ||
_context.t2 = _context["catch"](41); | ||
_didIteratorError2 = true; | ||
_iteratorError2 = _context.t2; | ||
case 49: | ||
_context.prev = 49; | ||
_context.prev = 50; | ||
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { | ||
_iterator2["return"](); | ||
} | ||
case 52: | ||
_context.prev = 52; | ||
if (!_didIteratorError2) { | ||
_context.next = 55; | ||
break; | ||
} | ||
throw _iteratorError2; | ||
case 55: | ||
return _context.finish(52); | ||
case 56: | ||
return _context.finish(49); | ||
case 57: | ||
offsetY = this.offsetY = this.dumping(distance + this.lastOffsetY); | ||
pullDown = distance > 0; // 没loading动画时下拉计算动画 | ||
if (this.status === STATUS.IDLE) { | ||
circleInfo = (0, _index.calcCircle)(offsetY, this.data.loadingHeight); | ||
circleInfo && this.setData(circleInfo); | ||
} // 向上划要收起loading, 设置20px防误触 | ||
} // 还未加载时,向上划要收起loading | ||
if (!(!pullDown && Math.abs(y - this.startY) > 20)) { | ||
_context.next = 29; | ||
if (!(!pullDown && this.status !== STATUS.IDLE && Math.abs(offsetY) > 20)) { | ||
_context.next = 66; | ||
break; | ||
@@ -207,5 +318,5 @@ } | ||
case 29: | ||
case 66: | ||
if (!disabled) { | ||
_context.next = 31; | ||
_context.next = 68; | ||
break; | ||
@@ -216,4 +327,6 @@ } | ||
case 31: | ||
if (pullDown && this.scrollTop <= 0 && this.scrollTop - offsetY <= 0) { | ||
case 68: | ||
// offsetY快,setData慢,可能造成向上划没到顶。 | ||
// 要注意 初始就向下划,过滤掉 | ||
if (offsetY > 0 || this.data.offsetY > 0) { | ||
setOffsetY = function setOffsetY() { | ||
@@ -236,14 +349,63 @@ return _this2.setData({ | ||
return _context.abrupt("break", 42); | ||
return _context.abrupt("break", 99); | ||
case 33: | ||
if (!(ids.length > 0 && !ids.includes(this.identifier) || this.offsetY === 0 || disabled)) { | ||
_context.next = 35; | ||
case 70: | ||
_iteratorNormalCompletion3 = true; | ||
_didIteratorError3 = false; | ||
_iteratorError3 = undefined; | ||
_context.prev = 73; | ||
for (_iterator3 = changedTouches[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
_touch2 = _step3.value; | ||
_id2 = _touch2.identifier, _pageY2 = _touch2.pageY; | ||
if (this.pos[_id2]) { | ||
this.lastOffsetY += _pageY2 - this.pos[_id2]; | ||
} | ||
} | ||
_context.next = 81; | ||
break; | ||
case 77: | ||
_context.prev = 77; | ||
_context.t3 = _context["catch"](73); | ||
_didIteratorError3 = true; | ||
_iteratorError3 = _context.t3; | ||
case 81: | ||
_context.prev = 81; | ||
_context.prev = 82; | ||
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) { | ||
_iterator3["return"](); | ||
} | ||
case 84: | ||
_context.prev = 84; | ||
if (!_didIteratorError3) { | ||
_context.next = 87; | ||
break; | ||
} | ||
throw _iteratorError3; | ||
case 87: | ||
return _context.finish(84); | ||
case 88: | ||
return _context.finish(81); | ||
case 89: | ||
if (!(touches.length || disabled)) { | ||
_context.next = 91; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
case 35: | ||
this.lastOffsetY = this.offsetY; // 判断是否加载 | ||
case 91: | ||
this.touching = false; | ||
this.pos = {}; // 判断是否加载 | ||
@@ -256,3 +418,2 @@ shouldLoad = this.scrollTop <= 0 && this.offsetY >= this.data.loadingHeight; | ||
if (this.status === STATUS.IDLE) { | ||
this.startRefreshTime = Date.now(); | ||
this.triggerEvent('refresh'); | ||
@@ -265,2 +426,3 @@ this.setData({ | ||
this.startRefreshTime = Date.now(); | ||
result = this.data.loadingHeight; | ||
@@ -279,5 +441,5 @@ } else { | ||
this.lastOffsetY = this.offsetY = result; | ||
return _context.abrupt("break", 42); | ||
return _context.abrupt("break", 99); | ||
case 42: | ||
case 99: | ||
case "end": | ||
@@ -287,3 +449,3 @@ return _context.stop(); | ||
} | ||
}, _callee, this); | ||
}, _callee, this, [[11, 24, 28, 36], [29,, 31, 35], [41, 45, 49, 57], [50,, 52, 56], [73, 77, 81, 89], [82,, 84, 88]]); | ||
})); | ||
@@ -445,4 +607,4 @@ | ||
case 0: | ||
// 用户下拉,至少保证小球转3圈 | ||
time = 1500 - (Date.now() - this.startRefreshTime); | ||
// 用户下拉,至少保证小球转1圈 | ||
time = 500 - (Date.now() - this.startRefreshTime); | ||
time = time > 0 ? time : 0; | ||
@@ -481,4 +643,4 @@ _context4.next = 4; | ||
*/ | ||
scrollToLower: function scrollToLower(_ref4) { | ||
var detail = _ref4.detail; | ||
scrollToLower: function scrollToLower(_ref3) { | ||
var detail = _ref3.detail; | ||
this.triggerEvent('scrolltolower', detail); | ||
@@ -502,6 +664,8 @@ }, | ||
this.scrollTop = 0; // 手指开始位置 | ||
this.scrollTop = 0; // 是否有手指在屏幕 | ||
this.startY = 0; // 上次结束位置 | ||
this.touching = false; // 多点触控位置,解决手指交叉切换问题 | ||
this.pos = {}; // 上次结束位置 | ||
this.lastOffsetY = 0; // 手指移动位置 * 用这个来判断是否手机离开屏幕 | ||
@@ -518,3 +682,3 @@ | ||
var timer = setInterval(function () { | ||
if (_this5.offsetY > _this5.data.loadingHeight) { | ||
if (_this5.touching) { | ||
return; | ||
@@ -532,36 +696,50 @@ } | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref5 = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee5(drag) { | ||
return _regenerator["default"].wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context5.next = 2; | ||
return _this5.debOffsetCheck(); | ||
(0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee5() { | ||
return _regenerator["default"].wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context5.next = 2; | ||
return _this5.debOffsetCheck(); | ||
case 2: | ||
_context5.next = 4; | ||
return new Promise(function (r) { | ||
return setTimeout(r, 800); | ||
}); | ||
case 2: | ||
_context5.next = 4; | ||
return new Promise(function (r) { | ||
return setTimeout(r, 800); | ||
}); | ||
case 4: | ||
_context5.next = 6; | ||
return _this5.closeLoading(); | ||
case 4: | ||
_context5.next = 6; | ||
return _this5.closeLoading(); | ||
case 6: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
case 6: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
}, _callee5); | ||
})); | ||
} | ||
}, _callee5); | ||
})), 100); | ||
}, | ||
ready: function ready() { | ||
var _this6 = this; | ||
return function (_x2) { | ||
return _ref5.apply(this, arguments); | ||
}; | ||
}(), 100); | ||
// 计算滑动区域高度,用于计算阻尼值 | ||
swan.createSelectorQuery()["in"](this).select('.smt-feed-wrap').boundingClientRect(function (res) { | ||
try { | ||
if (!res) { | ||
throw '未找到节点'; | ||
} | ||
var clientHeight = res.height; | ||
_this6.setData({ | ||
clientHeight: clientHeight | ||
}); | ||
} catch (err) { | ||
console.error('获取节点信息错误'); | ||
} | ||
}).exec(); | ||
} | ||
}); |
@@ -10,3 +10,3 @@ { | ||
"prebuild": "sh ./prebuild.sh", | ||
"build": "" | ||
"build": "echo \"smt-feed build\" && exit 1" | ||
}, | ||
@@ -13,0 +13,0 @@ "keywords": [], |
@@ -73,2 +73,3 @@ /** | ||
data: { | ||
// 左右小球信息 | ||
circle: { | ||
@@ -87,7 +88,10 @@ // 小球尺寸 * device px防止变形 | ||
// 是否禁用scrollView | ||
enableScroll: true, | ||
// 滑动距离 | ||
offsetY: 0, | ||
lower: false, | ||
// 滑动区域高度,用于计算阻尼值 | ||
clientHeight: 0, | ||
@@ -115,2 +119,6 @@ // 最长18个汉字 | ||
/** | ||
* scrollView 滚动参数 | ||
* @param {Object} param Event | ||
*/ | ||
scrollHdl({detail}) { | ||
@@ -131,3 +139,19 @@ this.scrollTop = detail.scrollTop; | ||
async touchHdl({type, changedTouches = [], manual = false}) { // eslint-disable-line fecs-max-statements | ||
/** | ||
* 阻尼值转换 * 四参方程有常数,便于转换屏幕比 | ||
* x: 0, 50, 100, 150, 200, 250, 300, 350, 400, 800, 40000, 120000 | ||
* y: 0,32,62,90,115,136,153,164,170,270, 420, 440 | ||
* | ||
* @param {number} pullDistance 下拉的总距离 | ||
* @param {number=} base 基础值,calc(iphone 8p - 40px) | ||
* @return {number} 返回值 | ||
*/ | ||
dumping(offsetY, base = 464) { | ||
const y = offsetY > 0 ? offsetY : 0; | ||
const ratio = this.data.clientHeight / base; | ||
const result = (440.5 + .5) * ratio / (1 + (y / 551.5665) ** -1.009) - .5; | ||
return Math.round(result); | ||
}, | ||
async touchHdl({type, touches = [], changedTouches = [], manual = false}) { // eslint-disable-line fecs-max-statements | ||
// 如果上一次没完全关闭,禁止下拉 | ||
@@ -137,5 +161,2 @@ if (this.closing || (this.data.disableTouch && !manual)) { | ||
} | ||
const ids = changedTouches.map(({identifier}) => identifier); | ||
const last = changedTouches.length - 1; | ||
const y = changedTouches[last] && changedTouches[last].pageY; | ||
// ue规定: 如果api调用下拉刷新,则不启用手势刷新 | ||
@@ -147,18 +168,23 @@ const disabled = !this.data.pullToRefresh && !manual && this.status === STATUS.IDLE; | ||
case 'touchstart': { | ||
const identifier = changedTouches[last].identifier; | ||
this.identifier = identifier; | ||
if (!ids.includes(this.identifier)) { | ||
return; | ||
this.touching = true; | ||
for (const touch of touches) { | ||
const {identifier: id, pageY} = touch; | ||
if (this.pos[id] == null) { | ||
this.pos[id] = pageY + this.scrollTop; | ||
break; | ||
} | ||
} | ||
this.startY = y + this.scrollTop; | ||
this.lastOffsetY = this.offsetY; | ||
break; | ||
} | ||
case 'touchmove': { | ||
if (!ids.includes(this.identifier)) { | ||
return; | ||
let distance = 0; | ||
for (const touch of touches) { | ||
const {identifier: id, pageY} = touch; | ||
if (this.pos[id]) { | ||
distance += Math.round(pageY - this.pos[id]); | ||
} | ||
} | ||
const distance = y - this.startY; | ||
let offsetY = this.offsetY = this.dumping(distance + this.lastOffsetY); | ||
const pullDown = distance > 0; | ||
let offsetY = this.offsetY = distance * .6 + this.lastOffsetY; | ||
// 没loading动画时下拉计算动画 | ||
@@ -170,4 +196,4 @@ if (this.status === STATUS.IDLE) { | ||
// 向上划要收起loading, 设置20px防误触 | ||
if (!pullDown && Math.abs(y - this.startY) > 20) { | ||
// 还未加载时,向上划要收起loading | ||
if (!pullDown && this.status !== STATUS.IDLE && Math.abs(offsetY) > 20) { | ||
this.fadeCircle(); | ||
@@ -186,4 +212,5 @@ this.setData({ | ||
} | ||
if (pullDown && this.scrollTop <= 0 && this.scrollTop - offsetY <= 0) { | ||
// offsetY快,setData慢,可能造成向上划没到顶。 | ||
// 要注意 初始就向下划,过滤掉 | ||
if (offsetY > 0 || this.data.offsetY > 0) { | ||
const setOffsetY = () => this.setData({offsetY}); | ||
@@ -203,7 +230,16 @@ // 如果已经禁止滚动&&还往下拉,直接赋值 | ||
case 'touchend': { | ||
// ids.lenght === 0 说明手动触发;offsetY === 0 说明关闭主动置零 | ||
if (ids.length > 0 && !ids.includes(this.identifier) || this.offsetY === 0 || disabled) { | ||
for (const touch of changedTouches) { | ||
const {identifier: id, pageY} = touch; | ||
if (this.pos[id]) { | ||
this.lastOffsetY += pageY - this.pos[id]; | ||
} | ||
} | ||
if (touches.length || disabled) { | ||
return; | ||
} | ||
this.lastOffsetY = this.offsetY; | ||
this.touching = false; | ||
this.pos = {}; | ||
// 判断是否加载 | ||
@@ -215,3 +251,2 @@ const shouldLoad = this.scrollTop <= 0 && this.offsetY >= this.data.loadingHeight; | ||
if (this.status === STATUS.IDLE) { | ||
this.startRefreshTime = Date.now(); | ||
this.triggerEvent('refresh'); | ||
@@ -221,2 +256,3 @@ this.setData({status: STATUS.LOADING}); | ||
} | ||
this.startRefreshTime = Date.now(); | ||
result = this.data.loadingHeight; | ||
@@ -302,4 +338,4 @@ } | ||
async stopRefresh() { | ||
// 用户下拉,至少保证小球转3圈 | ||
let time = 1500 - (Date.now() - this.startRefreshTime); | ||
// 用户下拉,至少保证小球转1圈 | ||
let time = 500 - (Date.now() - this.startRefreshTime); | ||
time = time > 0 ? time : 0; | ||
@@ -341,5 +377,8 @@ await new Promise(r => setTimeout(r, time)); | ||
// 手指开始位置 | ||
this.startY = 0; | ||
// 是否有手指在屏幕 | ||
this.touching = false; | ||
// 多点触控位置,解决手指交叉切换问题 | ||
this.pos = {}; | ||
// 上次结束位置 | ||
@@ -360,3 +399,3 @@ this.lastOffsetY = 0; | ||
const timer = setInterval(() => { | ||
if (this.offsetY > this.data.loadingHeight) { | ||
if (this.touching) { | ||
return; | ||
@@ -370,3 +409,3 @@ } | ||
// 关闭loading bar; text显示时长: 800ms | ||
this.debCloseLoading = promiseDebounce(async drag => { | ||
this.debCloseLoading = promiseDebounce(async () => { | ||
await this.debOffsetCheck(); | ||
@@ -376,3 +415,20 @@ await new Promise(r => setTimeout(r, 800)); | ||
}, 100); | ||
}, | ||
ready() { | ||
// 计算滑动区域高度,用于计算阻尼值 | ||
swan.createSelectorQuery().in(this) | ||
.select('.smt-feed-wrap').boundingClientRect(res => { | ||
try { | ||
if (!res) { | ||
throw '未找到节点'; | ||
} | ||
const clientHeight = res.height; | ||
this.setData({clientHeight}); | ||
} | ||
catch (err) { | ||
console.error('获取节点信息错误'); | ||
} | ||
}).exec(); | ||
} | ||
}); |
@@ -1,1 +0,1 @@ | ||
{"name":"component","label":"布局组件","type":"component","configPath":"./smart-design-config.json","version":"0.0.32-alpha.0"} | ||
{"name":"component","label":"布局组件","type":"component","configPath":"./smart-design-config.json","version":"0.0.36-alpha.0"} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1426989
102
18944
15
1