效果预览:
创新互联建站2013年开创至今,是专业互联网技术服务公司,拥有项目成都网站建设、网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元隆回做网站,已为上家服务,为隆回各地企业和个人服务,联系电话:18982081108
在线预览:传送门
时间练利用两个时间之间的差别与整个时间轴的长度运算得来
- locateHandler = function () {
- var referTime = (that[that.length] - that[0]) / 86400000, i = 0, len = that.handler.length, temp = 0;
- for (; i < len;) {
- temp = ((that[i] - that[0]) / (referTime * 86400000)) * that.parent.offsetWidth;
- that.fx(that.handler[i], 'left', ((i === len - 1 || i === 0) ? temp - 20 : temp), 50);
- i++;
- }
为了减少计算次数,用户操作时把图文面板,时间点,还有时间的位置信息都储存起来,这样在用户操作时计算并储存,第二次操作时读取缓存的位置信息。直接用css设置位置减少运算量
cache = [[],[],[]] |
初始化时只有一组信息
触摸了2个时间点以后,位置数据已经被缓存起来了
- if (!indicator.cache[1][index]) {
- if ((rect.left - div.offsetWidth / 2) < limit.left) {
- indicator.cache[1][index] = 'visibility:visible;left:0px;';
- } else if ((rect.left + div.offsetWidth / 2) > limit.right) {
- indicator.cache[1][index] = 'visibility:visible;left:' + (limit.right - div.offsetWidth - limit.left) + 'px;';
- } else {
- indicator.cache[1][index] = 'visibility:visible;left:' + (rect.left - div.offsetWidth / 2 - limit.left) + 'px;';
- }
- }
图文面板的位置也是经过智能计算获取,如果超出左边则左对齐,其他情况则以时间点位参考居中,右边超出亦然
动画使用了tween的一些算法 可以自己修改。
当前名称:很棒的时间线ui控件(纯javascript)
文章来源:http://www.shufengxianlan.com/qtweb/news47/131297.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联