zepto.js 中报错,其中链接的zepto模块有官网上的模块,并添加了touch、动画这几个但

问题描述

zepto.js 中报错,其中链接的zepto模块有官网上的模块,并添加了touch、动画这几个但
 <!DOCTYPE html><html><head>    <meta charset=""UTF-8"">    <meta name=""viewport"" content=""width=device-width initial-scale=1.0 user-scalable=no"">     <title>Document</title>    <style>        *{ margin: 0 auto;}        html{height:100%; margin: 0;padding: 0;}        body{width:100%;height:100%;margin:0;overflow:hidden; margin:0 auto;}        ul{width:100%;height:100%;margin:0;padding:0;overflow:hidden;position:relative;}        .clearfix:after { content:""."";display:block;height: 0; clear: both; visibility: hidden;}        .clearfix{ display: inline-block;}        .clearfix{ display:block;}        ul li{list-style:none;width:100%;height:100%;position:absolute;left:0;margin:0;}        .on{z-index:999;}    </style></head><body>    <ul touchDir=""1"" class=""clearfix"">        <li class=""sty"" style=""background:#f1076a; display:block;""></li>        <li class=""sty"" style=""background:#1f6ee5; display:none;""></li>        <li class=""sty"" style=""background:#ef6767;display:none;""></li>        <li class=""sty"" style=""background:#5ef6e9;display:none;""></li>        <li class=""sty"" style=""background:#2da00e;display:none;""></li>    </ul></body><script type=""text/javascript"" src=""zepto/zep.js""></script>    <script type=""text/javascript"" src=""zepto/touch.js""></script>    <script type=""text/javascript"" src=""zepto/an.js""></script><script type=""text/javascript"">    $(function(){        var touchDir=$('ul').touchDir        var listBox=$('ul li');        var boxWidth=$('ul').eq(0).width();        var boxHeight=$('ul').eq(0).height();               function NextPage(){                alert(0)                console.log('test');            // if(listBox.is(':animated')){return;}            if(touchDir===""1""){                if($(this).index()===-1){return;}                    $(this).next().addClass('on').siblings().removeClass('on');                    $(this).next().animate({top:0}500function(){                            $(this).position().top=-boxHeight+'px';                            $(this).hide();                    })            }        }               function PrevPage(){                // if(listBox.is(':animated')){return;}                if(touchDir===""1""){                         if($(this).index()===0){return;}                        $(this).prev().addClass('on').show().siblings().removeClass('on');                        $(this).animate({top:boxHeight}500function(){                            $(this).hide();                        })                        $(this).prev().animate({top:0}500);                }           }                listBox.bind(""swipeUp""NextPage());         listBox.bind(""swipeDown""PrevPage());    })</script></html>

解决方案

<!DOCTYPE html>

Document
<br> *{ margin:0 auto;}<br> html{height:100%; margin: 0;padding: 0;}<br> body{width:100%;height:100%;margin:0;overflow:hidden; margin:0 auto;}<br> ul{width:100%;height:100%;margin:0;padding:0;overflow:hidden;position:relative;}<br> .clearfix:after { content:&quot;.&quot;;display:block;height: 0; clear: both; visibility: hidden;}<br> .clearfix{ display: inline-block;}<br> .clearfix{ display:block;}<br> ul li{list-style:none;width:100%;height:100%;position:absolute;left:0;margin:0;}<br> .on{z-index:999;}<br>

<script type=""text/javascript"" src=""zepto/touch.js""></script><script type=""text/javascript"" src=""zepto/an.js""></script>

$(function(){ var touchDir=$('ul').touchDir var listBox=$('ul li'); var boxWidth=$('ul').eq(0).width(); var boxHeight=$('ul').eq(0).height(); function NextPage(){ alert(0) console.log('test'); // if(listBox.is(':animated')){return;} if(touchDir===""1""){ if($(this).index()===-1){return;} $(this).next().addClass('on').siblings().removeClass('on'); $(this).next().animate({top:0}500function(){ $(this).position().top=-boxHeight+'px'; $(this).hide(); }) } } function PrevPage(){ // if(listBox.is(':animated')){return;} if(touchDir===""1""){ if($(this).index()===0){return;} $(this).prev().addClass('on').show().siblings().removeClass('on'); $(this).animate({top:boxHeight}500function(){ $(this).hide(); }) $(this).prev().animate({top:0}500); } } listBox.bind(""swipeUp""NextPage()); listBox.bind(""swipeDown""PrevPage()); })

时间: 2024-08-22 16:10:03

zepto.js 中报错,其中链接的zepto模块有官网上的模块,并添加了touch、动画这几个但的相关文章

zepto.js判断元素的可见性并显示或隐藏

最近在做移动端的项目,所以多的使用'轻量级zepto.js,现在的问题是,我需要显示-隐藏一个div,一般是判断此div是否是可见的,再显示或隐藏,测试一个页面上的是可见的还是不可见的,一般使用$('div).is(:visible), 然而zepto.js不支持:visible, 所以,必须换种方式判断: (1)可以检查显示器的CSS属性:css("display") == "block" (2)可以检查可见:可见/隐藏:css("visibility&

jQuery插件zepto.js简单实现tab切换

这篇文章主要介绍了jQuery插件zepto.js简单实现tab切换的代码,十分的简洁,有需要的小伙伴可以参考下 老规矩,先贴代码 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <script> $(function(){ window.onload = function() { var $li = $('.taocan-title li'); var $ul = $('.taocan-content .con110');   $li.mouse

基于zepto.js实现仿手机QQ空间的大图查看组件ImageView.js详解

 这篇文章主要介绍了基于zepto.js实现仿手机QQ空间的大图查看组件ImageView.js的源码和使用方法,并附上一个使用ImageView.js的实例,这里分享给大家,有需要的小伙伴参考下.     调用方式 :ImageView(index,imgData) --index参数 为图片默认显示的索引值,类型 为Number --imaData参数 为图片url数组 ,类型为Array 使用之前要先引入 zepto.js 文件 ImageView.js具体代码如下:   代码如下: /*

zepto.js中tap事件阻止冒泡的实现方法

 这篇文章主要介绍了zepto.js中tap事件阻止冒泡的实现方法,实例分析了由冒泡产生的click延迟解决方法,需要的朋友可以参考下     本文实例讲述了zepto.js中tap事件阻止冒泡的实现方法.分享给大家供大家参考.具体如下: 最近在弄一个手机版的网站,本来想用jQuery Mobile,但文件太大了,所以用了zepto.js 由于移动网页中使用click事件会有延迟,所以就用上了zepto.js中的tap事件. 使用click事件可以使用stopPropagation来阻止冒泡,但

jQuery插件zepto.js简单实现tab切换_jquery

老规矩,先贴代码 <script> $(function(){ window.onload = function() { var $li = $('.taocan-title li'); var $ul = $('.taocan-content .con110'); $li.mouseover(function(){ var $this = $(this); var $t = $this.index(); $li.removeClass(); $this.addClass('active');

使用jsonp完成跨域请求,但是请求的链接是js文件,请求总是那个js报错,怎莫办?

问题描述 使用jsonp完成跨域请求,但是请求的链接是js文件,请求总是那个js报错,怎莫办? 把链接换成php就没问题. $.ajax({ type:'GET', async:false, url:"http://app.veishu.com/jsonp/categories/all.js", dataType:"jsonp", success:function(data){ alert("success"); // alert(data[0]

scroll事件实现监控滚动条并分页显示(zepto.js)_javascript技巧

需求:在APP落地页上的底部位置显示此前其他用户的购买记录,要求此div盒子只显示3条半,但一页有10条,div内的滑动条滑到一页底部自动加载下一页并发加载埋点. 实现:首先理解三个概念,分别是contentH,viewH,scrollTop. contentH:即所要滑动的元素内容的高度,包括可见部分以及滚动条下面的不可见部分. ViewH:即我们看到的这个DIV的高度,不包括可见部分也不包括滚动条下面的不可见部分. scrollTop:即滚动条距离顶部的距离,若scrollTop的值为0,则

基于touch.js手势库+zepto.js插件开发图片查看器(滑动、缩放、双击缩放)_javascript技巧

最近由于公司项目需要图片查看器,网上搜了一圈,感觉资料很少,所以决定基于百度的touch.js手势库+zepto.js自己写了一个小插件,实现了左右滑动,双指缩放,双击缩放功能,基本使用还行,但是有时候还是不太顺畅,后续会慢慢完善:写的不好的地方望各位能够给出好的建议,谢谢! 源码地址:https://github.com/GLwen/molong_photoSwipe.git 演示:http://runjs.cn/detail/iceaaogh molong.css *{padding:0;m

基于zepto.js实现仿手机QQ空间的大图查看组件ImageView.js详解_javascript技巧

调用方式 :ImageView(index,imgData)  --index参数 为图片默认显示的索引值,类型 为Number  --imaData参数 为图片url数组 ,类型为Array 使用之前要先引入 zepto.js 文件 ImageView.js具体代码如下: 复制代码 代码如下: /*  * ImageView v1.0.0  * --基于zepto.js的大图查看  * --调用方法 ImageView(index,imgDada)  * --index 图片默认值显示索引,N