配置所需參數(shù)來初始化一個幻燈片組件Slider
Slider的配置格式如下:
var slider = new Blend.ui.Slider({"options":"values"});
Slider包含以下配置項:
類型 | 說明 | 是否必須 |
---|---|---|
String | slider的id | 否 |
實例:
var slider = new Blend.ui.Slider({
"id": "slider",
"images": [
{"url":"http://*.com/old_07_02.jpg"},
{"url":"http://*.com/old_09_02.jpg"}
]
});
類型 | 說明 | 是否必須 |
---|---|---|
Number | slider距離屏幕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"}
]
});
類型 | 說明 | 是否必須 |
---|---|---|
Number | slider距離屏幕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"}
]
});
類型 | 說明 | 是否必須 |
---|---|---|
Number | slider像素寬度,默認為屏幕寬度 | 否 |
實例:
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"}
]
});
類型 | 說明 | 是否必須 |
---|---|---|
Number | slider像素高度,默認為屏幕高度 | 否 |
實例:
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"}
]
});
類型 | 說明 | 是否必須 |
---|---|---|
String | slider背景顏色,默認透明 | 否 |
實例:
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"}
]
});
類型 | 說明 | 是否必須 |
---|---|---|
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"}
]
});
類型 | 說明 | 是否必須 |
---|---|---|
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)}
});
類型 | 說明 | 是否必須 |
---|---|---|
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)}
});
類型 | 說明 | 是否必須 |
---|---|---|
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
});
類型 | 說明 | 是否必須 |
---|---|---|
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"
});
類型 | 說明 | 是否必須 |
---|---|---|
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"
});
類型 | 說明 | 是否必須 |
---|---|---|
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
});
類型 | 說明 | 是否必須 |
---|---|---|
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
});
實例:
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();
實例:
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();
參數(shù) | 類型 | 說明 | 是否必須 |
---|---|---|---|
index | Number | 滑動到第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);
實例:
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();
更多建議: