自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

很棒的時間線ui控件(純javascript)

開發(fā) 前端
為了減少計算次數(shù),用戶操作時把圖文面板,時間點,還有時間的位置信息都儲存起來,這樣在用戶操作時計算并儲存,第二次操作時讀取緩存的位置信息。

效果預(yù)覽:

在線預(yù)覽:傳送門

時間練利用兩個時間之間的差別與整個時間軸的長度運算得來

  1. locateHandler = function () {   
  2.         var referTime = (that[that.length] - that[0]) / 86400000, i = 0, len = that.handler.length, temp = 0;   
  3.         for (; i < len;) {   
  4.             temp = ((that[i] - that[0]) / (referTime * 86400000)) * that.parent.offsetWidth;   
  5.             that.fx(that.handler[i], 'left', ((i === len - 1 || i === 0) ? temp - 20 : temp), 50);   
  6.             i++;   
  7.         } 

為了減少計算次數(shù),用戶操作時把圖文面板,時間點,還有時間的位置信息都儲存起來,這樣在用戶操作時計算并儲存,第二次操作時讀取緩存的位置信息。直接用css設(shè)置位置減少運算量

cache = [[],[],[]]

初始化時只有一組信息

觸摸了2個時間點以后,位置數(shù)據(jù)已經(jīng)被緩存起來了

  1. if (!indicator.cache[1][index]) {   
  2.     if ((rect.left - div.offsetWidth / 2) < limit.left) {   
  3.         indicator.cache[1][index] = 'visibility:visible;left:0px;';   
  4.     } else if ((rect.left + div.offsetWidth / 2) > limit.right) {   
  5.                 indicator.cache[1][index] = 'visibility:visible;left:' + (limit.right - div.offsetWidth - limit.left) + 'px;';   
  6.     } else {   
  7.         indicator.cache[1][index] = 'visibility:visible;left:' + (rect.left - div.offsetWidth / 2 - limit.left) + 'px;';   
  8.     }   
  9.                 

圖文面板的位置也是經(jīng)過智能計算獲取,如果超出左邊則左對齊,其他情況則以時間點位參考居中,右邊超出亦然

動畫使用了tween的一些算法 可以自己修改。

原文鏈接:http://www.cnblogs.com/enix/archive/2012/06/27/2565568.html

【編輯推薦】

責(zé)任編輯:張偉 來源: 小玉西瓜的博客
相關(guān)推薦

2011-09-26 11:17:16

2021-07-24 13:40:25

谷歌Chrome瀏覽器

2015-08-26 13:49:06

可視化

2018-08-06 09:18:33

Windows操作系統(tǒng)Chrome

2022-03-09 12:45:15

時間線

2024-02-21 12:15:00

SoraOpenAI人工智能

2019-04-26 14:30:49

自動駕駛Uber特斯拉

2014-06-18 10:53:44

BootstrapBootstrap U

2019-11-18 14:50:29

開發(fā)技能代碼

2017-11-22 19:30:58

Windows時間線功能完整版

2020-12-31 07:56:02

JavaScript 字符串技巧

2024-04-01 08:48:38

Node.jsnpmNode

2021-04-15 21:57:49

Windows 10Windows微軟

2023-02-09 16:15:27

JavaScript編程語言字符串

2023-04-17 16:19:32

編程語言JavaScript開發(fā)

2021-01-19 12:16:10

CSS前端UI

2021-05-26 05:24:51

Windows10操作系統(tǒng)微軟

2020-03-08 13:24:47

JavaScript開發(fā)

2020-07-25 19:38:54

JavaScriptJavaScript庫Web

2023-11-27 16:01:59

JavaScrip技巧
點贊
收藏

51CTO技術(shù)棧公眾號