如何编写脚本实现日历自动滚动功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计223个文字,预计阅读时间需要1分钟。
将代码简化如下:
javascript// 获取当前行位置var _nowLineTop=$('#now-line').offset().top;// 获取当前行位置_nowLineTop=$('#now-line').position().top;// 滚动到对应位置$('.sc-view.timed-scroll .sc-container-view').scrollTop(_nowLineTop);
//var _nowLineTop = $(".now-line").offset().top; //var _nowLineTop = $(".now-line").position().top; //$(".sc-view.timed-scroll > .sc-container-view").scrollTop(_nowLineTop); var _top = $(".sc-view.timed-scroll > .sc-container-view").offset().top; $(".sc-view.timed-scroll > .sc-container-view").scrollTop($(".now-line").position().top - _top); var _top = $(".sc-view.timed-scroll > .sc-container-view").offset().top; var _scrollTop = $(".now-line").position().top; $(".sc-view.timed-scroll > .sc-container-view").scrollTop(_scrollTop); console.info("scroll", _scrollTop); 插件自动滚动
// ==UserScript== // @name icloud 日历自动滚动 // @namespace tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author Topin // @match www.icloud.com/applications/calendar/current/zh-cn/index.html // @grant none // ==/UserScript== (function() { console.info("日历自动滚动-启用"); setInterval(function(){ var _scrollTop = $(".now-line").position().top; $(".sc-view.timed-scroll > .sc-container-view").scrollTop(_scrollTop - 33); console.info("scroll", _scrollTop); }, 1000*20); })();
本文共计223个文字,预计阅读时间需要1分钟。
将代码简化如下:
javascript// 获取当前行位置var _nowLineTop=$('#now-line').offset().top;// 获取当前行位置_nowLineTop=$('#now-line').position().top;// 滚动到对应位置$('.sc-view.timed-scroll .sc-container-view').scrollTop(_nowLineTop);
//var _nowLineTop = $(".now-line").offset().top; //var _nowLineTop = $(".now-line").position().top; //$(".sc-view.timed-scroll > .sc-container-view").scrollTop(_nowLineTop); var _top = $(".sc-view.timed-scroll > .sc-container-view").offset().top; $(".sc-view.timed-scroll > .sc-container-view").scrollTop($(".now-line").position().top - _top); var _top = $(".sc-view.timed-scroll > .sc-container-view").offset().top; var _scrollTop = $(".now-line").position().top; $(".sc-view.timed-scroll > .sc-container-view").scrollTop(_scrollTop); console.info("scroll", _scrollTop); 插件自动滚动
// ==UserScript== // @name icloud 日历自动滚动 // @namespace tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author Topin // @match www.icloud.com/applications/calendar/current/zh-cn/index.html // @grant none // ==/UserScript== (function() { console.info("日历自动滚动-启用"); setInterval(function(){ var _scrollTop = $(".now-line").position().top; $(".sc-view.timed-scroll > .sc-container-view").scrollTop(_scrollTop - 33); console.info("scroll", _scrollTop); }, 1000*20); })();

