app-framework学习-----Scroller

Scroller

这个插件允许你创建一个可滚动区域。我们使用的JavaScript滚轮,除非该设备支持 - WebKit的溢出卷轴:触摸。它有许多修复Android版<3和iOS原生的滚动。

创建:

2

$(selector).scroller({})
//create

$(selector).scroller()
//get
the scroller object

属性:

Attributes


1

2

3

4

5

6

7

8

9

10

11

scrollbars                  
(bool) ID of DOM elemenet
for

the popup container

verticalScroll              
(bool) 允许vertical scrolling

horizontalScroll            
(bool) 允许horizontal scrolling

useJsScroll                 
(bool) 是否允许 JavaScript scroller

lockBounce                  
(bool) Prevent the rubber band effect

autoEnable                  
(bool) 自动启用滚动条

refresh                     
(bool) 上拉刷新

infinite                    
(bool) 启用无限滚动

initScrollProgress          
(bool) Dispatch progress on touch move

vScrollCSS                  
(string) 垂直滚动条

hScrollCSS                  
(string) 水平滚动条

方法


1

2

3

4

5

6

7

8

9

10

11

enable()                    
启用滚动条

disable()                   
禁用滚动条

scrollToBottom(time)        
滚动到内容的底部

scrollToTop(time)           
滚动到内容顶部

scrollTo(obj,time)          
to X / Y 坐标

scrollBy(obj,time)          
by X / Y 坐标

addPullToRefresh()          
启用下拉刷新的滚动条

setRefreshContent(string)   
设置了下拉刷新内容的文字

addInfinite()

addInfinite事件

clearInfinite()             
Clear inifinite-scroll-end event

scrollToItem(DOMNode,time)  
滚动到屏幕上的特定元素

事件

Events must be registered on the scroller using $.bind()


1

2

3

4

5

6

7

8

9

10

11

12

13

14

//scroller
object events

scrollstart                 
Scrolling started

scroll                      
Scrolling progress

scrollend                   
Scrolling stopped

//pull
to refresh

refresh-trigger             
Pull to refresh scroll started

refresh-release             
Event when pull to refresh is has happened

refresh-cancel              
User cancelled pull to refresh by scrolling

refresh-finish              
Pull to refresh has finished and hidden

//infinite
scroll

infinite-scroll             
User scrolled to the bottom of the content

infinite-scroll-end         
User finished scrolling

CSS/Customize

Below is an example used by App Framework‘s iOS7 theme to customize the look and feel of the popup


1

2

3

4

5

6

7

8

9

.scrollBar
{

    position:
absolute ;

    width:
5px !important;

    height:
20px !important;

    border-radius:
2px !important;

    border:
1px solid black !important;

    background:
red !important;

    opacity:
0 !important;

}

Examples

在HTML 中添加


1

||div
id=
"scroll"

style=
‘width:100%;height:200;‘></div>

js中创建


1

2

3

4

5

var

myScroller=$(
"#scroll").scroller({

   verticalScroll:true,

   horizontalScroll:false,

   autoEnable:true

})

调用方法


1

myScroller.addPullToRefresh();

从缓存中获取滚动条


1

var

myScroller=$(
"#scroll").scroller();
//no
parameters

Pull to refresh

下面是如何结合事件和执行下拉刷新的例子


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

myScroller.addPullToRefresh();

//User
is dragging the page down exposing the pull to refresh message.

$.bind(myScroller,
"refresh-trigger",
function

() {

    console.log("Refresh
trigger"
);

});

//Here
we listen for the user to pull the page down and then let go to start the pull to refresh callbacks.

var

hideClose;

$.bind(myScroller,
"refresh-release",
function

() {

    var

that =
this;

    console.log("Refresh
release"
);

    clearTimeout(hideClose);

    //For
the demo, we set a timeout of 5 seconds to show how to hide it asynchronously

    hideClose
= setTimeout(
function

() {

        console.log("hiding
manually refresh"
);

        that.hideRefresh();

    },
5000);

    return

false
;
//tells
it to not auto-cancel the refresh

});

//This
event is triggered when the user has scrolled past and the pull to refresh block is no longer available

$.bind(myScroller,
"refresh-cancel",
function

() {

    clearTimeout(hideClose);

    console.log("cancelled");

});

infinite scrolling

The following shows how to implement infinite scrolling.


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

myScroller.addInfinite();

//Bind
the infinite scroll event

$.bind(myScroller,
"infinite-scroll",
function

() {

    var

self =
this;

    console.log("infinite
triggered"
);

    //Append
text at the bottom

    $(this.el).append("

<div
id="
infinite"
style="
border:2px
solid black;margin-top:10px;width:100%;height:20px
">Fetching
content...</div>

");

    //Register
for the infinite-scroll-end - this is so we do not get it multiple times, or a false report while infinite-scroll is being triggered;

    $.bind(myScroller,
"infinite-scroll-end",
function

() {

        //unbind
the event since we are handling it

        $.unbind(myScroller,
"infinite-scroll-end");

        self.scrollToBottom();

        //Example
to show how it could work asynchronously

        setTimeout(function

() {

            $(self.el).find("#infinite").remove();

            //We
must call clearInfinite() when we are done to reset internal variables;

            self.clearInfinite();

            $(self.el).append("

<div>This
was loaded via inifinite scroll<br>More Content</div>

");

            self.scrollToBottom();

        },
3000);

    });

});

有什么问题可以联系我

官网链接:http://app-framework-software.intel.com/api.php#scroller

时间: 2024-11-08 21:15:58

app-framework学习-----Scroller的相关文章

jqMobi(App Framework)入门学习(一)

jqMobi(App Framework)入门学习(一) 1. 什么是jqMobi? jqMobi是由appMobi针对HTML5浏览器和移动设备开发的javascript框架,是个极其快速的查询选择库,支持W3C查询. jqMobi源码是基于jQuery源码重写的,但是两者又属于不同的产品,jqMobi体积更小,速度更快,兼容性也有所不同. 上面这段话来自百度百科,但是目前由于jqmobi已被收购并不断发展,而且jqmobi并不仅仅局限于查询选择库,所以上面的解释并不是很全面. 2. jqMo

Entity Framework 学习

Entity Framework 学习初级篇1--EF基本概况... 2 Entity Framework 学习初级篇2--ObjectContext.ObjectQuery.ObjectStateEntry.ObjectStateManager类的介绍... 7 Entity Framework 学习初级篇3-- LINQ TOEntities. 10 Entity Framework 学习初级篇4--EntitySQL. 17 Entity Framework 学习初级篇5--ObjectQ

Android学习Scroller(五)——详解Scroller调用过程以及View的重绘

MainActivity如下: package cc.ww; import android.os.Bundle; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; import android.app.Activity;

Android学习Scroller(四)——实现拉动后回弹的布局

MainActivity如下: package cc.testscroller2; import android.os.Bundle; import android.app.Activity; /** * Demo描述: * 实现可以拉动后回弹的布局. * 类似于下拉刷新的. * * 参考资料: * 1 http://gundumw100.iteye.com/blog/1884373 * 2 http://blog.csdn.net/gemmem/article/details/7321910

Android学习Scroller(三)——控件平移划过屏幕 (Scroller简单使用)

MainActivity如下: package cc.cn; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.app.Activity; /** * Demo描述: * Scroller使用示例--让控件平移划过屏幕 * * 参考资料: * http://blog.cs

Android学习Scroller(二)——ViewGroup调用scrollTo()

MainActivity如下: package cc.ac; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.app.Activity; /** * Demo描述: * 对ViewGroup调用sc

Android学习Scroller(一)——View调用scrollTo()的理解及使用

MainActivity如下: package cc.uu; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.app.Activity; /** * Demo描述: * scrollTo()和scrollB

Android学习Scroller(三)

MainActivity如下: package cc.testscroller2; import android.os.Bundle; import android.app.Activity; /** * Demo描述: * 实现可以拉动后回弹的布局. * 类似于下拉刷新的. * * 参考资料: * 1 http://gundumw100.iteye.com/blog/1884373 * 2 http://blog.csdn.net/gemmem/article/details/7321910

Android学习Scroller(二)

MainActivity如下: package cc.testscroller1; import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.View.OnClick

Entity Framework学习中级篇

1-EF支持复杂类型的实现 本节,将介绍如何手动构造复杂类型(ComplexType)以及复杂类型的简单操作. 通常,复杂类型是指那些由几个简单的类型组合而成的类型.比如:一张Customer表,其中有FristName和LastName字段,那么对应的Customer实体类将会有FristName和LastName这两个属性.当我们想把FirstName和LastName合成一个名为CustomerName属性时,此时,如果要在EF中实现这个目的,那么我们就需要用到复杂类型. 目前,由于EF不