使用鼠标滚轮或者手势滑动到页面节点部分

css部分:

    <style>
        .demo{width:300px; margin:60px auto 10px auto;text-align:center}
        @media only screen and (min-width: 420px) {
            .demo{width:500px; margin:60px auto 10px auto}
        }
        html, body, div, span, applet, object, iframe,
        h1, h2, h3, h4, h5, h6, p, blockquote, pre,
        a, abbr, acronym, address, big, cite, code,
        del, dfn, em, img, ins, kbd, q, s, samp,
        small, strike, strong, sub, sup, tt, var,
        b, u, i, center,
        dl, dt, dd, ol, ul, li,
        fieldset, form, label, legend,
        table, caption, tbody, tfoot, thead, tr, th, td,
        article, aside, canvas, details, embed,
        figure, figcaption, footer, header, hgroup,
        menu, nav, output, ruby, section, summary,
        time, mark, audio, video {
            margin: 0;
            padding: 0;
            border: 0;
            font-size: 100%;
            font: inherit;
            vertical-align: baseline;
        }
        /* HTML5 display-role reset for older browsers */
        article, aside, details, figcaption, figure,
        footer, header, hgroup, menu, nav, section {
            display: block;
        }
        body {
            line-height: 1;
        }
        ol, ul {
            list-style: none;
        }
        blockquote, q {
            quotes: none;
        }
        blockquote:before, blockquote:after,
        q:before, q:after {
            content: ‘‘;
            content: none;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }

        /****** Main ********/

        body {
            font-size:62.5%;
            font-family: "Microsoft Yahei", Tahoma, Helvetica, Arial, sans-serif;
            color:#FFF;
        }
        h1 {
            font-size:7em;
            padding:1.4em 0 0 0;
        }
        h2 {
            font-size:6em;
            padding:0.5em 0 0.5em 0;
        }
        h3 {
            font-size:2.3em;
        }
        dt {
            font-size:2.3em;
        }
        dd {
            font-size:1.9em;
            padding:0.6em 0 0.9em 0;
        }
        p {
            font-size:1.9em;
            padding:0.4em 0 0.4em 0;
        }
        a:link,
        a:visited {
            color:#FFF;
            text-decoration:none;
        }
        a:hover,
        a:focus,
        a:active {
            text-decoration:underline;
        }
        a.back:link,
        a.back:visited,
        a.twitter:link,
        a.twitter:visited {
            font-size:1.3em;
            line-height:4em;
            position:absolute;
            left:40px;
            bottom:25px;
        }
        a.back:link,
        a.back:visited {
            bottom:auto;
            top:0px;
        }
        a.twitter img {
            border-radius:50%;
            float:left;
            border:1px solid #bbb;
            padding:0.1em;
            background:#FFF;
        }
        a.twitter span {
            padding:0 0 0 0.6em;
        }
        header {
            padding-bottom:5em;
        }
        .scroll {
            position:relative;
            font-size:1.3em;
            margin-top:580px;
            display:inline-block;

        }
        .scroll:hover {
            text-decoration:none;
        }

        .scroll:after {
            content:‘‘;
            width:40px;
            height:40px;
            position:absolute;
            top:40px;
            margin:auto;
            top:50px;
            right:0;
            bottom:0;
            left:0;
            -webkit-animation:3s arrow infinite ease;
            animation:3s arrow infinite ease;
        }

        .scroll:after {
            border-right:2px solid #FFF;
            border-bottom:2px solid #FFF;
            -ms-transform:rotate(45deg);
            -webkit-transform:rotate(45deg);
            transform:rotate(45deg);

        }
        .tagline {

            font-size:2.3em;
            letter-spacing:0.02em;
            padding:0;
        }
        .tagline a{text-decoration:underline}
        .panel {
            height:100vh;
            border-bottom:1px solid #666;
        }
        .home {
            background: #65c2cf;
            background:hsl(184,65%,49%);
            text-align:center;
        }
        .overview {
            background:#e14456;
            background:hsl(350,92%,59%);

        }
        .configuration {
            background:#6dcb94;
            background:hsl(158,58%,52%);
        }
        .options {
            background:#ec8200;
            background:hsl(28,100%,52%);
        }
        .methods {
            background:#64a0d4;
            background:hsl(200,60%,55%);
        }
        .inner {
            width:960px;
            margin:0 auto;
        }
        pre {
            background:rgba(0,0,0,0.2);
            padding:2em 0 2em 0;
            font-size:2.1em;
            margin-top:0.7em;
        }
        @-webkit-keyframes arrow {
            0%,100% {
                top:50px;
            }
            50% {
                top:80px;
            }
        }
        @keyframes arrow {
            0%,100% {
                top:50px;
            }
            50% {
                top:80px;
            }
        }
        #carbonads {
            width:330px;
            margin:20px auto;
            font-size:1.3em;
            line-height:1.4;
            border:1px solid rgba(255,255,255,0.3);
            overflow: hidden;
            border-radius:8px;
            padding:10px 0 10px 10px;
        }
        #carbonads a {
            float:left;
            text-align: left;
        }
        #carbonads .carbon-text {
            width:180px;
        }
        #carbonads .carbon-poweredby {
            margin-top:7px;
        }
        #carbonads .carbon-text,
        #carbonads .carbon-poweredby {
            padding:0 9px;
        }
        @media (max-width:960px) {
            .inner {
                width:100%;

            }
            h1,h2,h3,p,pre,dl {
                margin-left:30px;
                margin-right:30px;
            }
        }
    </style>

html部分:

<!--[if lt IE 9]>
    <script src="../../../../js/html5shiv.min.js"></script>
    <![endif]-->
<section class="panel home"  data-section-name="home">
    <div class="inner">
        <header>
            <h1 class="company_bottom">SCROLLIFY</h1>
        </header>
        <a href="#overview" class="scroll"></a>

    </div>
</section>
<section class="panel overview"  data-section-name="overview">
    <div class="inner">
        <h2>基本使用</h2>
        <p>需要引入 jQuery 1.6+ 以及缓冲动画插件<a href="#" >jquery.easing.js</a>.</p>
                <pre>
    &lt;! doctype html&gt;
    &lt;html&gt;
        &lt;head&gt;
            &lt;script&gt;
                $(function() {
                    $.scrollify({
                        section : "section",
                    });
                });
            &lt;/script&gt;
        &lt;/head&gt;
        &lt;body&gt;
            &lt;section&gt;&lt;/section&gt;
            &lt;section&gt;&lt;/section&gt;
        &lt;/body&gt;
    &lt;/html&gt;
                </pre>

    </div>
</section>
<section class="panel configuration" data-section-name="configuration">
    <div class="inner">
        <h2>配置</h2>
                <pre>
    $.scrollify({
        section : "section",
        sectionName : "section-name",
        easing: "easeOutExpo",
        scrollSpeed: 1100,
        offset : 0,
        scrollbars: true,
        before:function() {},
        after:function() {}
    });
                </pre>
    </div>
</section>
<section class="panel options" data-section-name="options">
    <div class="inner">
        <h2>选项设置</h2>
        <dl>
            <dt>section</dt>
            <dd>节点部分选择器.</dd>
            <dt>sectionName</dt>
            <dd>每一个section节点对应的data属性.</dd>
            <dt>easing</dt>
            <dd>定义缓冲动画.</dd>
            <dt>offset</dt>
            <dd>定义每个色彩tion节点的偏移量.</dd>
            <dt>scrollbars</dt>
            <dd>是否显示滚动条.</dd>
            <dt>before</dt>
            <dd>回调函数,滚动开始前触发.</dd>
            <dt>after</dt>
            <dd>回调函数,滚动完成后触发.</dd>
        </dl>
    </div>
</section>
<section class="panel methods" data-section-name="methods">
    <div class="inner">
        <h2>方法</h2>
        <p>滑动到指定的节点。</p>
                <pre>
                $.scrollify("move","#name");
                </pre>
        <div style="text-algin:center;margin:10px auto"></div><br/>
    </div>
</section>

js部分:(此处需要引入jquery.js、easing.jsscrollify.js )

<script>

    $(function() {
        $(".panel").css({"height":$(window).height()});
        var timer;
        $(window).resize(function() {
            clearTimeout(timer);
            timer = setTimeout(function() {
                $(".panel").css({"height":$(window).height()});
            },40);
        });
        $.scrollify({
            section:".panel"
        });
        $(".scroll").click(function(e) {
            e.preventDefault();
            $.scrollify("move",$(this).attr("href"),easingeaseInOutBounce());

        });
    });
</script>
时间: 2024-08-03 06:16:39

使用鼠标滚轮或者手势滑动到页面节点部分的相关文章

基于jQuery鼠标滚轮滑动到页面节点部分

基于jQuery鼠标滚轮滑动到页面节点部分.这是一款基于jQuery+CSS3实现的使用鼠标滚轮或者手势滑动到页面节点部分特效.效果图如下: 在线预览   源码下载 实现的代码. html代码: <section class="panel home" data-section-name="home"> <div class="inner"> <header> <h1></h1> <

关于移动端手势滑动和上拉加载下拉刷新简单模拟笔记

本人接触前端不久,写的不好的请多多指教,欢迎指出 最近做到一个需求需要实现移动端的手势操作,在网上有找到不少不错的插件(PS:就不打广告了,一搜一大堆) 插件用起来确实不错,不过自己想研究下,便写了一个demo,实现了上拉.下拉触发,及左右手势滑动触发 上拉.下拉触发用了 $(window).scroll()                //当滚动条滚动时触发 scrollTop()(滚动条距离顶部的高度) $(document).height(当前页面的总高度) $(this).height

鼠标滚轮(mousewheel)和DOMMouseScroll事件

IE6.0首先实现了mousewheel事件.此后,Opera.Chrome和Safari也都实现了这个事件.当用户通过鼠标滚轮与页面交互.在垂直方向上滚动页面时(无论向下还是向上),就会触发mousewheel事件.这个事件可以在任何元素上面触发,最终会冒泡到document(IE)或window(Opera.Chrome.及Safari)对象.与mousewheel事件对应的event对象包含鼠标事件的所有标准信息之外,还包含一个特殊的wheelDelta属性.当用于向前滚动鼠标滚轮是,wh

iOS之手势滑动返回功能-b

iOS中如果不自定义UINavigationBar,通过手势向右滑是可以实现返回的,这时左边的标题文字提示的是上一个ViewController的标题,如果需要把文字改为简约风格,例如弄过箭头返回啥的,那么你需要自定义UINavigationBar,但当你自定义navigationBar后,这个功能就会自动失效. 屏蔽右滑返回功能代码:   if ([self.navigationController respondsToSelector:@selector(interactivePopGest

手势滑动结束 Activity(一)基本功能的实现

喜欢听音乐的朋友可能都看过天天动听这款 app, 这款 app 有一个亮点就是在切换页面(Fragment)的时候可以通过手势滑动来结束当前页面,这里先说一下,我为什么会这么关心这个功能呢,因为前两天 PM说我们即将开始做的这款app 也要实现页面能通过手势滑动来结束的功能,所以我就拿着这款 app 滑了一上午:但是我要实现的跟天天动听这款 app又有点不同,细心观察的朋友可能会发现,天天动听是 Fragment 之间的切换,而我这里要实现的是 Activity 之间的切换,不过,不管是哪种,最

鼠标滚轮实现图片的缩放-------Day79

今天是7月的最后一天了,不得不说,我定下的七月份剩余几天的计划是完不成了,一则工作确实紧了些,再则没能处理好生活.工作和学习的节奏,这才是人生最大的课题吧,不过也还好,至少自己还在坚持着,其实真的越来越感觉到自己的不足,可昂扬的斗志却是越来越低沉的迹象,内心里总有个声音在蛊惑自己:别整那些刻意的东西,做给谁看啊,而且刻意的记录的时间完全可以拿来学更多的东西,可最终我还在这个蛊惑前坚持着:确实可以腾出更多的时间来,也没人会在意在做什么,可是,同样,我不需要走那么快,而且只要知道自己在意就好了,我需

笔记本触摸板实现鼠标滚轮功能---Synpatics 定点装置

Synpatics定点装置,它是笔记本触摸板的驱动,把它稍微设置一下就基本可以用触摸板代替鼠标,以下是网上的介绍: Synaptics获2014消费电子展"创新设计与工程奖" 11月25日消息,人机界面解决方案的领先开发商Synaptics公司(纳斯达克代码:SYNA)今天宣布,凭借ClickPad 2.0技术,公司已被提名为2014年度国际消费电子展“创新设计与工程奖”获得者.Synaptics ClickPad 2.0是当今市场上最先进的电容式传感笔记本电脑触摸板技术,集成了一种特

鼠标滚轮事件MouseWheel

其实在大多数浏览器(IE6, IE7, IE8, Opera 10+, Safari 5+,Chrome)中,都提供了 "mousewheel" 事件.但杯具的是 Firefox 却不支持此事件,不过庆幸 Firefox  中提供了另外一个等同的事件:"DOMMouseScroll" . OK,我们现在已经知道了不同浏览器之间实现的差别,兼容代码如下: var addEvent = (function () { if (window.addEventListener

Android-通过SlidingPaneLayout高仿微信6.2最新版手势滑动返回(一)

最近更新了微信版本到6.2,发现里面有个非常好的体验,就是在第二个页面Activity能手势向右滑动返回,在手势滑动的过程中能看到第一个页面,这种体验非常赞,这里高仿了一下.这里使用的是v4包里面的SlidingPaneLayout来手势滑动,在下一篇博文中将采用SlidingMenu来高仿,下面是SlidingPaneLayout高仿后的效果,效果还是蛮不错的. 最重要的是,每一个页面都是Activity,而非Fragment哦,使用Activity和正常的Activity一样 这里给出dem