Blend UI Slider API文檔

2018-10-17 11:35 更新

Construct

配置所需參數(shù)來初始化一個幻燈片組件Slider

Slider的配置格式如下:

var slider = new Blend.ui.Slider({"options":"values"});

Slider包含以下配置項:


id

slider的id

類型說明是否必須
Stringslider的id


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});


top

配置slider距離屏幕top的坐標

類型說明是否必須
Numberslider距離屏幕top的坐標,默認值0


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "top": 100,
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});


left

配置slider距離屏幕left的坐標

類型說明是否必須
Numberslider距離屏幕left的坐標,默認值0


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "top": 100,
    "left": 100,
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});


width

配置slider寬度

類型說明是否必須
Numberslider像素寬度,默認為屏幕寬度


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "width": 100,
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});


height

配置slider高度

類型說明是否必須
Numberslider像素高度,默認為屏幕高度


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "height": 100,
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});


bgColor

配置slider背景顏色

類型說明是否必須
Stringslider背景顏色,默認透明


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "bgColor": "#cccccc",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});


images

配置圖片數(shù)據(jù)json

類型說明是否必須
Object圖片數(shù)據(jù)json


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});


tap

配置點擊slider的事件回調(diào)

類型說明是否必須
Function點擊slider的事件回調(diào)


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ],
    "tap": function(e){console.log(e.data.index)}
});


slide

配置滑動slide的事件回調(diào)

類型說明是否必須
Function滑動slider的事件回調(diào)


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ],
    "slide": function(e){console.log(e.data.index)}
});


hasIndicator

是否添加頁面指示,可以以圓點的方式展現(xiàn)有多少個圖片頁面,可以指示當前頁面在整個頁面的順序。

類型說明是否必須
Boolean是否添加頁面指示,默認值?


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ],
    "hasIndicator": true
});


inactiveColor

配置非選中狀態(tài)的指示圓點圖標的顏色

類型說明是否必須
String非選中狀態(tài)的指示圓點圖標的顏色RGB值


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ],
    "hasIndicator": true,
    "inactiveColor": "#888888"
});


activeColor

配置選中狀態(tài)的指示圓點圖標的顏色

類型說明是否必須
String選中狀態(tài)的指示圓點圖標的顏色RGB值


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ],
    "hasIndicator": true,
    "inactiveColor": "#888888",
    "activeColor": "#ff0000"
});


unitSize

配置頁面指示圓點圖標的尺寸

類型說明是否必須
Number頁面指示圓點圖標的尺寸(單位:像素),默認值10


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ],
    "hasIndicator": true,
    "unitSize": 6
});


unitSpace

配置頁面指示圓點圖標間的間距

類型說明是否必須
Number頁面指示圓點圖標間的間距(單位:像素),默認值5


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
      ],
    "hasIndicator": true,
    "inactiveColor": "#888888",
    "activeColor": "#ff0000",
    "unitSize": 6,
    "unitSpace": 3
});


Method

prev ( )

滾動到前一個圖片頁面


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});

slider.prev();


next ( )

滾動到下一個圖片頁面


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});

slider.next();


sliderTo (index)

滑動到第index個圖片頁面

參數(shù)類型說明是否必須
indexNumber滑動到第index個頁面


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});

slider.sliderTo(0);


destroy ( )

銷毀slider


實例:

var slider = new Blend.ui.Slider({
    "id": "slider",
    "images": [
        {"url":"http://*.com/old_07_02.jpg"},
        {"url":"http://*.com/old_09_02.jpg"}
     ]
});

slider.destroy();
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號