博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sencha 2.3中自己定义PullRefreshFn给PullRefresh加入下拉刷新事件
阅读量:5742 次
发布时间:2019-06-18

本文共 3458 字,大约阅读时间需要 11 分钟。

Sencha removed the refreshFn from the pullrefresh plugin in ST 2.2. Here is an user extension with gives the old functionality back to you.

/** * This user extension gives st 2.3.0 Pullrefresh the RefreshFn back * based on sencha touch 2.3.0 *  * @class Ext.ux.touch.PullRefreshFn * @version 2.0.1-beta * @author Martin Hess 
* * ## Example * * Ext.create('Ext.dataview.List', { * fullscreen: true, * * store: store, * * plugins: [ * { * xclass: 'Ext.ux.touch.PullRefreshFn', * pullRefreshText: 'Pull down for more new Tweets!' * refreshFn: function() { * Ext.getStore('ENTER YOUR STORE HERE').load('',1) * } * } * ], * * itemTpl: [ * 'YOUR ITEMTPL' * ] * }); */Ext.define('myapp.model.PullRefreshFn', { extend: 'Ext.plugin.PullRefresh', alias: 'plugin.pullrefreshfn', requires: ['Ext.DateExtras'], xtype:'refreshFn', config: { /** * @cfg {Function} refreshFn The function that will be called to refresh the list. * If this is not defined, the store's load function will be called. * The refresh function gets called with a reference to this plugin instance. * @accessor */ refreshFn: null, pullText: '下拉能够更新', lastUpdatedText:"上次刷新时间", lastUpdatedDateFormat:"Y-m-d H:i", releaseText:"松开開始更新", loadedText:"载入完毕" }, fetchLatest: function() { if (this.getRefreshFn()) { this.getRefreshFn().call(this, this); this.setState("loaded"); this.fireEvent('latestfetched', this, 'refreshFn, you have to handle toInsert youself'); if (this.getAutoSnapBack()) { this.snapBack(); } } else { console.log('fetchLatest') var store = this.getList().getStore(), proxy = store.getProxy(), operation; operation = Ext.create('Ext.data.Operation', { page: 1, start: 0, model: store.getModel(), limit: store.getPageSize(), action: 'read', sorters: store.getSorters(), filters: store.getRemoteFilter() ? store.getFilters() : [] }); proxy.read(operation, this.onLatestFetched, this); } }, /** * Snaps the List back to the top after a pullrefresh is complete * @param {Boolean=} force Force the snapback to occur regardless of state {optional} */ snapBack: function(force) { if(this.getState() !== "loaded" && force !== true) return; var that = this, list = this.getList(), scroller = list.getScrollable().getScroller(), currentY = scroller.minPosition.y; scroller.refresh(); scroller.minPosition.y = 0; scroller.on({ scrollend: this.onSnapBackEnd, single: true, scope: this }); this.setIsSnappingBack(true); scroller.getTranslatable().translateAnimated(0, currentY, {duration: this.getSnappingAnimationDuration()}); setTimeout( function () { scroller.scrollTo(0,1); scroller.scrollToTop(); }, that.getSnappingAnimationDuration() ); }});

转载地址:http://enizx.baihongyu.com/

你可能感兴趣的文章
centos和pycharm中取绝对路径的差别
查看>>
ext2磁盘布局
查看>>
MySql数据库2【常用命令行】
查看>>
动态规划---->货郎担问题
查看>>
Ubuntu 12.04 root用户登录设置
查看>>
存储过程点滴
查看>>
[LeetCode]22.Generate Parentheses
查看>>
计算A/B Test需要的样本量
查看>>
二叉树前序中序后序遍历的非递归方法
查看>>
《设计模式系列》---桥接模式
查看>>
[Unity3d]Shader 着色器 学习前了解知识
查看>>
strtok和strtok_r
查看>>
维辰超市:借助云商城成功转型新零售
查看>>
web.xml中<load-on-start>n</load-on-satrt>作用
查看>>
【算法】CRF
查看>>
windows 8 微软拼音输入法
查看>>
Windows UI风格的设计(7)
查看>>
SQL中使用WITH AS提高性能 使用公用表表达式(CTE)简化嵌套SQL
查看>>
oracle 强行杀掉一个用户连接
查看>>
Git提交本地库代码到远程服务器的操作
查看>>