起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2040|回复: 8

[结贴] 请问如何实现淘宝首页中“淘宝头条”的向上滚动效果呢?

  [复制链接]

4

主题

16

帖子

32

积分

新手上路

Rank: 1

积分
32
QQ
发表于 2017-1-8 15:50:08 | 显示全部楼层 |阅读模式
请问如何实现淘宝首页中“淘宝头条”的向上滚动效果呢?
就是两行文章的题目不断向上滚动~~本人新手,希望能得到比较详细的解答~~
谢谢~



1

主题

6163

帖子

2095

积分

金牌会员

Rank: 6Rank: 6

积分
2095
QQ
发表于 2017-1-9 10:19:55 | 显示全部楼层
这样的功能目前平台是没有提供的  建议楼主到网上搜索相关的案例
网上有很多关于类似这样定义动画的案例
回复 支持 反对

使用道具 举报

4

主题

16

帖子

32

积分

新手上路

Rank: 1

积分
32
QQ
 楼主| 发表于 2017-1-9 10:53:15 | 显示全部楼层
半导体 发表于 2017-1-9 10:19
这样的功能目前平台是没有提供的  建议楼主到网上搜索相关的案例
网上有很多关于类似这样定义动画的案例 ...

谢谢版主回复~
有人说:
用了一个叫jquery.bootstrap.newsbox.js的插件!直接可以引入进来使用,页面上用list设置一下高度然后初始化一下就可以实现滚动了!
不是很懂啊,JS插件怎么直接引用啊,看了里面写的东西,和WEX5的JS语言好像不一样?
回复 支持 反对

使用道具 举报

4

主题

16

帖子

32

积分

新手上路

Rank: 1

积分
32
QQ
 楼主| 发表于 2017-1-9 10:54:04 | 显示全部楼层
/*
* jQuery Bootstrap News Box v1.0.1
*
* Copyright 2014, Dragan Mitrovic
* email: gagi270683@gmail.com
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
if (typeof Object.create !== "function") { Object.create = function (e) { function t() { } t.prototype = e; return new t } } (function (e, t, n, r) { var i = { init: function (t, n) { var r = this; r.elem = n; r.$elem = e(n); r.newsTagName = r.$elem.find(":first-child").prop("tagName"); r.newsClassName = r.$elem.find(":first-child").attr("class"); r.timer = null; r.resizeTimer = null; r.animationStarted = false; r.isHovered = false; if (typeof t === "string") { if (console) { console.error("String property override is not supported") } throw "String property override is not supported" } else { r.options = e.extend({}, e.fn.bootstrapNews.options, t); r.prepareLayout(); if (r.options.autoplay) { r.animate() } if (r.options.navigation) { r.buildNavigation() } if (typeof r.options.onToDo === "function") { r.options.onToDo.apply(r, arguments) } } }, prepareLayout: function () { var n = this; e(n.elem).find("." + n.newsClassName).on("mouseenter", function () { n.onReset(true) }); e(n.elem).find("." + n.newsClassName).on("mouseout", function () { n.onReset(false) }); e.map(n.$elem.find(n.newsTagName), function (t, r) { if (r > n.options.newsPerPage - 1) { e(t).hide() } else { e(t).show() } }); if (n.$elem.find(n.newsTagName).length < n.options.newsPerPage) { n.options.newsPerPage = n.$elem.find(n.newsTagName).length } var r = 0; e.map(n.$elem.find(n.newsTagName), function (t, i) { if (i < n.options.newsPerPage) { r = parseInt(r) + parseInt(e(t).height()) + 10 } }); e(n.elem).css({ "overflow-y": "hidden", height: r }); e(t).resize(function () { if (n.resizeTimer !== null) { clearTimeout(n.resizeTimer) } n.resizeTimer = setTimeout(function () { n.prepareLayout() }, 200) }) }, findPanelObject: function () { var e = this.$elem; while (e.parent() !== r) { e = e.parent(); if (e.parent().hasClass("panel")) { return e.parent() } } return r }, buildNavigation: function () { var t = this.findPanelObject(); if (t) { var n = '<ul class="pagination pull-right" style="margin: 0px;">' + '<li><a href="#" class="prev"><span class="glyphicon glyphicon-chevron-down"></span></a></li>' + '<li><a href="#" class="next"><span class="glyphicon glyphicon-chevron-up"></span></a></li>' + '</ul><div class="clearfix"></div>'; var r = e(t).find(".panel-footer")[0]; if (r) { e(r).append(n) } else { e(t).append('<div class="panel-footer">' + n + "</div>") } var i = this; e(t).find(".prev").on("click", function (e) { e.preventDefault(); i.onPrev() }); e(t).find(".next").on("click", function (e) { e.preventDefault(); i.onNext() }) } }, onStop: function () { }, onPause: function () { var e = this; e.isHovered = true; if (this.options.autoplay && e.timer) { clearTimeout(e.timer) } }, onReset: function (e) { var t = this; if (t.timer) { clearTimeout(t.timer) } if (t.options.autoplay) { t.isHovered = e; t.animate() } }, animate: function () { var e = this; e.timer = setTimeout(function () { if (!e.options.pauseOnHover) { e.isHovered = false } if (!e.isHovered) { if (e.options.direction === "up") { e.onNext() } else { e.onPrev() } } }, e.options.newsTickerInterval) }, onPrev: function () { var t = this; if (t.animationStarted) { return false } t.animationStarted = true; var n = "<" + t.newsTagName + ' style="display:none;" class="' + t.newsClassName + '">' + e(t.$elem).find(t.newsTagName).last().html() + "</" + t.newsTagName + ">"; e(t.$elem).prepend(n); e(t.$elem).find(t.newsTagName).first().slideDown(t.options.animationSpeed, function () { e(t.$elem).find(t.newsTagName).last().remove() }); e(t.$elem).find(t.newsTagName + ":nth-child(" + parseInt(t.options.newsPerPage + 1) + ")").slideUp(t.options.animationSpeed, function () { t.animationStarted = false; t.onReset(t.isHovered) }); e(t.elem).find("." + t.newsClassName).on("mouseenter", function () { t.onReset(true) }); e(t.elem).find("." + t.newsClassName).on("mouseout", function () { t.onReset(false) }) }, onNext: function () { var t = this; if (t.animationStarted) { return false } t.animationStarted = true; var n = "<" + t.newsTagName + ' style="display:none;" class=' + t.newsClassName + ">" + e(t.$elem).find(t.newsTagName).first().html() + "</" + t.newsTagName + ">"; e(t.$elem).append(n); e(t.$elem).find(t.newsTagName).first().slideUp(t.options.animationSpeed, function () { e(this).remove() }); e(t.$elem).find(t.newsTagName + ":nth-child(" + parseInt(t.options.newsPerPage + 1) + ")").slideDown(t.options.animationSpeed, function () { t.animationStarted = false; t.onReset(t.isHovered) }); e(t.elem).find("." + t.newsClassName).on("mouseenter", function () { t.onReset(true) }); e(t.elem).find("." + t.newsClassName).on("mouseout", function () { t.onReset(false) }) } }; e.fn.bootstrapNews = function (e) { return this.each(function () { var t = Object.create(i); t.init(e, this) }) }; e.fn.bootstrapNews.options = { newsPerPage: 4, navigation: true, autoplay: true, direction: "up", animationSpeed: "normal", newsTickerInterval: 4e3, pauseOnHover: true, onStop: null, onPause: null, onReset: null, onPrev: null, onNext: null, onToDo: null} })(jQuery, window, document)
回复 支持 反对

使用道具 举报

1

主题

6163

帖子

2095

积分

金牌会员

Rank: 6Rank: 6

积分
2095
QQ
发表于 2017-1-9 10:57:34 | 显示全部楼层
ttelva 发表于 2017-1-9 10:53
谢谢版主回复~
有人说:
用了一个叫jquery.bootstrap.newsbox.js的插件!直接可以引入进来使用,页面上用 ...

这个应该是个第三方js库吧   如果是的话直接require进来就可以了
这个你可以看一下平台集成第三方的这个
他就是按序加载的/UI2/third/bootstrap-datepicker
回复 支持 反对

使用道具 举报

4

主题

16

帖子

32

积分

新手上路

Rank: 1

积分
32
QQ
 楼主| 发表于 2017-1-9 11:32:21 | 显示全部楼层
半导体 发表于 2017-1-9 10:57
这个应该是个第三方js库吧   如果是的话直接require进来就可以了
这个你可以看一下平台集成第三方的这个
...

好的,谢谢版主,我试试看~好像看了教程没有教怎么require外部JS的
回复 支持 反对

使用道具 举报

1

主题

6163

帖子

2095

积分

金牌会员

Rank: 6Rank: 6

积分
2095
QQ
发表于 2017-1-9 11:39:58 | 显示全部楼层
ttelva 发表于 2017-1-9 11:32
好的,谢谢版主,我试试看~好像看了教程没有教怎么require外部JS的

我不是给你提供案例了吗  你参考那个就可以了
回复 支持 反对

使用道具 举报

75

主题

356

帖子

502

积分

高级会员

Rank: 4

积分
502
QQ
发表于 2017-3-4 16:19:47 | 显示全部楼层
ttelva 发表于 2017-1-9 11:32
好的,谢谢版主,我试试看~好像看了教程没有教怎么require外部JS的

楼主 实现了没有,求分享啊
回复 支持 反对

使用道具 举报

8

主题

49

帖子

127

积分

初级会员

Rank: 2

积分
127
QQ
发表于 2017-3-15 11:33:10 | 显示全部楼层
这功能我实现过,太简单了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2025-7-4 04:11 , Processed in 0.054870 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表