|
|
@@ -3,8 +3,7 @@
|
|
3
|
3
|
* 功能:鼠标移入标签,当前标签静止放大
|
|
4
|
4
|
* 说明:
|
|
5
|
5
|
* */
|
|
6
|
|
-
|
|
7
|
|
-window.tagcloud = (function(win, doc) { // ns
|
|
|
6
|
+var tagcloud = (function(win, doc) { // ns
|
|
8
|
7
|
// 判断对象
|
|
9
|
8
|
function isObject (obj) {
|
|
10
|
9
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
|
@@ -13,7 +12,6 @@ window.tagcloud = (function(win, doc) { // ns
|
|
13
|
12
|
// 构造函数
|
|
14
|
13
|
function TagCloud (options) {
|
|
15
|
14
|
var self = this;
|
|
16
|
|
-
|
|
17
|
15
|
self.config = TagCloud._getConfig(options);
|
|
18
|
16
|
self.box = self.config.element; //组件元素
|
|
19
|
17
|
self.fontsize = self.config.fontsize; //平均字体大小
|
|
|
@@ -25,11 +23,11 @@ window.tagcloud = (function(win, doc) { // ns
|
|
25
|
23
|
self.ispeed = TagCloud._getIsSpeed(self.config.ispeed);
|
|
26
|
24
|
self.items = self._getItems();
|
|
27
|
25
|
|
|
28
|
|
- self.direction = self.config.direction; //初始滚动方向
|
|
|
26
|
+ self.direction = self.config.direction; //初始滚动方向
|
|
29
|
27
|
self.keep = self.config.keep; //鼠标移出后是否保持之前滚动
|
|
30
|
28
|
|
|
31
|
29
|
//初始化
|
|
32
|
|
- self.active = false; //是否为激活状态
|
|
|
30
|
+ self.active = false; //是否为激活状态
|
|
33
|
31
|
self.lasta = 1;
|
|
34
|
32
|
self.lastb = 1;
|
|
35
|
33
|
self.mouseX0 = self.ispeed * Math.sin(self.direction * Math.PI / 180); //鼠标与滚动圆心x轴初始距离
|
|
|
@@ -72,6 +70,7 @@ window.tagcloud = (function(win, doc) { // ns
|
|
72
|
70
|
//定时更新
|
|
73
|
71
|
TagCloud.boxs.push(self.box);
|
|
74
|
72
|
self.update(self); //初始更新
|
|
|
73
|
+
|
|
75
|
74
|
self.box.style.visibility = "visible";
|
|
76
|
75
|
self.box.style.position = "relative";
|
|
77
|
76
|
self.box.style.minHeight = 1.2 * self.size + "px";
|
|
|
@@ -177,7 +176,6 @@ window.tagcloud = (function(win, doc) { // ns
|
|
177
|
176
|
|
|
178
|
177
|
update: function () {
|
|
179
|
178
|
var self = this, a, b;
|
|
180
|
|
-
|
|
181
|
179
|
if (!self.active && !self.keep) {
|
|
182
|
180
|
self.mouseX = Math.abs(self.mouseX - self.mouseX0) < 1 ? self.mouseX0 : (self.mouseX + self.mouseX0) / 2; //重置鼠标与滚动圆心x轴距离
|
|
183
|
181
|
self.mouseY = Math.abs(self.mouseY - self.mouseY0) < 1 ? self.mouseY0 : (self.mouseY + self.mouseY0) / 2; //重置鼠标与滚动圆心y轴距离
|
|
|
@@ -192,7 +190,7 @@ window.tagcloud = (function(win, doc) { // ns
|
|
192
|
190
|
self.lastb = b;
|
|
193
|
191
|
|
|
194
|
192
|
var sc = TagCloud._getSc(a, b);
|
|
195
|
|
-
|
|
|
193
|
+
|
|
196
|
194
|
for (var j = 0, len = self.items.length; j < len; j++) {
|
|
197
|
195
|
|
|
198
|
196
|
var rx1 = self.items[j].x,
|
|
|
@@ -220,7 +218,7 @@ window.tagcloud = (function(win, doc) { // ns
|
|
220
|
218
|
self.items[j].alpha = 1.5 * per - 0.5;
|
|
221
|
219
|
self.items[j].element.style.zIndex = Math.ceil(per*10-5);
|
|
222
|
220
|
}
|
|
223
|
|
- self.items[j].element.style.fontSize = self.items[j].fontsize + "px";
|
|
|
221
|
+ self.items[j].element.style.fontSize = self.items[j].fontsize + "px";
|
|
224
|
222
|
// self.items[j].element.style.left = self.items[j].x + (self.box.offsetWidth - self.items[j].offsetWidth) / 2 + "px";
|
|
225
|
223
|
self.items[j].element.style.left = self.items[j].x / 1.2+self.box.offsetWidth/2.3-40 + "px";
|
|
226
|
224
|
// self.items[j].element.style.top = self.items[j].y + (self.box.offsetHeight - self.items[j].offsetHeight) / 2 + "px";
|
|
|
@@ -288,10 +286,11 @@ window.tagcloud = (function(win, doc) { // ns
|
|
288
|
286
|
instance = [];
|
|
289
|
287
|
for (var index = 0, len = elements.length; index < len; index++) {
|
|
290
|
288
|
options.element = elements[index];
|
|
291
|
|
- if (!!TagCloud._set(options.element)) {
|
|
|
289
|
+// if (!!TagCloud._set(options.element)) {
|
|
292
|
290
|
instance.push(new TagCloud(options));
|
|
293
|
|
- }
|
|
|
291
|
+// }
|
|
294
|
292
|
}
|
|
|
293
|
+ console.log(instance);
|
|
295
|
294
|
return instance;
|
|
296
|
295
|
};
|
|
297
|
296
|
|