简体   繁体   English

如何使用yii2fullcalendar处理长按事件

[英]How to handle a long press event with yii2fullcalendar

I use yii2fullcalendar for my website. 我在网站上使用yii2fullcalendar

On mobile device, a "dayClick" event is fired although we just want to scroll down the screen. 在移动设备上,尽管我们只想向下滚动屏幕,但会触发“ dayClick”事件。

How to change "dayClick" to a day double click event ? 如何将“ dayClick”更改为一天双击事件?

UPDATE: Actually, I want to avoid an inconvenient usage on mobile device. 更新:实际上,我想避免在移动设备上使用不便。 So, it's better if we can set a "long press" parameter instead of finding the way to change "dayClick" to a day double click event. 因此,最好设置一个“长按”参数,而不是寻找将“ dayClick”更改为一天双击事件的方法。

This is my view.php 这是我的view.php

<?= \yii2fullcalendar\yii2fullcalendar::widget(array(
        'options' => [
        ],
        'clientOptions' => [
            'allDaySlot' => false,
            'selectHelper' => true,
            'eventClick' => new JsExpression($JSEventClick),
            'dayClick' => new JsExpression($JSDayClick),
            'eventMouseover' =>new JsExpression($JSDayMouseover),
            'eventMouseout' =>new JsExpression($JSDayMouseout),
            'defaultView' => 'agendaWeek',
            'firstDay' => date('w'),  // Sunday=0, Monday=1, Tuesday=2, etc.
            'header' => [
                'center'=>'prev,next today',
                'left'=>'',
                'right'=>'agendaDay,agendaWeek,month',
            ],
        ],
        'ajaxEvents' => Url::to(......)
    ));
    ?>

Thank you. 谢谢。

You should be able to modify your dayClick function to handle a double click using the following algorithm: 您应该可以使用以下算法修改dayClick函数以处理双击:

  • Set variable clicked_once to false. 将变量clicked_once设置为false。
  • On click: 点击时:
    • If !clicked_once 如果!clicked_once
      • Set clicked_once to true. clicked_once设置为true。
      • Start a timeout function to occur after xx seconds. 启动超时功能以在xx秒后发生。
        • On timeout, set clicked_once to false. 超时时,将clicked_once设置为false。
    • If clicked_once 如果clicked_once
      • Perform event 执行活动
      • set clicked_once to false. clicked_once设置为false。

Sorry to provide an algorithm rather than code, don't have any reference material in front of me at them moment. 很抱歉提供的是算法而不是代码,目前他们手上没有参考资料。

I got a better solution for my issue. 我有一个更好的解决方案。

That is set a parameter to: 将参数设置为:

longPressDelay

within the client options as below 在下面的客户端选项中

<?= \yii2fullcalendar\yii2fullcalendar::widget(array(
        'options' => [
        ],
        'clientOptions' => [
            'allDaySlot' => false,
            'selectHelper' => true,
            'eventClick' => new JsExpression($JSEventClick),
            'dayClick' => new JsExpression($JSDayClick),
            'eventMouseover' =>new JsExpression($JSDayMouseover),
            'eventMouseout' =>new JsExpression($JSDayMouseout),
            'defaultView' => 'agendaWeek',

            'longPressDelay' => 1500, // -> Add here

            'firstDay' => date('w'),  // Sunday=0, Monday=1, Tuesday=2, etc.
            'header' => [
                'center'=>'prev,next today',
                'left'=>'',
                'right'=>'agendaDay,agendaWeek,month',
            ],
        ],
        'ajaxEvents' => Url::to(......)
    ));
    ?>

Refer to: https://github.com/philippfrenzel/yii2fullcalendar/issues/72#issuecomment-268556312 请参阅: https : //github.com/philippfrenzel/yii2fullcalendar/issues/72#issuecomment-268556312

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM