sencha touch Carousel 自动切换
2024-08-24 21:19:13
代码是在网上找的,忘记原出处了
/**
* 跑马灯自动切换
*/
Ext.define('ux.RotatingCarousel', {
extend: 'Ext.carousel.Carousel',
alternateClassName: 'rotatingCarousel',
xtype: 'rotatingCarousel',
config: {
delay: 3000,
start: true,
listeners: {
tap: {
fn: function () {
this.pause();
},
element: 'element'
},
swipe: {
fn: function () {
this.start();
},
element: 'innerElement'
}
}
},
initialize: function () {
if (this.config.start) {
this.start();
}
},
rotate: function () {
if (this.timeout) {
clearTimeout(this.timeout);
}
if (this.getActiveIndex() === this.getMaxItemIndex()) {
this.setActiveItem(0, 'slide');
} else {
this.next();
}
this.timeout = Ext.defer(this.rotate, this.config.delay, this);
},
start: function (delayStart) {
this.timeout = Ext.defer(this.rotate, delayStart || this.config.delay, this);
},
pause: function (delayStart) {
if (this.timeout) {
clearTimeout(this.timeout);
}
if (delayStart) {
this.start(delayStart);
}
return this;
},
stop: function (delayStart) {
this.pause(delayStart);
this.setActiveItem(0, 'slide');
return this;
}
});
使用:
Ext.define('app.view.Home', {
extend: 'Ext.Container',
xtype: 'home',
requires: ['ux.RotatingCarousel'],
config: {
items: [{
xtype: 'rotatingCarousel',
height: '200px',
items: [{
html: '<div class="homeImg" style="background-image:url(\'resources/images/lg1.png\')"></div>'
},
{
html: '<div class="homeImg" style="background-image:url(\'resources/images/lg2.png\')"></div>'
},
{
html: '<div class="homeImg" style="background-image:url(\'resources/images/lg3.png\')"></div>'
}]
}]
}
});
最新文章
- C#中将DataTable转成List
- C++程序员如何入门Unreal Engine 4
- js调用.net后台事件、后台调用前台以及js调用服务器控件
- 高性能javascript学习笔记系列(2)-数据存取
- flex设置成1和auto有什么区别
- Oracle 中的游标(用Javase中Iterator 类比之)
- 读CopyOnWriteArrayList有感
- [C++] socket - 2 [UDP通信C/S实例]
- 实验箱FPGA部分测试报告及A8与FPGA链接测试报告
- 条款2:尽量以const、enum、inline替换#define
- java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^
- Python 操作 MySQL--(pymysql)
- iTunes Store:隐藏和取消隐藏已购项目
- npx命令介绍
- 关于各种工具输入参数中";-";和";--";
- [Swift]LeetCode907. 子数组的最小值之和 | Sum of Subarray Minimums
- Python——SQLite
- 2种方式解决vue路由跳转未匹配相应路由避免出现空白页面或者指定404页面
- ASP.NET Core 中使用EF Core 将实体映射到数据库表的方法(SQL Server)
- 【Linux常见问题】Centos7的网络配置问题