先上图看效果

没错,这是一个sencha touch 项目,而这里的右边推出效果(下文叫做tabsiderbar),使用插件tabsiderbar来扩展的.

插件js下载地址:http://www.m-gd.com/sencha-touch-sidebar-component/

这里的插件实现的效果为:工具栏点击,从左边open半个页面出来

而我们如果我们要使这个页面从邮编出来怎么办呢?

这里我将Siderbar.js中扩展了一下,具体如下(这里只贴扩展后的代码和主要思路):

1,给indicator对象添加自定义属性startBy

        /**
* @cfg {Object || Boolean} indicator
* if false, no idicator is shown, otherwise this defines the indicator
*/
indicator: {
itemId: 'mgd-tab-sidebar-button',
/**
* @cfg {String} text
* the button text
*/
text: '', /**
* @cfg {String} #closeStateCls
* add additional classes to the button
*/
openCls: '', /**
* @cfg {String} #openStateCls
* add additional classes to the button
*/
cls: 'mgd-tab-sidebar-button', /**
* @cfg {String} btnPressedCls
* add additional classes to the pressed button state
*/
pressedCls: 'mgd-tab-sidebar-button-pressing', /**
* @cfg {Number} [left=0]
* The absolute left position of this Component
*/
// left: 0, /**
* @cfg {Number} top
* The absolute top position of this Component
*/
top: 3, /**
* @cfg {Number} zIndex
* The z-index to give this Component when it is rendered
*/
zIndex: 5,
//添加自定义属性startBy(名称自取)
startBy:"left"
}

2,扩展toggle函数为两个:toggleByLeft(默认就是这个方法)和toggleByRight

/* ---------------------------------------扩展 Show By Right ACTION --------------------------------------- */
toggleByRight: function (button) {
config.showToast();
console.log('[tab.Sidebar][toggle] tapped the button');
console.log("扩展注释:---toggleByRight");
button = button || this.getIndicator();
var activeView = Ext.Viewport.getActiveItem(),
sidebar = button ? button.config.sidebar : this;
var width = sidebar.getWidth();
var windowWidth=window.innerWidth; //初始位置从浏览器窗口的最右端开始
if (sidebar.getState() === 'closed') {
// set State
sidebar.setState('open');
sidebar.setHidden(false);
// run the opening animation
Ext.Anim.run(sidebar, 'tabsidebar', {duration: sidebar.getDuration(),fromX: windowWidth});
if(sidebar.getMoveActiveView())
Ext.Anim.run(activeView, 'tabsidebar', {duration: sidebar.getDuration(),toX:-width});
if (button){
Ext.Anim.run(button, 'tabsidebar', {duration: sidebar.getDuration(),toX:-width});
// show a different symbol in the button
button.addCls(button.config.openCls);
}
} else {
// set State
sidebar.setState('closed');
// run the closing animation
Ext.Anim.run(sidebar, 'tabsidebar', {out: true,duration: sidebar.getDuration(),toX: windowWidth});
if(sidebar.getMoveActiveView())
Ext.Anim.run(activeView, 'tabsidebar', {out: true,duration: sidebar.getDuration(),fromX: -width});
if (button){
Ext.Anim.run(button, 'tabsidebar', {out: true,duration: sidebar.getDuration(),fromX: -width});
// revert to original symbol in the button
button.removeCls(button.config.openCls);
}
}
config.hideToast();
},

3,toggleByRight代码

    /* --------------------------------------- BUTTON --------------------------------------- */
/**
* create the indicator
*/
createIndicator: function () {
if (this.getIndicator() !== false) {
// Set the text on the button
var button = this.getIndicator();
button.xtype = 'button';
//button.handler = this.toggle;
/************扩展代码开始************/
if(this.getIndicator().startBy=='left'){
this.getIndicator().left=10;//设置按钮位置靠左
this.setLeft(0);//从左边open,将siderBar靠左浮动(left=0),保持层靠边不重叠
button.handler = this.toggleByLeft;
}else{
this.getIndicator().right=10; //设置按钮位置靠右
this.setRight(0);//从右边show,将siderBar靠左浮动(right=0),保持层靠边不重叠
button.handler = this.toggleByRight;
}
/************扩展代码结束************/
button.sidebar = this;
Ext.Viewport.add(button);
this.setIndicator(Ext.Viewport.down('#' + button.itemId));
// Set the handler on the button to listen for opening/closing and the pressed state.
// createdButton.on('touchstart', 'addPressedCls', this);
Ext.Viewport.on('orientationchange', this.orientationchange, this.getIndicator());
}
}

4,需要注意的地方:

  ①open这个tabsiderbar的时候,注意tabsiderbar的浮动方向(代码2中说明)

  ②使用方式只需要配置startBy属性

  

Ext.Viewport.add(
{
xtype: 'tabsidebar',
id: 'tabsb',
scrollable: null,
indicator: {
text: '更多',
iconMask: false,
width: '65px',
startBy: "right" //使用自定义属性,使得该tabsiderbar从左边出来还是右边
},
header: '更多',
items:[
{
xtype: "list",
scrollable: null,
id:"moreList_id",
height:"600px",
store: {
fields: ['mid','text'],
data: [
{mid:'1',text: '分享应用'},
{mid:'1',text: '关于我们'},
{mid:'1',text: '更新版本'},
{mid:'1',text: '清除缓存'},
{mid:'1',text: '退出应用'}
]
},
itemTpl: "<div>{text}</div>",
listeners:{
painted:function(sb){
sb.setCls("moreList_cls");
}
}
}
]
}
);

至此,欢迎大家拍砖;

这里又做了一个手指跟随的扩展

            //手指滑动事件
main.on("swipe", function(e, target, options, eOpts) {
if (e.direction === 'left' && e.distance >= 20) {
if(Ext.getCmp("tabsb").getState()=="closed"){
Ext.getCmp("tabsb").toggleByRight();
}
} else if (e.direction === 'right' && e.distance >= 20) {
if(Ext.getCmp("tabsb").getState()=="open"){
Ext.getCmp("tabsb").toggleByRight();
}
}
},this);

sencha touch tabsidebar 源码扩展的更多相关文章

  1. sencha touch NavigationView 源码详解(注释)

    Ext.define('Ext.navigation.View', { extend: 'Ext.Container', alternateClassName: 'Ext.NavigationView ...

  2. ubuntu phone/touch的源码从哪里下载?

    这里有人在问ubuntu phone的源码从哪里下载? http://askubuntu.com/questions/237321/where-can-i-get-the-source-code-fo ...

  3. Linux下利用phpize安装memcashe的php源码扩展包

    phpize是php的一种构建工具,为PHP扩展准备构建环境,通过phpize可以编译php的扩展源码文件为php扩展模块. 一.安装 phpize工具可以通过安装php-dev包自动集成安装.安装完 ...

  4. 记录一次源码扩展案列——FastJson自定义反序列化ValueMutator

    背景:曾经遇到一个很麻烦的事情,就是一个json串中有很多占位符,需要替换成特定文案.如果将json转换成对象后,在一个一个属性去转换的话就出出现很多冗余代码,不美观也不是很实用. 而且也不能提前在j ...

  5. 四:WEB源码扩展

    前言:WEB源码在安全测试中是非常重要的信息来源,可以用来进行代码审计漏洞也可以用来做信息突破口,其中WEB源码有很多技术需要简明分析,获取某ASP源码后就可以采用默认数据库下载为突破,获取某其他脚本 ...

  6. sencha touch 分享到微博扩展

    扩展代码: /* *分享到微博 */ Ext.define('ux.WeiboPicker', { extend: 'Ext.Picker', xtype: 'weiboPicker', config ...

  7. sencha touch list 批量选择扩展(2013-7-29)

    扩展js代码 /* *list多选扩展 */ Ext.define('ux.SimpleList', { alternateClassName: 'simpleList', extend: 'Ext. ...

  8. PHP扩展编写、PHP扩展调试、VLD源码分析、基于嵌入式Embed SAPI实现opcode查看

    catalogue . 编译PHP源码 . 扩展结构.优缺点 . 使用PHP原生扩展框架wizard ext_skel编写扩展 . 编译安装VLD . Debug调试VLD . VLD源码分析 . 嵌 ...

  9. 读Zepto源码之Touch模块

    大家都知道,因为历史原因,移动端上的点击事件会有 300ms 左右的延迟,Zepto 的 touch 模块解决的就是移动端点击延迟的问题,同时也提供了滑动的 swipe 事件. 读 Zepto 源码系 ...

随机推荐

  1. Linux下通过shell脚本创建账户

    当我们在linux平台上开发一些项目时,或者有一些项目是需要部署到linux系统上时,有时候会涉及到linux上的特定的账户,例如有一些项目需要运行在某些特定的账户下,或者有时候需要在全新的环境上搭建 ...

  2. flash memory

    数据删除不是以单个的字节为单位而是以固定的区块为单位(注意:NOR Flash 为字节存储.),区块大小一般为256KB到20MB. 由于其断电时仍能保存数据,闪存通常被用来保存设置信息,如在电脑的B ...

  3. 【转】How to view word document in WPF application

    How to view word document in WPF application (CSVSTOViewWordInWPF) Introduction The Sample demonstra ...

  4. 《WPF程序设计指南》读书笔记——第5章 Stack与Wrap

    1.StackPanel面板 using System; using System.Windows; using System.Windows.Input; using System.Windows. ...

  5. C语言获取网页源代码的学习所得

    研究了一天这个玩意感觉挺有意思的. 刚开始是什么都不懂,现在写出来一段代码感觉略微有点意思了. 下面我分享一下学习过程和自己的理解. 整体过程大概就是如下情况: 先搜了一下别人的写这个东西的代码. 研 ...

  6. ubuntu find方法

    通用格式:find pathname -options [-print -exec -ok]例子:find / -name filename 再根目录里面搜索文件名为filename的文件find / ...

  7. C#基础及记忆概念

    在C#中,你给一个方法传输值类型参数时,实际上是使用的这个参数的一个副本,就是将原来的变量复制一份,然后传给一个方法,让其进行操作.所以在方法内部对参数的修改等不会对原来的参数造成影响(这个其实就是值 ...

  8. Qt单元测试

    单元测试之作用要完成测试用例,保证设计上的耦合依赖通过测试用例,保证覆盖率,提高程序质量 QTest一些有用的静态函数QTest::qExecQTest::qSleepQTest::qWait   例 ...

  9. centos apache 隐藏和伪装 版本信息

    1.隐藏Apache版本信息 测试默认 apache 的状态信息[root@1314it conf]# curl -Is localhostHTTP/1.1 200 OKDate: Tue, 16 N ...

  10. Hibernate - SQLQuery

    使用SQLQuery 对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Session.createSQLQuery()获取这个接口.下面来描述如何使用这个API进行查询. 标量查询 ...