Owl Carousel在移动ios / android上快速滚动时启用拖动

时间:2018-08-17 09:10:28

标签: android jquery ios owl-carousel owl-carousel-2

当我快速向上/向下滚动时,我尝试拖动轮播,但在ios / android中不起作用。这是我的example

 $('.owl-carousel').owlCarousel({
    autoWidth: true,
    center: true,
    items: 3,
    loop: true,
    margin: 10
  });

第1步:快速拖动垂直页面(向下拖动+快速向上拖动+触摸结束)

第2步::在滚动页面时,您将其水平拖动(我的轮播不滑动,我认为应该滚动并可以拖动)

如何使旋转木马在滚动时拖动,谢谢

1 个答案:

答案 0 :(得分:1)

您可以使用回调查看事件是否被触发。在这种情况下,不会在轮播上触发任何拖动事件,因此Owl Carousel不会收到拖动回调。

public class customAdapter extends BaseAdapter {

    String[] languages ;
    Context mContext;
    boolean isChecked = false;

    public customAdapter(String[] languages, Context mContext) {
        this.languages = languages;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return languages.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView=  inflater.inflate(R.layout.content_lang_list,parent,false);

        TextView lang_text = (TextView) rowView.findViewById(R.id.text_select_lang);
        final ImageView image_tick = (ImageView) rowView.findViewById(R.id.image_tick);

        lang_text.setText(languages[position]);
        image_tick.setImageResource(R.drawable.ic_checked);

        return rowView;

    }



public class ChangeLang extends AppCompatActivity {

    private ListView languageList;
    String[] languages = {"English","Portuguese","Arabic"};


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cahnge_lang);

        languageList = (ListView) findViewById(R.id.language_list);
        final customAdapter mAdapter = new customAdapter(languages,this);
        languageList.setAdapter(mAdapter);

        languageList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String selected = ((TextView) view.findViewById(R.id.text_select_lang)).getText().toString();
                Object itemObject = parent.getAdapter().getItem(position);
                LanguageSelect selectedLang = (LanguageSelect)itemObject;



            }
        });
    }
}

我也测试了其他几个轮播的功能(例如http://kenwheeler.github.io/slick/)。但他们都不具备这种能力。

这与浏览器如何处理拖动回调以及在移动设备上有关,是通过这种方式处理的。