This is a migrated thread and some comments may be shown as answers.

BringIntoView on page load

5 Answers 73 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 22 Jun 2015, 04:30 PM

Hello,

I'm calling bringIntoView() once my diagram has been initialized, in order to fit the diagram into the space available.

I'm doing that by subscribing to the requestEnd event of the datasource, as below:

var datasource = new kendo.data.DataSource({
    transport: {
        read: {
            url: "MyDataUrl",
            type: "POST",
            dataType: "json",
        }
    },
    requestEnd: function(e) {
        setTimeout(function() { ZoomToFit(); },200);
    },
});
 
function ZoomToFit() {
    var diagram = $("#myDiagram").getKendoDiagram();
    diagram.bringIntoView(diagram.shapes);
}

I found that calling ZoomToFit() directly from the event was too quick, and would attempt to perform the action before the diagram had been initially displayed, so I used a timeout.

The problem I have is that in some cases, even with the timeout, the ZoomToFit() method is called before the diagram is initially displayed.

I therefore need a method of performing that initial bringIntoView() as soon as the diagram has been displayed. Is there a better event I should be using?

Note that calling bringIntoView() straight after initializing the diagram is also too early, it would seem. And I can't just extend the timeout, as this will be perceived as a jump, for users whose diagram does display quickly.

Thanks,

George

5 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 25 Jun 2015, 06:52 AM
Hi,

Please accept my apologies for the delayed response.

The most appropriate moment for calling bringIntoView is in the dataBound handler. Note that it still needs a timeout:
        function onDataBound(e) {
            var that = this;
            setTimeout(function () {
                that.bringIntoView(that.shapes);
            }, 0);
        }

 

This is something that we need to look into. Maybe a special event handler is in order.
Apologies for the caused inconvenience.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
George
Top achievements
Rank 1
answered on 25 Jun 2015, 01:01 PM

OK, thanks for the info.

I'll use onDataBound, as you suggest, but it would really be of value if you could implement a new event handler in a future release.

Many thanks,

George

0
T. Tsonev
Telerik team
answered on 29 Jun 2015, 06:18 AM
Hi,

We might move the dataBound event to trigger a bit later when the shapes are created.
This doesn't sound like it will break something, but it will remove the need for a separate event.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
George
Top achievements
Rank 1
answered on 06 Jul 2015, 10:03 AM

Thanks for the update.

I've now implemented it using the dataBound event, as you suggested.

Presumably this will not require a change on our part once you've modified the timing of that event. It should just seamlessly work.

Thanks,

George

0
T. Tsonev
Telerik team
answered on 06 Jul 2015, 11:42 AM
Hello,

Indeed, this is our plan as well. We try not to break client code whenever possible.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Diagram
Asked by
George
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
George
Top achievements
Rank 1
Share this question
or