简体   繁体   English

全日历窗口自动向上滚动

[英]Fullcalendar window is automatically scrolling up

I've got an issue with creating new events.我在创建新事件时遇到了问题。 In Chrome for example, scroll down the to the bottom, make sure it's height is small enough, so you cannot see the whole calendar.例如在 Chrome 中,向下滚动到底部,确保它的高度足够小,这样你就看不到整个日历。

Click buttons month , then week , then month , week (several times).单击按钮,然后是,然后是(多次)。 Now try to create an event today at 11pm - a modal window will appear.现在尝试在今天晚上 11 点创建一个事件 - 将出现一个模式窗口。 Press Cancel.按取消。

What I get now and what is wrong - browser window is scrolled up, until the Title of the calendar!我现在得到了什么,出了什么问题 - 浏览器窗口向上滚动,直到日历的标题!

As you see - there is no my own libraries included, only basic code from fullcalendar/semantic-ui documentation.如您所见 - 没有包含我自己的库,只有 fullcalendar/semantic-ui 文档中的基本代码。

The issue doesn't happen with Semantic-ui modal window itself (without fullcalendar).这个问题不会发生在 Semantic-ui 模态窗口本身(没有 fullcalendar)。 Moreover, just after a page refresh everything is Ok, but then pressing month/week/month/week enables this scrolling up.此外,在页面刷新后一切正常,但随后按月/周/月/周可以向上滚动。

 $(document).ready(function() { $('#calendar').fullCalendar({ header: { right: 'month,agendaWeek' }, aspectRatio: 1.8, selectable: true, select: function() { $('.ui.modal').modal('show'); } }); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://fullcalendar.io/js/fullcalendar-2.2.5/fullcalendar.css"> <script type="text/javascript" src="https://fullcalendar.io/js/fullcalendar-2.2.5/lib/moment.min.js"></script> <script type="text/javascript" src="https://fullcalendar.io/js/fullcalendar-2.2.5/fullcalendar.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.1/semantic.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.1/semantic.min.css"> <div style="height:1000px;"></div> <div id="calendar"></div> <div class="ui small modal"> <div class="actions"> <div class="ui black cancel button">Cancel</div> </div> </div>

JSFiddle example: https://jsfiddle.net/edomzxLL/1/ JSFiddle 示例: https ://jsfiddle.net/edomzxLL/1/

Please help me to understand what's wrong and how to prevent this strange/unneeded scrolling up?请帮助我了解出了什么问题以及如何防止这种奇怪的/不需要的向上滚动?


EDIT:编辑:

At the moment I think it's done by a modal window.目前我认为它是由模态窗口完成的。 There is a code, which runs when window closes:有一个代码,它在窗口关闭时运行:

...
onComplete : function() {
  settings.onHidden.call(element);
  module.restore.focus();
  callback();
}
...

... onHidden() is fired and then focus returns to the last focused object. ... onHidden()被触发,然后焦点返回到最后一个焦点对象。 That's an issue.这是个问题。 If I have a focused element somewhere in the beginning of a webpage, then scroll down, show a modal window and close it - browser is automatically scrolling up to the beginning of the page to that focused element.如果我在网页开头的某处有一个焦点元素,然后向下滚动,显示一个模式窗口并关闭它 - 浏览器会自动向上滚动到页面的开头到该焦点元素。 Commenting out this line helps me, but this is editing a Semantic source code, which is not a solution.注释掉这一行对我有帮助,但这是编辑语义源代码,这不是解决方案。 In my case probably button gets a focus.在我的情况下,按钮可能会获得焦点。

 const calendar = new Calendar(calendarEl, {
  timeZone: 'UTC',
  plugins: [interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin],
  headerToolbar: { left: 'prev,next', center: 'title', right: '' },
  initialView: calendarView,
  eventDurationEditable: true,
  slotDuration: `00:${duracaoMinimaConsulta}`,
  locale: 'pt-br',
  navLinks: true,
  editable: true,
  dayMaxEvents: true,
  dateClick: handleDateClick,
  eventClick: handleEventClick,
  eventResize: handleResizeEvent,
  eventDrop: handleDropEvent,
  **scrollTime: scrollTime, (Set this property)** Ex.: scrollTime: "20:00"
  events: eventosState,
});

scrollTimeReset道具设置为falsehttps : scrollTimeReset

I really don't understand the issue.我真的不明白这个问题。

The first div in your document has a height of 1000px so obviously the rest of the document flows down.文档中的第一个 div 的高度为 1000px,因此显然文档的其余部分向下流动。

When you open your modal it has a height and width of 100 % so scrolling up is disabled.当您打开模态时,它的高度和宽度为 100%,因此禁用向上滚动。

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

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