Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.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 如何在窗体上禁用刷卡?_Javascript_Jquery_Swipe - Fatal编程技术网

Javascript 如何在窗体上禁用刷卡?

Javascript 如何在窗体上禁用刷卡?,javascript,jquery,swipe,Javascript,Jquery,Swipe,我正在尝试使用找到的代码刷页面。 我尝试只使用支持水平滑动的部分。 然后我遇到了一个问题。 我试图做的是将表单标记包含在已扫描的div中,但代码甚至不允许对div中的输入标记进行聚焦和键入 到目前为止,我试图通过以下方式限制目标元素: 1. replacing // the slides this.slides = [].slice.call( this.handle.children ); /*with*/ // the slides var slides =

我正在尝试使用找到的代码刷页面。 我尝试只使用支持水平滑动的部分。 然后我遇到了一个问题。 我试图做的是将表单标记包含在已扫描的div中,但代码甚至不允许对div中的输入标记进行聚焦和键入

到目前为止,我试图通过以下方式限制目标元素:

1. replacing     
  // the slides
  this.slides = [].slice.call( this.handle.children );
/*with*/   
  // the slides
  var slides = [].slice.call( this.imgDragger.querySelectorAll('div.handle>*:not(form)') );

2. adding
  if (slide.tagName.toLowerCase() == "form") { return }
/*and*/
  if (currentSlide .tagName.toLowerCase() == "form") { return }

/*after*/
  slide.addEventListener( 'click', function() {
/*and*/
  currentSlide = self.slides[ self.current ];
/*respectively.*/
但这些都不适合我:( 有人能帮我修改代码,这样它就可以禁止在表单标签上滑动了吗

下面是我的html的结构

<body>
    <div id="slideshow" class="dragslider">
      <section class="img-dragger img-dragger-large dragdealer">
        <div class="handle">            
          <div class="slide">           
            <div class="img-wrap">
                swiping page #1
              <form><input type="text" /></form>

            </div>          
          </div>
          <div class="slide">                           
            <div class="img-wrap">
                swiping page #2                     
            </div>                          
          </div>
        </div>
      </section><!-- /img-dragger-->
    </div>
    <script>
        (function() {                   

            var toggleBtnn = function() {
                    if( slideshow.isFullscreen ) {
                        classie.add( switchBtnn, 'view-maxi' );
                    }
                    else {
                        classie.remove( switchBtnn, 'view-maxi' );
                    }
                },
                slideshow = new DragSlideshow( document.getElementById( 'slideshow' ), { 
                    // toggle between fullscreen and minimized slideshow
                    onToggle : toggleBtnn                                               

                }),
                toggleSlideshow = function() {                  

                    slideshow.toggle();
                    toggleBtnn();

                }                   

            // toggle between fullscreen and small slideshow
            switchBtnn.addEventListener( 'click', toggleSlideshow )         

        }());           
    </script>   
</body>

滑动页面#1
滑动页面#2
(函数(){
var toggleBtnn=函数(){
如果(slideshow.isFullscreen){
添加(开关BTNN,“查看最大值”);
}
否则{
移除类别(开关BTNN,“查看最大值”);
}
},
slideshow=新的DragSlideshow(document.getElementById('slideshow'),{
//在全屏和最小化幻灯片放映之间切换
onToggle:ToggleBtn
}),
toggleSlideshow=函数(){
slideshow.toggle();
toggleBtnn();
}                   
//在全屏和小幻灯片之间切换
SwitchBtn.addEventListener('单击',切换幻灯片放映)
}());           
下面是dragslideshow.js:

/**
 * dragslideshow.js v1.0.0
 * http://www.codrops.com
 *
 * Licensed under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Copyright 2014, Codrops
 * http://www.codrops.com
 */
;( function( window ) {

    'use strict';

    var docElem = window.document.documentElement,
        transEndEventNames = {
            'WebkitTransition': 'webkitTransitionEnd',
            'MozTransition': 'transitionend',
            'OTransition': 'oTransitionEnd',
            'msTransition': 'MSTransitionEnd',
            'transition': 'transitionend'
        },
        transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
        support = { transitions : Modernizr.csstransitions };

    /**
     * gets the viewport width and height
     * based on http://responsejs.com/labs/dimensions/
     */
    function getViewport( axis ) {
        var client, inner;
        if( axis === 'x' ) {
            client = docElem['clientWidth'];
            inner = window['innerWidth'];
        }
        else if( axis === 'y' ) {
            client = docElem['clientHeight'];
            inner = window['innerHeight'];
        }

        return client < inner ? inner : client;
    }

    /**
     * extend obj function
     */
    function extend( a, b ) {
        for( var key in b ) { 
            if( b.hasOwnProperty( key ) ) {
                a[key] = b[key];
            }
        }
        return a;
    }

    /**
     * DragSlideshow function
     */
    function DragSlideshow( el, options ) { 
        this.el = el;
        this.options = extend( {}, this.options );
        extend( this.options, options );
        this._init();
    }

    /**
     * DragSlideshow options
     */
    DragSlideshow.prototype.options = {
        perspective : '1200',
        slideshowRatio : 0.3, // between: 0,1
        onToggle : function() { return false; },
        onToggleContent : function() { return false; },
        onToggleContentComplete : function() { return false; }
    }

    /**
     * init function
     * initialize and cache some vars
     */
    DragSlideshow.prototype._init = function() {
        var self = this;

        // current
        this.current = 0;

        // status
        this.isFullscreen = true;

        // the images wrapper element
        this.imgDragger = this.el.querySelector( 'section.dragdealer' );

        // the moving element inside the images wrapper
        this.handle = this.imgDragger.querySelector( 'div.handle' );

        // the slides
        this.slides = [].slice.call( this.handle.children );

        // total number of slides
        this.slidesCount = this.slides.length;

        if( this.slidesCount < 1 ) return;

        // cache options slideshowRatio (needed for window resize)
        this.slideshowRatio = this.options.slideshowRatio;

        // add class "current" to first slide
        classie.add( this.slides[ this.current ], 'current' );

        // the pages/content
        this.pages = this.el.querySelector( 'section.pages' );

        // set the width of the handle : total slides * 100%
        this.handle.style.width = this.slidesCount * 100 + '%';

        // set the width of each slide to 100%/total slides
        this.slides.forEach( function( slide ) {
            slide.style.width = 100 / self.slidesCount + '%';
        } );

        // initialize the DragDealer plugin
        this._initDragDealer();

        // init events
        this._initEvents();
    }

    /**
     * initialize the events
     */
    DragSlideshow.prototype._initEvents = function() {
        var self = this;

        this.slides.forEach( function( slide ) {
            // clicking the slides when not in isFullscreen mode
            slide.addEventListener( 'click', function() {
                if( self.isFullscreen || self.dd.activity || self.isAnimating ) return false;

                if( self.slides.indexOf( slide ) === self.current ) {
                    self.toggle();
                }
                else {
                    self.dd.setStep( self.slides.indexOf( slide ) + 1 );
                }
            } );

            // reveal content
            slide.querySelector( 'button.content-switch' ).addEventListener( 'click', function() { self._toggleContent( slide ); } );
        } );

        // keyboard navigation events
        document.addEventListener( 'keydown', function( ev ) {
            var keyCode = ev.keyCode || ev.which,
                currentSlide = self.slides[ self.current ];

            if( self.isContent ) {
                switch (keyCode) {
                    // up key
                    case 38:
                        // only if current scroll is 0:
                        if( self._getContentPage( currentSlide ).scrollTop === 0 ) {
                            self._toggleContent( currentSlide );
                        }
                        break;
                }
            }
            else {
                switch (keyCode) {
                    // down key
                    case 40:
                        // if not fullscreen don't reveal the content. If you want to navigate directly to the content then remove this check.
                        if( !self.isFullscreen ) return;
                        self._toggleContent( currentSlide );
                        break;
                    // right and left keys
                    case 37:
                        self.dd.setStep( self.current );
                        break;
                    case 39:
                        self.dd.setStep( self.current + 2 );
                        break;
                }
            }
        } );
    }

    /**
     * gets the content page of the current slide
     */
    DragSlideshow.prototype._getContentPage = function( slide ) {
        return this.pages.querySelector( 'div.content[data-content = "' + slide.getAttribute( 'data-content' ) + '"]' );
    }

    /**
     * show/hide content
     */
    DragSlideshow.prototype._toggleContent = function( slide ) {
        if( this.isAnimating ) {
            return false;
        }
        this.isAnimating = true;

        // callback
        this.options.onToggleContent();

        // get page
        var page = this._getContentPage( slide );

        if( this.isContent ) {
            // enable the dragdealer
            this.dd.enable();
            classie.remove( this.el, 'show-content' );
        }
        else {
            // before: scroll all the content up
            page.scrollTop = 0;
            // disable the dragdealer
            this.dd.disable();
            classie.add( this.el, 'show-content' ); 
            classie.add( page, 'show' );
        }

        var self = this,
            onEndTransitionFn = function( ev ) {
                if( support.transitions ) {
                    if( ev.propertyName.indexOf( 'transform' ) === -1 || ev.target !== this ) return;
                    this.removeEventListener( transEndEventName, onEndTransitionFn );
                }
                if( self.isContent ) {
                    classie.remove( page, 'show' ); 
                }
                self.isContent = !self.isContent;
                self.isAnimating = false;
                // callback
                self.options.onToggleContentComplete();
            };

        if( support.transitions ) {
            this.el.addEventListener( transEndEventName, onEndTransitionFn );
        }
        else {
            onEndTransitionFn();
        }
    }

    /**
     * initialize the Dragdealer plugin
     */
    DragSlideshow.prototype._initDragDealer = function() {
        var self = this;
        this.dd = new Dragdealer( this.imgDragger, {
            steps: this.slidesCount,
            speed: 0.4,
            loose: true,
            requestAnimationFrame : true,
            callback: function( x, y ) {
                self._navigate( x, y );
            }
        });
    }

    /**
     * DragDealer plugin callback: update current value
     */
    DragSlideshow.prototype._navigate = function( x, y ) {
        // add class "current" to the current slide / remove that same class from the old current slide
        classie.remove( this.slides[ this.current || 0 ], 'current' );
        this.current = this.dd.getStep()[0] - 1;
        classie.add( this.slides[ this.current ], 'current' );
    }

    /**
     * toggle between fullscreen and minimized slideshow
     */
    DragSlideshow.prototype.toggle = function() {
        if( this.isAnimating ) {
            return false;
        }
        this.isAnimating = true;

        // add preserve-3d to the slides (seems to fix a rendering problem in firefox)
        this._preserve3dSlides( true );

        // callback
        this.options.onToggle();

        classie.remove( this.el, this.isFullscreen ? 'switch-max' : 'switch-min' );
        classie.add( this.el, this.isFullscreen ? 'switch-min' : 'switch-max' );

        var self = this,
            p = this.options.perspective,
            r = this.options.slideshowRatio,
            zAxisVal = this.isFullscreen ? p - ( p / r ) : p - p * r;

        this.imgDragger.style.WebkitTransform = 'perspective(' + this.options.perspective + 'px) translate3d( -50%, -50%, ' + zAxisVal + 'px )';
        this.imgDragger.style.transform = 'perspective(' + this.options.perspective + 'px) translate3d( -50%, -50%, ' + zAxisVal + 'px )';

        var onEndTransitionFn = function( ev ) {
            if( support.transitions ) {
                if( ev.propertyName.indexOf( 'transform' ) === -1 ) return;
                this.removeEventListener( transEndEventName, onEndTransitionFn );
            }

            if( !self.isFullscreen ) {
                // remove preserve-3d to the slides (seems to fix a rendering problem in firefox)
                self._preserve3dSlides();
            }

            // replace class "img-dragger-large" with "img-dragger-small"
            classie.remove( this, self.isFullscreen ? 'img-dragger-large' : 'img-dragger-small' );
            classie.add( this, self.isFullscreen ? 'img-dragger-small' : 'img-dragger-large' );

            // reset transforms and set width & height
            self.imgDragger.style.WebkitTransform = 'translate3d( -50%, -50%, 0px )';
            self.imgDragger.style.transform = 'translate3d( -50%, -50%, 0px )';
            this.style.width = self.isFullscreen ? self.options.slideshowRatio * 100 + '%' : '100%';
            this.style.height = self.isFullscreen ? self.options.slideshowRatio * 100 + '%' : '100%';
            // reinstatiate the dragger with the "reflow" method
            self.dd.reflow();

            // change status
            self.isFullscreen = !self.isFullscreen;

            self.isAnimating = false;
        };

        if( support.transitions ) {
            this.imgDragger.addEventListener( transEndEventName, onEndTransitionFn );
        }
        else {
            onEndTransitionFn();
        }
    }

    /**
     * add/remove preserve-3d to the slides (seems to fix a rendering problem in firefox)
     */
    DragSlideshow.prototype._preserve3dSlides = function( add ) {
        this.slides.forEach( function( slide ) {
            slide.style.transformStyle = add ? 'preserve-3d' : '';
        });
    }

    /**
     * add to global namespace
     */
    window.DragSlideshow = DragSlideshow;

} )( window );
/**
*dragslideshow.js v1.0.0
* http://www.codrops.com
*
*根据麻省理工学院许可证授权。
* http://www.opensource.org/licenses/mit-license.php
* 
*版权所有2014,Codrops
* http://www.codrops.com
*/
(功能(窗口){
"严格使用",;
var docElem=window.document.documentElement,
Transandeventnames={
“WebKittTransition”:“WebKittTransitionEnd”,
'MozTransition':'transitionend',
“OTransition”:“oTransitionEnd”,
“msTransition”:“MSTransitionEnd”,
“transition”:“transitionend”
},
transEndEventName=transEndEventNames[现代化前缀('transition')],
支持={transitions:modernizer.cstransitions};
/**
*获取视口的宽度和高度
*基于http://responsejs.com/labs/dimensions/
*/
函数getViewport(轴){
var客户端,内部;
如果(轴=='x'){
client=docElem['clientWidth'];
内部=窗口['innerWidth'];
}
否则,如果(轴=='y'){
客户=docElem['clientHeight'];
内部=窗['innerHeight'];
}
返回客户<内部?内部:客户;
}
/**
*扩展obj函数
*/
功能扩展(a,b){
对于(b中的var键){
如果(b.hasOwnProperty(键)){
a[键]=b[键];
}
}
返回a;
}
/**
*DragSlideshow函数
*/
函数DragSlideshow(el,选项){
this.el=el;
this.options=extend({},this.options);
扩展(这个。选项,选项);
这个;
}
/**
*DragSlideshow选项
*/
DragSlideshow.prototype.options={
透视图:“1200”,
幻灯片放映比率:0.3,//介于:0,1之间
onToggle:function(){return false;},
onToggleContent:function(){return false;},
onToggleContentComplete:函数(){return false;}
}
/**
*初始化函数
*初始化并缓存一些变量
*/
DragSlideshow.prototype.\u init=function(){
var self=这个;
//当前
该电流=0;
//地位
this.isFullscreen=true;
//图像包装器元素
this.imgDragger=this.el.querySelector('section.dragdealer');
//图像包装器中的移动元素
this.handle=this.imgDragger.querySelector('div.handle');
//幻灯片
this.slides=[].slice.call(this.handle.children);
//幻灯片总数
this.slidescont=this.slides.length;
如果(this.slidescont<1)返回;
//缓存选项幻灯片比例(调整窗口大小时需要)
this.slideshowRatio=this.options.slideshowRatio;
//将“当前”类添加到第一张幻灯片
classie.add(this.slides[this.current],“current”);
//页面/内容
this.pages=this.el.querySelector('section.pages');
//设置手柄宽度:总幻灯片数*100%
this.handle.style.width=this.slideCount*100+'%';
//将每张幻灯片的宽度设置为100%/总幻灯片
this.slides.forEach(函数(幻灯片){
slide.style.width=100/self.slidescont+'%';
} );
//初始化DragDealer插件
这个;
//初始化事件
这个;
}
/**
*初始化事件
*/
DragSlideshow.prototype.\u initEvents=function(){
var self=这个;
this.slides.forEach(函数(幻灯片){
//非全屏模式时单击幻灯片
slide.addEventListener('click',function(){
if(self.isFullscreen | self.dd.activity | | self.isAnimating)返回false;
if(self.slides.indexOf(slide)==self.current){
self.toggle();
}
否则{
self.dd.setStep(self.slides.indexOf