左滑菜单(删除、置顶)

news/2024/7/7 14:33:52 标签: 区块链
<div class="xinzhibox">
        <div class="list">
            <div class="xinzhilist" tapmode  onclick="openlist('数字化商业')">
                <div class="imgbox">
                    <img src="../image/news/img.png" alt="" />
                    <div class="dian red"></div>
                </div>
                <div class="xinzhilistright">
                    <p>数字化商业</p>
                    <span>CIGI:央行区块链联盟是G20国,央行区块链联盟是G20国,央行区块链联盟是G20国</span>
                </div>
                <div class="zhiding"></div>
            </div>
            <div class="right">
                <div tapmode class="top_btn">取消置顶</div>
                    <div tapmode class="del_btn">取消订阅</div>
                </div>
            </div>
                
            <div class="list">
                <div class="xinzhilist" tapmode  onclick="openlist('数字化商业')">
                    <div class="imgbox">
                    <img src="../image/news/img.png" alt="" />
                    <div class="dian red"></div>
                        </div>
                        <div class="xinzhilistright">
                            <p>数字化商业</p>
                            <span>CIGI:央行区块链联盟是G20国,央行区块链联盟是G20国,央行区块链联盟是G20国</span>
                        </div>
                        <div class="zhiding"></div>
                    </div>
                    <div class="right">
                        <div tapmode class="top_btn">取消置顶</div>
                        <div tapmode class="del_btn">取消订阅</div>
                    </div>
                </div>
                
                <div class="list">
                    <div class="xinzhilist" tapmode  onclick="openlist('数字化商业')">
                        <div class="imgbox">
                            <img src="../image/news/img.png" alt="" />
                            <div class="dian red"></div>
                        </div>
                        <div class="xinzhilistright">
                            <p>数字化商业</p>
                            <span>CIGI:央行区块链联盟是G20国,央行区块链联盟是G20国,央行区块链联盟是G20国</span>
                        </div>
                    </div>
                    <div class="right">
                        <div tapmode class="top_btn">置顶</div>
                        <div tapmode class="del_btn">取消订阅</div>
                    </div>
                </div>-->
            
        </div>

html

 

function addListenFn() {
        /*左滑移除*/
    
        //设置要滑动的距离
        var slideWidth;
        // 获取所有行,对每一行设置监听
        var lines = $(".xinzhilist");
        var linesParent = $(".list");
        var len = lines.length;
        var lastXForMobile;
        // 用于记录被按下的对象
        var pressedObj;
        // 当前左滑的对象
        var lastLeftObj;
        // 上一个左滑的对象
        // 用于记录按下的点
        var start;
        // 监听
        linesParent.delegate(".xinzhilist", "touchstart", function(e) {
            lastXForMobile = event.changedTouches[0].pageX;
            pressedObj = this;
            slideWidth = $(pressedObj).parent().find('.right').width();
            // 记录被按下的对象
            // 记录开始按下时的点
            var touches = event.touches[0];
            start = {
                x : touches.pageX, // 横坐标
                y : touches.pageY // 纵坐标
            };
        });
        linesParent.delegate(".xinzhilist", "touchmove", function(e) {
            // 计算划动过程中x和y的变化量
            var touches = event.touches[0];
            delta = {
                x : touches.pageX - start.x,
                y : touches.pageY - start.y
            };
            // 横向位移大于纵向位移,阻止纵向滚动
            if (Math.abs(delta.x) > Math.abs(delta.y)) {
                event.preventDefault();
            }
        });
        linesParent.delegate(".xinzhilist", "touchend", function(e) {
            if (lastLeftObj && pressedObj != lastLeftObj) {// 点击除当前左滑对象之外的任意其他位置
                $(lastLeftObj).animate({
                    marginLeft : 0
                }, 300);
                // 右滑
                lastLeftObj = null;
                // 清空上一个左滑的对象
            }
            var diffX = event.changedTouches[0].pageX - lastXForMobile;
            if (diffX < -60) {
                $(pressedObj).animate({
                    marginLeft : -slideWidth + "px"
                }, 300);
                // 左滑
                lastLeftObj && lastLeftObj != pressedObj && $(lastLeftObj).animate({
                    marginLeft : 0
                }, 300);
                // 已经左滑状态的按钮右滑
                lastLeftObj = pressedObj;
                // 记录上一个左滑的对象
            } else if (diffX > 60) {
                if (pressedObj == lastLeftObj) {
                    $(pressedObj).animate({
                        marginLeft :  0
                    }, 300);
                    // 右滑
                    lastLeftObj = null;
                    // 清空上一个左滑的对象
                }
            }
        });
    }    

js

转载于:https://www.cnblogs.com/wubaba/p/6844523.html


http://www.niftyadmin.cn/n/719907.html

相关文章

Mybatis-原生Mybatis原理源码分析篇

Mybatis框架概述 Mybatis是持久层的框架&#xff0c;它内部封装了jdbc&#xff0c;使开发的时候只需要关注sql语句本身&#xff0c;不需要话费精力去处理加载驱动、创建连接、创建statement等。下面我们也是通过一个实例来对它进行分析。 首先编写一个SqlMapConfig.xml ​ …

灰度图像双边滤波代码

function B bfltGray(A,w,sigma_d,sigma_r) % Pre-compute Gaussian distance weights. [X,Y] meshgrid(-w:w,-w:w); G exp(-(X.^2Y.^2)/(2*sigma_d^2));% Apply bilateral filter. dim size(A); B zeros(dim); for i 1:dim(1)for j 1:dim(2)%这里的处理方式采用批方式&…

C语言-编译运行程序

一、运行 Visual Studio x64 兼容工具命令提示(2010) 开始菜单-> 所有程序-> Microsoft Visual Studio 2010-> Visual Studio Tools-> Visual Studio x64 兼容工具命令提示(2010) 二、进入源文件目录f:cd F:\Users\MyProjects\C\firstProg 三、使用 cl 命令编译源码…

Spring-IOC原理简述

今天的这个IOC&#xff0c;不打算分析源码了&#xff0c;一方面觉的Spring的源码很庞大&#xff0c;一步步跟的话容易陷入很深的某一个分支里&#xff0c;而且容易遗忘。所以打算简单的说下原理&#xff0c;大家可以先记下来简单的原理&#xff0c;然后再看看大佬们的博客&…

nyoj19 全排列

http://acm.nyist.net/JudgeOnline/status.php?pid19 1 #include<stdio.h>2 #include<stdlib.h>3 int n,a[10];4 bool vis[10];//标示数字是否被用过 5 void f(int k,int m)//k用来给a中第k个元素赋值&#xff0c;m表示还需要寻找的数字个数 6 {7 for(int i1;…

SpringBoot启动原理之核心注解和run()方法-源码分析

微信公众号&#xff1a;测试加油站 关注可了解更多的测试开发技术。问题或建议&#xff0c;请公众号留言; 如果你觉得文章对你有帮助&#xff0c;欢迎转发[^1] 随着微服务的兴起&#xff0c;SpringBoot框架越来越火&#xff0c;相信大部分公司已经开始转向使用这个框架&#xf…

第一阶段冲刺(第八天)

昨天&#xff1a;进行报表界面的设计 今天&#xff1a;对小组内的代码进行整合测试。 问题&#xff1a;代码整合时候出现版本不对应得问题&#xff0c;更改后解决问题。转载于:https://www.cnblogs.com/lhj1017/p/6847611.html

开源的数据可视化工具

Linux 上的数据可视化工具 5 种开放源码图形化工具简介 M. Tim Jones (mtjmtjones.com), 资深软件工程师, Emulex简介&#xff1a; Linux 上用来实现数据的图形可视化的应用程序有很多&#xff0c;从简单的 2-D 绘图到 3-D 制图&#xff0c;再到科学图形编程和图形模拟。幸运的…