framework7 keypad + swipe incompatibility

169 views Asked by At

As title, when a keypad is within a swipe it won't work, any ideas of a workaroud?

<div class="swiper-container">
    <div class="swiper-wrapper">
        <div class="swiper-slide" style="text-align:center">
            <h3>Product name</h3>
            <div class="range-slider"><input type="range" min="0" value="" step="1" onchange="$$(this).parent().parent().find('span').html(this.value);" oninput="$$(this).parent().parent().find('input').val(this.value);"></div>
            <div class="list-block">
                <ul>
                    <li><div class="item-content">
                        <div class="item-inner">
                            <div class="item-title label">Qtd</div>
                            <div class="item-input">
                                <input type="text" class="kpNumpad">
                            </div>
                        </div>
                    </div></li>
                </ul>
            </div>
            <img  src="img/temp/img01-mobile-md.jpg" style="max-height: 45vh;">
        </div>
    </div>
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
</div>

The script to create keypad + swipe:

myApp.keypad({ 'input': '.kpNumpad', 'dotButton': true, 'toolbarCloseText': 'Fechar', 'toolbarTemplate': '' });

myApp.swiper('.swiper-container',{
    'onlyExternal': true,
    'nextButton': '.swiper-button-next',
    'prevButton': '.swiper-button-prev',
    'speed':  600,
    'loop': true, // <- DON'T USE IT, set it to false (see my answer)
    'effect': 'slide' //-- slide, coverflow, flip
});

No matter the order if swiper or keypad is called first, none of them work, debugging inside a browser, the div of keypad is created but don't show, and input becomes unclicable.

1

There are 1 answers

0
Paulo Lima On BEST ANSWER

Problem solved by creating an instance for each keypad input.

window.top.myKeyPad = [];
$$('.kpNumpad').each(function(){
     var kpNum = myApp.keypad({ 'input': $(this), 'dotButton': true,  'toolbarTemplate': '' });
     window.top.myKeyPad.push(kpNum);
});

NOTE: AVOID Swiper parameter 'loop' == false, it will break the keypad, also, I highly recommend not to use it as it will erase your input values when loop restart