最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js實現(xiàn)單行文本向上滾動效果實例代碼

 更新時間:2013年11月28日 10:07:29   作者:  
這篇文章主要介紹了js實現(xiàn)單行文本向上滾動效果,大家參考使用吧

復(fù)制代碼 代碼如下:

/***************滾動場次開始*****************/

function ScrollText(content, btnPrevious, btnNext, autoStart) {
    this.Delay = 10;
    this.LineHeight = 20;
    this.Amount = 1;
    this.Direction = "up";
    this.Timeout = 1500;
    this.ScrollContent = this.$(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
    //this.ScrollContent.scrollTop = 0;
    if (btnNext) {
        this.NextButton = this.$(btnNext);
        this.NextButton.onclick = this.GetFunction(this, "Next");
        this.NextButton.onmouseover = this.GetFunction(this, "Stop");
        this.NextButton.onmouseout = this.GetFunction(this, "Start");
    }
    if (btnPrevious) {
        this.PreviousButton = this.$(btnPrevious);
        this.PreviousButton.onclick = this.GetFunction(this, "Previous");
        this.PreviousButton.onmouseover = this.GetFunction(this, "Stop");
        this.PreviousButton.onmouseout = this.GetFunction(this, "Start");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this, "Stop");
    this.ScrollContent.onmouseout = this.GetFunction(this, "Start");
    if (autoStart) {
        this.Start();
    }
}

ScrollText.prototype.$ = function (element) {
    return document.getElementById(element);
}

ScrollText.prototype.Previous = function () {
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("up");
}

ScrollText.prototype.Next = function () {
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("down");
}

ScrollText.prototype.Start = function () {
    clearTimeout(this.AutoScrollTimer);
    this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
}

ScrollText.prototype.Stop = function () {
    clearTimeout(this.ScrollTimer);
    clearTimeout(this.AutoScrollTimer);
}

ScrollText.prototype.AutoScroll = function () {
    if (this.Direction == "up") {
        if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
            this.ScrollContent.scrollTop = 0;
        }
        this.ScrollContent.scrollTop += this.Amount;
    } else {
        if (parseInt(this.ScrollContent.scrollTop) <= 0) {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
        this.ScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Delay);
    } else {
        this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"), this.Timeout);
    }
}

ScrollText.prototype.Scroll = function (direction) {
    if (direction == "up") {
        if (this.ScrollContent.scrollTop == 0) {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    } else {
        this.ScrollContent.scrollTop += this.Amount;
    }
    if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
        this.ScrollContent.scrollTop = 0;
    }
    if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
        this.ScrollTimer = setTimeout(this.GetFunction(this, "Scroll", direction), this.Delay);
    }
}

ScrollText.prototype.GetFunction = function (variable, method, param) {
    return function () {
        variable[method](param);
    }
}

if (document.getElementById("ul_round")) {
    var scrollup = new ScrollText("ul_round");
    scrollup.LineHeight = 40;        //單排文字滾動的高度
    scrollup.Amount = 1;            //注意:子模塊(LineHeight)一定要能整除Amount.
    scrollup.Delay = 30;           //延時
    scrollup.Start();             //文字自動滾動
    scrollup.Direction = "up";   //默認設(shè)置為文字向上滾動
}
/***************滾動場次結(jié)束*****************/

相關(guān)文章

  • JS給Textarea文本框添加行號的方法

    JS給Textarea文本框添加行號的方法

    這篇文章主要介紹了JS給Textarea文本框添加行號的方法,涉及javascript針對頁面元素結(jié)點的讀取與判定技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-08-08
  • js求數(shù)組最大值的八種具體實現(xiàn)方法

    js求數(shù)組最大值的八種具體實現(xiàn)方法

    數(shù)組如何求最大值,想必很多的朋友都不會吧,下面這篇文章主要給大家介紹了關(guān)于使用js求數(shù)組最大值的八種方法具體實現(xiàn)的相關(guān)資料,文中給出了詳細的代碼示例,需要的朋友可以參考下
    2023-09-09
  • JS猜數(shù)字游戲?qū)嵗v解

    JS猜數(shù)字游戲?qū)嵗v解

    這篇文章主要為大家詳細介紹了JS猜數(shù)字游戲?qū)嵗?,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-06-06
  • js獲取指定時間的前幾秒

    js獲取指定時間的前幾秒

    本文主要介紹了根據(jù)一張圖片的拍攝時間獲取到這個時間前二后三的一個五秒鐘的視頻信息的實例方法。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-04-04
  • JS庫之Three.js 簡易入門教程(詳解之一)

    JS庫之Three.js 簡易入門教程(詳解之一)

    three.js是一款webGL框架,由于其易用性被廣泛應(yīng)用。下面腳本之家小編通過案例給大家闡述three.js的基本配置方法,具體內(nèi)容詳情大家參考下本文吧
    2017-09-09
  • javascript移動設(shè)備Web開發(fā)中對touch事件的封裝實例

    javascript移動設(shè)備Web開發(fā)中對touch事件的封裝實例

    這篇文章主要介紹了javascript移動設(shè)備Web開發(fā)中對touch事件的封裝實例,分別對tap事件、doubleTap事件、longTap事件、swipe事件做了封裝,需要的朋友可以參考下
    2014-06-06
  • Echart結(jié)合圓形實現(xiàn)儀表盤的繪制詳解

    Echart結(jié)合圓形實現(xiàn)儀表盤的繪制詳解

    EChart開源來自百度商業(yè)前端數(shù)據(jù)可視化團隊,基于html5?Canvas,是一個純Javascript圖表庫,提供直觀,生動,可交互,可個性化定制的數(shù)據(jù)可視化圖表。本文將利用EChart實現(xiàn)儀表盤的繪制,感興趣的可以學(xué)習(xí)一下
    2022-03-03
  • canvas繪制環(huán)形進度條

    canvas繪制環(huán)形進度條

    本文主要介紹了canvas繪制環(huán)形進度條的示例代碼,具有很好的參考價值,下面跟著小編一起來看下吧
    2017-02-02
  • 使用JavaScript監(jiān)視有沒有被刷新后跳轉(zhuǎn)其他頁面

    使用JavaScript監(jiān)視有沒有被刷新后跳轉(zhuǎn)其他頁面

    這篇文章主要為大家詳細介紹了如何使用JavaScript監(jiān)視有沒有被刷新后跳轉(zhuǎn)其他頁面,文中的示例代碼講解詳細,感興趣的小伙伴可以參考一下
    2025-01-01
  • JavaScript可折疊區(qū)域?qū)崿F(xiàn)代碼

    JavaScript可折疊區(qū)域?qū)崿F(xiàn)代碼

    可折疊區(qū)域的基本思想:通過點擊某個地方來顯示或隱藏屏幕中的某個區(qū)域。
    2010-10-10

最新評論

五寨县| 屏山县| 丽水市| 新巴尔虎左旗| 水城县| 双牌县| 睢宁县| 孝感市| 镇赉县| 金平| 青海省| 泗水县| 抚远县| 伊川县| 伊春市| 邓州市| 固安县| 泸溪县| 莱阳市| 沧源| 灵寿县| 肃宁县| 大连市| 霍州市| 油尖旺区| 乐平市| 莱州市| 漳平市| 济南市| 陵水| 密云县| 定陶县| 九龙坡区| 安吉县| 乌海市| 策勒县| 武夷山市| 芜湖县| 乡宁县| 色达县| 图们市|