Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在手机上使用touch向左和向右制作此幻灯片?_Javascript_Html_Css_Touch_Responsive - Fatal编程技术网

Javascript 如何在手机上使用touch向左和向右制作此幻灯片?

Javascript 如何在手机上使用touch向左和向右制作此幻灯片?,javascript,html,css,touch,responsive,Javascript,Html,Css,Touch,Responsive,我想添加javascript/css/任何需要的东西,这样我就可以用touch在移动设备上向左或向右滑动,它会相应地向左或向右改变幻灯片。最好的方法是什么?我跟在达米安·德莱吉尔的密码笔后面 标题 临时的,临时的 我们必须解释一下,我们的生活是暂时的。尼莫·埃尼姆 我认为这是一个暂时的问题 autem quibusdam和aut Temporibus autem quibusdam和aut Temporibus autem quibusdam和aut。 标题1 所有人都能清楚地看到错误

我想添加javascript/css/任何需要的东西,这样我就可以用touch在移动设备上向左或向右滑动,它会相应地向左或向右改变幻灯片。最好的方法是什么?我跟在达米安·德莱吉尔的密码笔后面


  • 标题

    临时的,临时的 我们必须解释一下,我们的生活是暂时的。尼莫·埃尼姆 我认为这是一个暂时的问题 autem quibusdam和aut Temporibus autem quibusdam和aut Temporibus autem quibusdam和aut。
  • 标题1

    所有人都能清楚地看到错误所在 劳丹蒂姆酒,一杯酒,一杯酒 《国际公共部门会计准则》是一部真实的和准建筑师的著作 格言必须解释清楚。尼莫·埃尼姆·伊普萨姆·沃卢帕塔姆·奎亚·沃卢帕塔斯·西特 无论你是谁,你都应该为自己的行为负责 这是一个合理的解释。内克·波罗·奎斯夸姆东部,魁 多洛雷姆·伊普苏姆·奎亚·多洛尔·阿梅特、康塞特图尔、阿迪皮西·维利特、塞德·奎亚 非努姆夸姆
  • 标题2

    所有人都能清楚地看到错误所在 劳丹蒂姆酒,一杯酒,一杯酒 《国际公共部门会计准则》是一部真实的和准建筑师的著作 格言必须解释清楚。尼莫·埃尼姆·伊普萨姆·沃卢帕塔姆·奎亚·沃卢帕塔斯·西特 无论你是谁,你都应该为自己的行为负责 这是一个合理的解释。内克·波罗·奎斯夸姆东部,魁 多洛雷姆·伊普苏姆·奎亚·多洛尔·阿梅特、康塞特图尔、阿迪皮西·维利特、塞德·奎亚 非货币配给权。内克·波罗·奎斯坎东部, 我不知道该怎么做,
  • 标题3

    合理的价格。内克·波罗·奎斯夸姆东部,奎多勒姆 这是一个合理的解释。内克 这是一个合理的理由 这是一个很好的例子。这是我最喜欢的,也是我最喜欢的 这是一个合理的解释。内克波罗 这是我的错,我的错,我的错,
  • 标题4

    在vero eos和accusamus和iusto Dignessimos ducimus 白兰地病是一种腐败的疾病 除铜酸盐以外的其他分子 天意,同样地,我们也应该为自己的生命付出代价, 这是我的劳动和财富。等,等,等,等 特快。临时自由党(Nam libero Temporate)和诺贝尔和平解决方案(Solta nobis est eligendi) 选择在facere的最大位置处的阻抗减去id 可能的,可能的,可能的,可能的。 临时性autem quibusdam和aut
  • 标题5

    在vero eos和accusamus和iusto Dignessimos ducimus 白兰地病是一种腐败的疾病 除铜酸盐以外的其他分子 天意,同样地,我们也应该为自己的生命付出代价, 这是我的劳动和财富。等,等,等,等 特快。临时自由党(Nam libero Temporate)和诺贝尔和平解决方案(Solta nobis est eligendi) 选择在facere的最大位置处的阻抗减去id 可能的,可能的,可能的,可能的。 临时的,临时的 临时性autem quibusdam和aut

我在某处找到了一个函数,您可以更改一些以获得正确的结果。 但是我认为没有javascript你是做不到的

carousel.on('touchstart touchmove touchend', function (e) {
                            touchHandler(e);
});
function touchHandler (event) {
                    var touch
                        , xSwipe
                        , ySwipe;

                    if (typeof event !== 'undefined'){  
                        // for vanilla javascript use event.touches
                        if (typeof event.originalEvent.touches !== 'undefined') {
                            touch = event.originalEvent.touches[0];

                            switch (event.originalEvent.type) {
                                case 'touchstart':
                                case 'mousedown':
                                    _touches[event.originalEvent.type].x = touch.pageX;
                                    _touches[event.originalEvent.type].y = touch.pageY;
                                    break;
                                case 'touchmove':
                                case 'mousemove':
                                    _touches[event.originalEvent.type].x = touch.pageX;
                                    _touches[event.originalEvent.type].y = touch.pageY;
                                    break;
                                case 'touchend':
                                case 'mouseup':
                                    if (!carousel.data('busyAnimating')) {
                                        _touches[event.originalEvent.type] = true;

                                        if (_touches.touchstart.x > -1 && _touches.touchmove.x > -1) {
                                            xSwipe = Math.abs(_touches.touchstart.x - _touches.touchmove.x);
                                            ySwipe = Math.abs(_touches.touchstart.y - _touches.touchmove.y);

                                            if (xSwipe > ySwipe && xSwipe > (getViewport().width * .33)) {
                                                _touches.direction = _touches.touchstart.x < _touches.touchmove.x ? 'left' : 'right';

                                                if (_touches.direction === 'left') {
                                                    moveToSlide('prev');
                                                } else if (_touches.direction === 'right') {
                                                    moveToSlide('next')
                                                }
                                            }
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                }
旋转木马开启('touchstart touchmove touchend',功能(e){ 触摸处理器(e); }); 函数touchHandler(事件){ 变压触控 ,xSwipe ,ySwipe; 如果(事件类型!==“未定义”){ //对于普通javascript,请使用event.touchs if(typeof event.originalEvent.touchs!=“未定义”){ touch=event.originalEvent.touch[0]; 开关(event.originalEvent.type){ 案例“touchstart”: 案例“mousedown”: _触摸[event.originalEvent.type].x=touch.pageX; _触摸[event.originalEvent.type].y=touch.pageY; 打破 “触摸移动”案例: 案例“mousemove”: _触摸[event.originalEvent.type].x=touch.pageX; _触摸[event.originalEvent.type].y=touch.pageY; 打破 “touchend”案例: “鼠标”一案: 如果(!carousel.data('busyAnimating')){ _触摸[event.originalEvent.type]=true; 如果(_touch.touchstart.x>-1&&u touch.touchmove.x>-1){ xSwipe=Math.abs(_-touchs.touchtstart.x-_-touchs.touchmove.x); ySwipe=Math.abs(_-touchs.touchstart.y-_-touchs.touchsmove.y); if(xSwipe>ySwipe&&xSwipe>(getViewport().width*.33)){
carousel.on('touchstart touchmove touchend', function (e) {
                            touchHandler(e);
});
function touchHandler (event) {
                    var touch
                        , xSwipe
                        , ySwipe;

                    if (typeof event !== 'undefined'){  
                        // for vanilla javascript use event.touches
                        if (typeof event.originalEvent.touches !== 'undefined') {
                            touch = event.originalEvent.touches[0];

                            switch (event.originalEvent.type) {
                                case 'touchstart':
                                case 'mousedown':
                                    _touches[event.originalEvent.type].x = touch.pageX;
                                    _touches[event.originalEvent.type].y = touch.pageY;
                                    break;
                                case 'touchmove':
                                case 'mousemove':
                                    _touches[event.originalEvent.type].x = touch.pageX;
                                    _touches[event.originalEvent.type].y = touch.pageY;
                                    break;
                                case 'touchend':
                                case 'mouseup':
                                    if (!carousel.data('busyAnimating')) {
                                        _touches[event.originalEvent.type] = true;

                                        if (_touches.touchstart.x > -1 && _touches.touchmove.x > -1) {
                                            xSwipe = Math.abs(_touches.touchstart.x - _touches.touchmove.x);
                                            ySwipe = Math.abs(_touches.touchstart.y - _touches.touchmove.y);

                                            if (xSwipe > ySwipe && xSwipe > (getViewport().width * .33)) {
                                                _touches.direction = _touches.touchstart.x < _touches.touchmove.x ? 'left' : 'right';

                                                if (_touches.direction === 'left') {
                                                    moveToSlide('prev');
                                                } else if (_touches.direction === 'right') {
                                                    moveToSlide('next')
                                                }
                                            }
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                }
const slider = document.getElementById('slider1');
const slides = slider.querySelectorAll('input');

slider.addEventListener('touchmove', (e) => {
  // Add step 1 in here
});

slider.addEventListener('touchend', (e) => {
  // Add step 2 in here
});