google-code-export / gwt-cal

Automatically exported from code.google.com/p/gwt-cal
1 stars 0 forks source link

MonthView fireTimeBlockClickEvent returning wrong date in scroll mode #134

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. set calendar size so the width and (or) height exceed screen size, therefore 
scrollbar will visible
2. in original state (unscrollable), click a cell, it will returning correct 
date
3. scroll a little or maximum, click the same cell as step (2), it will 
returning incorrect date

What is the expected output? What do you see instead?
whether in scroll mode or unscrolled mode, the date returned should be the same

What version of the product are you using? On what operating system?
Version: 0.9.2
OS: Ubuntu 11.04, Kernel 2.6.38-11
Browser: Mozilla Firefox 5.0, Google Chrome 13.0.782.215

Please provide any additional information below.
I've attach fix for this, root element scroll left and scroll top position 
should be included in the calculation

Original issue reported on code.google.com by jaka.ram...@gmail.com on 4 Oct 2011 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
I'm sorry, before step 2) you must add addTimeBlockClickHandler first to the 
calendar

Original comment by jaka.ram...@gmail.com on 4 Oct 2011 at 4:03

GoogleCodeExporter commented 9 years ago
Unfortunately, I don't think the fix works completely.  See the attached 
screenshot.
Steps:
1) Set calendar size so that the height exceeds the browser window so that the 
vertical scrollbar is visible.
2) Without performing any other activities, once the calendar is loaded, click 
a cell.  It returns the correct date.  It also scrolls to the bottom of the 
screen.
3) Move the mouse to another date, click on it, and the incorrect date is 
returned.  The date returned is the one I would get if I simply moved the mouse 
thumbwheel two clicks up.

Regards, -Dwight

Original comment by dwight.l...@gmail.com on 21 Jan 2012 at 2:43

Attachments:

GoogleCodeExporter commented 9 years ago
Even more unfortunately, this was a case where I wrapped myself around the 
axles.  This issue come up in a split browser window like you see w/ firebug.  
If you detach the firebug console - it all works fine (well, w/ your fix).

-Dwight

Original comment by dwight.l...@gmail.com on 21 Jan 2012 at 3:03

GoogleCodeExporter commented 9 years ago
Appears similar to http://code.google.com/p/gwt-cal/issues/detail?id=144 
(DayView instead MonthView).

Original comment by dom....@gmail.com on 8 Sep 2012 at 6:22

GoogleCodeExporter commented 9 years ago
For sure seems similar, but I cannot replicate either.

Any help replicating the problem is welcome

Original comment by ctasada on 15 Sep 2012 at 10:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi ,

I fixed this problem simply by adding Window.getScrollTop() and 
Window.getScrollLeft() for x and y calculation..
I just changed the dayclicked method on MonthView.java :

    private void dayClicked(Event event) {
        int y = event.getClientY() + Window.getScrollTop() - DOM.getAbsoluteTop(appointmentCanvas.getElement());
        int x = event.getClientX() + Window.getScrollLeft() - DOM.getAbsoluteLeft(appointmentCanvas.getElement());
        int row = (int) Math.floor(y / (appointmentCanvas.getOffsetHeight() / monthViewRequiredRows));
        int col = (int) Math.floor(x / (appointmentCanvas.getOffsetWidth() / DAYS_IN_A_WEEK));
        calendarWidget.fireTimeBlockClickEvent(
            cellDate(row * DAYS_IN_A_WEEK + col));

Original comment by mohieddi...@gmail.com on 1 Oct 2012 at 8:50

Attachments:

GoogleCodeExporter commented 9 years ago
But i have a problem only with Firefox browser (works fine with chrome and 
other browser... ), when i scroll to the bottom of the screen and click on a 
day it automatically scrolls to the top of the screen...
any idea how to fix this?

Original comment by mohieddi...@gmail.com on 1 Oct 2012 at 8:56

GoogleCodeExporter commented 9 years ago
Hi ,

I found it , the problem with firefox scrolling mode in monthView is caused by 
the FocusPanel in the InteractiveWidget.java, it seem when a cell is clicked 
the screen scrolls depending to the FocusPanel location...
I solved it by fixing the FocusPanel Height.

 /**
     * Makes the widget's focus panel invisible.
     */
    private void hideFocusPanel() {
        RootPanel.get().add(focusPanel);
        DOM.setStyleAttribute(focusPanel.getElement(), "position", "absolute");
        DOM.setStyleAttribute(focusPanel.getElement(), "top", "-10");
        DOM.setStyleAttribute(focusPanel.getElement(), "left", "-10");
        // fix scroll mode problems
        DOM.setStyleAttribute(focusPanel.getElement(), "height", "900px");
        DOM.setStyleAttribute(focusPanel.getElement(), "width", "0px");
    }
Tested on firefox and chrome

Original comment by mohieddi...@gmail.com on 3 Oct 2012 at 8:51

GoogleCodeExporter commented 9 years ago
To replicate was needed to remove the autosizing from the get-cal-demo code and 
increase the calendar's height

Fixed in r431

Pending to fix the focus problem. I need to check if changing the panel's 
height is the best solution.

Original comment by ctasada on 10 Oct 2012 at 10:36

GoogleCodeExporter commented 9 years ago
Hi,

The previous solution regarding the focus problem has a problem. When the 
focusPanel receives the focus it's visible, also doesn't solve the problem when 
the panel height is bigger than 1500px or when there's an horizontal scroll.

The next solution seems better

    private void hideFocusPanel() {
        focusPanel.setVisible(false);
        RootPanel.get().add(focusPanel);
        DOM.setStyleAttribute(focusPanel.getElement(), "position", "absolute");
        DOM.setStyleAttribute(focusPanel.getElement(), "top", "0");
        DOM.setStyleAttribute(focusPanel.getElement(), "left", "0");
        DOM.setStyleAttribute(focusPanel.getElement(), "height", "100%");
        DOM.setStyleAttribute(focusPanel.getElement(), "width", "100%");
    }

Any comments before committing it?

Original comment by ctasada on 15 Oct 2012 at 8:10

GoogleCodeExporter commented 9 years ago
Done in rev 433

Original comment by ctasada on 21 Oct 2012 at 4:51

GoogleCodeExporter commented 9 years ago
I just realized that this fix is breaking the keyevent handling, so I'm 
reverting it until I find a proper fix, sorry.

Original comment by ctasada on 15 Nov 2012 at 9:37

GoogleCodeExporter commented 9 years ago
Solved the problem with vertical scroll in rev 437

Horizontal scroll needs some kind of different solution. Suggestions are 
welcome ;)

Original comment by ctasada on 19 Dec 2012 at 10:19